clc.APIv2.public_ip
index
/Users//clc_git/src/clc/APIv2/public_ip.py

PublicIP related functions.  
 
PublicIPs object variables:
 
        public_ips.public_ips - list of PublicIP objects
 
PublicIP object variables:
 
        public_ip.id - alias of public
        public_ip.public
        public_ip.internal
        public_ip.ports - list of port/protocol dicts
 
Port object variables:
 
        port.protocol
        port.port
        port.port_to
 
Source Restriction object variables:
 
        source_restriction.cidr

 
Modules
       
clc
json
re
time

 
Classes
       
__builtin__.object
Port
PublicIP
PublicIPs
SourceRestriction

 
class Port(__builtin__.object)
     Methods defined here:
Delete(self)
Delete this port and commit change to cloud.
 
>>> clc.v2.Server("WA1BTDIX01").PublicIPs().public_ips[0].ports[0].Delete().WaitUntilComplete()
0
ToDict(self)
__init__(self, public_ip, protocol, port, port_to=None)
__str__(self)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class PublicIP(__builtin__.object)
     Methods defined here:
AddPort(self, protocol, port, port_to=None)
Add and commit a single port.
 
# Add single port
>>> clc.v2.Server("WA1BTDIX01").PublicIPs().public_ips[0].AddPort(protocol='TCP',port='22').WaitUntilComplete()
0
 
# Add port range 
>>> clc.v2.Server("WA1BTDIX01").PublicIPs().public_ips[0].AddPort(protocol='UDP',port='10000',port_to='15000').WaitUntilComplete()
0
AddPorts(self, ports)
Create one or more port access policies.
 
Include a list of dicts with protocol, port, and port_to (optional - for range) keys.
 
>>> clc.v2.Server("WA1BTDIX01").PublicIPs().public_ips[0]
                .AddPorts([{'protocol': 'TCP', 'port': '80' },
                           {'protocol': 'UDP', 'port': '10000', 'port_to': '15000'}]).WaitUntilComplete()
0
AddSourceRestriction(self, cidr)
Add and commit a single source IP restriction policy.
 
>>> clc.v2.Server("WA1BTDIX01").PublicIPs().public_ips[0]
                .AddSourceRestriction(cidr="132.200.20.1/32").WaitUntilComplete()
0
AddSourceRestrictions(self, cidrs)
Create one or more CIDR source restriction policies.
 
Include a list of CIDR strings.
 
>>> clc.v2.Server("WA1BTDIX01").PublicIPs().public_ips[0]
                .AddSourceRestrictions(cidrs=["132.200.20.1/32","132.200.20.100/32"]).WaitUntilComplete()
0
Delete(self)
Delete public IP.  
 
>>> clc.v2.Server("WA1BTDIX01").PublicIPs().public_ips[0].Delete().WaitUntilComplete()
0
Update(self)
Commit  current PublicIP definition to cloud.
 
Usually called by the class to commit changes to port and source restriction policies.
 
>>> clc.v2.Server("WA1BTDIX01").PublicIPs().public_ips[0].Update().WaitUntilComplete()
0
__getattr__(self, var)
__init__(self, id, parent, public_ip_obj=None)
Create PublicIP object.
__str__(self)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class PublicIPs(__builtin__.object)
     Methods defined here:
Add(self, ports, source_restrictions=None, private_ip=None)
Add new public_ip.
 
Specify one or more ports using a list of dicts with the following keys:
 
        protocol - TCP, UDP, or ICMP
        port - int 0-65534
        port_to - (optional) if specifying a range of ports then the rqange end.  int 0-65534
 
Optionally specify one or more source restrictions using a list of dicts with the following keys:
 
        cidr - string with CIDR notation for the subnet (e.g. "132.200.20.0/24")
 
private_ip is the existing private IP address to NAT to (optional)
 
# New public IP with single port
>>> p = clc.v2.Server(alias='BTDI',id='WA1BTDIX03').PublicIPs()
>>> p.Add(ports=[{"protocol": "TCP","port":5}]).WaitUntilComplete()
0
 
# New public IP with port range
>>> p.Add([{"protocol": "UDP","port":10,"port_to":50}]).WaitUntilComplete()
0
 
# Map existing private IP to single port
>>> p.Add(ports=[{"protocol": "TCP","port":22}],k
          source_restrictions=[{'cidr': "132.200.20.0/24"}],
                  private_ip="10.80.148.13").WaitUntilComplete()
0
 
* Note this API is subject to revision to make ports and source restrictions access to parallel
  that used for accessors.
 
* public_ips.public_ips will not be updated to reflect this addition. Recreate object after request completes
  to access new info including getting the IP itself
Get(self, key)
Get public_ip by providing either the public or the internal IP address.
__init__(self, server, public_ips_lst)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class SourceRestriction(__builtin__.object)
     Methods defined here:
Delete(self)
Delete this source restriction and commit change to cloud.
 
>>> clc.v2.Server("WA1BTDIX01").PublicIPs().public_ips[0].source_restrictions[0].Delete().WaitUntilComplete()
0
ToDict(self)
__init__(self, public_ip, cidr)
__str__(self)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)