Sha256: d5db886ea4d532b0fe1f740ee3ebc6deba4deebbb06c7664ca3940b49d42d8f1

Contents?: true

Size: 1.73 KB

Versions: 4

Compression:

Stored size: 1.73 KB

Contents

module CloudstackClient

	module Router

		##
    # Lists all virtual routers.

    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

    ##
    # Destroy virtual router.

    def destroy_router(id, async = false)
      params = {
        'command' => 'destroyRouter',
        'id' => id
      }
      async ? send_async_request(params) : send_request(params)
    end

    ##
    # Start virtual router.

    def start_router(id, async = false)
      params = {
        'command' => 'startRouter',
        'id' => id
      }
      async ? send_async_request(params) : send_request(params)
    end

    ##
    # Stop virtual router.

    def stop_router(id, async = false)
      params = {
        'command' => 'stopRouter',
        'id' => id
      }
      async ? send_async_request(params) : send_request(params)
    end

	end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cloudstack-cli-0.3.1 lib/cloudstack-client/commands/router.rb
cloudstack-cli-0.2.2 lib/cloudstack-client/commands/router.rb
cloudstack-cli-0.2.1 lib/cloudstack-client/commands/router.rb
cloudstack-cli-0.2.0 lib/cloudstack-client/commands/router.rb