@@ -110,13 +110,13 @@ def add_securitygroup_rules(self, group_id, rules):
110110 raise TypeError ("The rules provided must be a list of dictionaries" )
111111 return self .security_group .addRules (rules , id = group_id )
112112
113- def add_subnet (self , subnet_type , quantity = None , vlan_id = None , version = 4 ,
113+ def add_subnet (self , subnet_type , quantity = None , endpoint_id = None , version = 4 ,
114114 test_order = False ):
115115 """Orders a new subnet
116116
117- :param str subnet_type: Type of subnet to add: private, public, global
117+ :param str subnet_type: Type of subnet to add: private, public, global,static
118118 :param int quantity: Number of IPs in the subnet
119- :param int vlan_id: VLAN id for the subnet to be placed into
119+ :param int endpoint_id: id for the subnet to be placed into
120120 :param int version: 4 for IPv4, 6 for IPv6
121121 :param bool test_order: If true, this will only verify the order.
122122 """
@@ -126,9 +126,11 @@ def add_subnet(self, subnet_type, quantity=None, vlan_id=None, version=4,
126126 if version == 4 :
127127 if subnet_type == 'global' :
128128 quantity = 0
129- category = ' global_ipv4'
129+ category = " global_ipv4"
130130 elif subnet_type == 'public' :
131- category = 'sov_sec_ip_addresses_pub'
131+ category = "sov_sec_ip_addresses_pub"
132+ elif subnet_type == 'static' :
133+ category = "static_sec_ip_addresses"
132134 else :
133135 category = 'static_ipv6_addresses'
134136 if subnet_type == 'global' :
@@ -137,15 +139,24 @@ def add_subnet(self, subnet_type, quantity=None, vlan_id=None, version=4,
137139 desc = 'Global'
138140 elif subnet_type == 'public' :
139141 desc = 'Portable'
142+ elif subnet_type == 'static' :
143+ desc = 'Static'
140144
141145 # In the API, every non-server item is contained within package ID 0.
142146 # This means that we need to get all of the items and loop through them
143147 # looking for the items we need based upon the category, quantity, and
144148 # item description.
145149 price_id = None
146150 quantity_str = str (quantity )
147- for item in package .getItems (id = 0 , mask = 'itemCategory' ):
151+ # package_items = package.getItems(id=0, mask='itemCategory')
152+ package_items = package .getItems (id = 0 )
153+ for item in package_items :
148154 category_code = utils .lookup (item , 'itemCategory' , 'categoryCode' )
155+ # if (category_code == category
156+ # and item.get('capacity') == quantity_str
157+ # and (version == 4 or (version == 6 and desc in item['description']))):
158+ # price_id = item['prices'][0]['id']
159+ # break
149160 if all ([category_code == category ,
150161 item .get ('capacity' ) == quantity_str ,
151162 version == 4 or (version == 6 and
@@ -161,9 +172,10 @@ def add_subnet(self, subnet_type, quantity=None, vlan_id=None, version=4,
161172 # correct order container
162173 'complexType' : 'SoftLayer_Container_Product_Order_Network_Subnet' ,
163174 }
164-
165- if subnet_type != 'global' :
166- order ['endPointVlanId' ] = vlan_id
175+ if subnet_type == 'static' :
176+ order ['endPointIpAddressId' ] = endpoint_id
177+ elif subnet_type != 'global' and subnet_type != 'static' :
178+ order ['endPointVlanId' ] = endpoint_id
167179
168180 if test_order :
169181 return self .client ['Product_Order' ].verifyOrder (order )
0 commit comments