Sha256: cfe71a22f796c58875502570aa737fb4ab0759ffcb922c7ee5ff8b661d95c9c3

Contents?: true

Size: 1.9 KB

Versions: 7

Compression:

Stored size: 1.9 KB

Contents

module CloudControl::API
  class Network < Core
    def list
      org_endpoint '/network'
      get
    end

    def create(name, description="", datacenter=@client.datacenter)
      org_endpoint "/networkWithLocation"
      xml_params(schema: "network", tag: "NewNetworkWithLocation", name: name, description: description, location: datacenter)
      post
    end

    def list_with_location
      org_endpoint "/networkWithLocation"
      get
    end

    def list_in_location(location_id)
      org_endpoint "/networkWithLocation/#{location_id}"
      get
    end

    def show(network_id)
      list_with_location.find {|n| n.id == network_id}
    end

    def show_by_name(name)
     list_with_location.find {|n| n.name == name}
    end

    def natrule_list(network_id)
      org_endpoint "/network/#{network_id}/natrule"
      get
    end

    # name = "10.147.15.11", source_ip = "10.147.15.11"
    def natrule_create(network_id, name, source_ip)
      org_endpoint "/network/#{network_id}/natrule"
      xml_params(schema: "network", tag: "NatRule", name: name, source_ip: source_ip)
      post
    end

    def natrule_delete(network_id, natrule_id)
      org_endpoint "/network/#{network_id}/natrule/#{natrule_id}?delete"
      get
    end

    def aclrule_list(network_id)
      org_endpoint "/network/#{network_id}/aclrule"
      get
    end

    def aclrule_delete(network_id, aclrule_id)
      org_endpoint "/network/#{network_id}/aclrule/#{aclrule_id}?delete"
      get
    end

    def aclrule_create(network_id, name, position, inbound, protocol, port, allow)
      org_endpoint "/network/#{network_id}/aclrule"
      xml_params(schema: "network", tag: "AclRule", name: name, position: position, action: (allow ? "PERMIT" : "DENY"), protocol: protocol, source_ip_range: {}, destination_ip_range: {}, port_range: {type: "EQUAL_TO", port1: port}, type: (inbound ? "OUTSIDE_ACL" : "INSIDE_ACL"))
      post
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cloudcontrol_sdk-0.3.11 lib/cloudcontrol/api/network.rb
cloudcontrol_sdk-0.3.10 lib/cloudcontrol/api/network.rb
cloudcontrol_sdk-0.3.9 lib/cloudcontrol/api/network.rb
cloudcontrol_sdk-0.3.8 lib/cloudcontrol/api/network.rb
cloudcontrol_sdk-0.3.7 lib/cloudcontrol/api/network.rb
cloudcontrol_sdk-0.3.6 lib/cloudcontrol/api/network.rb
cloudcontrol_sdk-0.3.5 lib/cloudcontrol/api/network.rb