Class: Yao::Cli::LBaaS::LB

Inherits:
Base
  • Object
show all
Defined in:
lib/yao/cli/lbaas/lb.rb

Instance Method Summary collapse

Methods inherited from Base

banner

Instance Method Details

#createObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/yao/cli/lbaas/lb.rb', line 32

def create
  vip_options = %w(vip_network_id vip_port_id vip_subnet_id)
  unless vip_options.map{|s| options[s]}.one?
    puts "Error: One of vip_network_id, vip_port_id, or vip_subnet_id must be specified."
    exit 1
  end

  params = generate_params
  result = Yao::Resources::LoadBalancer.create params

  # fix: すぐに出力するとvip_port_idがnullなのでエラーになる
  #pretty_output(Yao::Resources::Dumper::LoadBalancer.dump(result))
end

#listObject



8
9
10
11
12
# File 'lib/yao/cli/lbaas/lb.rb', line 8

def list
  result = Yao::Resources::LoadBalancer.list

  pretty_output(Yao::Resources::Dumper::LoadBalancer.dump(result))
end

#remove(uuid) ⇒ Object



58
59
60
# File 'lib/yao/cli/lbaas/lb.rb', line 58

def remove(uuid)
  Yao::Resources::LoadBalancer.delete(uuid)
end

#show(id_or_name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/yao/cli/lbaas/lb.rb', line 15

def show(id_or_name)
  if is_uuid?(id_or_name)
    result = Yao::Resources::LoadBalancer.find id_or_name
  else
    result = Yao::Resources::LoadBalancer.list.select do |lb|
      lb.name == id_or_name
    end
  end
  pretty_output(Yao::Resources::Dumper::LoadBalancer.dump(result))
end

#update(uuid) ⇒ Object



50
51
52
53
54
# File 'lib/yao/cli/lbaas/lb.rb', line 50

def update(uuid)
  params = generate_params
  result = Yao::Resources::LoadBalancer.update(uuid, params)
  pretty_output(Yao::Resources::Dumper::LoadBalancer.dump(result))
end