Sha256: c34dbf03f1a32a5d50f79d21f22d3b4f85dcdfb8cc8a08da225d5e52625f0f43

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 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)
      params = {
          'command' => 'createPortForwardingRule',
          'ipAddressId' => ip_address_id,
          'privatePort' => private_port,
          'protocol' => protocol,
          'publicPort' => public_port,
          'virtualMachineId' => virtual_machine_id
      }
      json = send_async_request(params)
      json['portforwardingrule']
    end

	end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cloudstack-cli-0.3.4 lib/cloudstack-client/commands/port_forwarding_rule.rb
cloudstack-cli-0.3.3 lib/cloudstack-client/commands/port_forwarding_rule.rb
cloudstack-cli-0.3.2 lib/cloudstack-client/commands/port_forwarding_rule.rb
cloudstack-cli-0.3.1 lib/cloudstack-client/commands/port_forwarding_rule.rb
cloudstack-cli-0.2.2 lib/cloudstack-client/commands/port_forwarding_rule.rb
cloudstack-cli-0.2.1 lib/cloudstack-client/commands/port_forwarding_rule.rb
cloudstack-cli-0.2.0 lib/cloudstack-client/commands/port_forwarding_rule.rb