Sha256: a17b9011b25ba81cd1a4a10ea1580e33a2bd7a233fdd0bde19c9ab0419968284

Contents?: true

Size: 1.39 KB

Versions: 53

Compression:

Stored size: 1.39 KB

Contents

module CloudstackClient

	module PortForwardingRule

		##
    # Lists all port forwarding rules.

    def list_port_forwarding_rules(ip_address_id=nil, project_id)
      params = {
          'command' => 'listPortForwardingRules',
          'listall' => true,
          'isrecursive' => true
      }
      params['ipAddressId'] = ip_address_id if ip_address_id
      params['projectid'] = project_id if project_id
      json = send_request(params)
      json['portforwardingrule'] || []
    end

    ##
    # Gets the SSH port forwarding rule for the specified server.

    def get_ssh_port_forwarding_rule(server, cached_rules=nil)
      rules = cached_rules || list_port_forwarding_rules || []
      rules.find_all { |r|
        r['virtualmachineid'] == server['id'] &&
            r['privateport'] == '22'&&
            r['publicport'] == '22'
      }.first
    end

    ##
    # Creates a port forwarding rule.

    def create_port_forwarding_rule(ip_address_id, private_port, protocol, public_port, virtual_machine_id, async = true)
      params = {
          'command' => 'createPortForwardingRule',
          'ipAddressId' => ip_address_id,
          'privatePort' => private_port,
          'protocol' => protocol,
          'publicPort' => public_port,
          'virtualMachineId' => virtual_machine_id
      }
      async ? send_async_request(params)['portforwardingrule'] : send_request(params)
    end

	end

end

Version data entries

53 entries across 53 versions & 3 rubygems

Version Path
cloudstack_client-0.9.7 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.9.6 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.9.5 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.9.3 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.9.2 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.9.1 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.9.0 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.8.0 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.7.1 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.7.0 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.6.4 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.6.3 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.6.2 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.6.0 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.6.1 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.5.0 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.4.4 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.4.3 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.4.2 lib/cloudstack_client/commands/port_forwarding_rule.rb
cloudstack_client-0.4.1 lib/cloudstack_client/commands/port_forwarding_rule.rb