Module: CloudstackClient::Router
- Defined in:
- lib/cloudstack_client/commands/router.rb
Instance Method Summary collapse
-
#destroy_router(id, opts = {async: true}) ⇒ Object
Destroy virtual router.
-
#get_router(name, project_id = nil) ⇒ Object
Get a router with a given name.
-
#list_routers(args = {:account => nil, :zone => nil, :projectid => nil, :status => nil, :name => nil}) ⇒ Object
Lists all virtual routers.
-
#start_router(id, opts = {async: true}) ⇒ Object
Start virtual router.
-
#stop_router(id, opts = {async: true}) ⇒ Object
Stop virtual router.
Instance Method Details
#destroy_router(id, opts = {async: true}) ⇒ Object
Destroy virtual router.
57 58 59 60 61 62 63 |
# File 'lib/cloudstack_client/commands/router.rb', line 57 def destroy_router(id, opts = {async: true}) params = { 'command' => 'destroyRouter', 'id' => id } opts[:async] ? send_async_request(params)['router'] : send_request(params) end |
#get_router(name, project_id = nil) ⇒ Object
Get a router with a given name.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cloudstack_client/commands/router.rb', line 8 def get_router(name, project_id = nil) params = { 'command' => 'listRouters', 'listall' => 'true', 'name' => name } params['projectid'] = project_id if project_id json = send_request(params) json['router'] ? json['router'].first : nil end |
#list_routers(args = {:account => nil, :zone => nil, :projectid => nil, :status => nil, :name => nil}) ⇒ Object
Lists all virtual routers.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cloudstack_client/commands/router.rb', line 23 def list_routers(args = {:account => nil, :zone => nil, :projectid => nil, :status => nil, :name => nil}) params = { 'command' => 'listRouters', 'listall' => 'true', 'isrecursive' => 'true' } if args[:zone] zone = get_zone(args[:zone]) unless zone puts "Error: Zone #{args[:zone]} not found" exit 1 end params['zoneid'] = zone['id'] end params['projectid'] = args[:projectid] if args[:projectid] params['state'] = args[:status] if args[:status] params['name'] = args[:name] if args[:name] if args[:account] account = list_accounts({name: args[:account]}).first unless account puts "Error: Account #{args[:account]} not found." exit 1 end params['domainid'] = account["domainid"] params['account'] = args[:account] end json = send_request(params) json['router'] || [] end |
#start_router(id, opts = {async: true}) ⇒ Object
Start virtual router.
68 69 70 71 72 73 74 |
# File 'lib/cloudstack_client/commands/router.rb', line 68 def start_router(id, opts = {async: true}) params = { 'command' => 'startRouter', 'id' => id } opts[:async] ? send_async_request(params)['router'] : send_request(params) end |
#stop_router(id, opts = {async: true}) ⇒ Object
Stop virtual router.
79 80 81 82 83 84 85 |
# File 'lib/cloudstack_client/commands/router.rb', line 79 def stop_router(id, opts = {async: true}) params = { 'command' => 'stopRouter', 'id' => id } opts[:async] ? send_async_request(params)['router'] : send_request(params) end |