@@ -53,34 +53,49 @@ def get_object(self, identifier, mask=None):
5353
5454 def get_create_options (self ):
5555 mask = "mask[attributes,prices[pricingLocationGroup]]"
56- # mask = "mask[id, description, capacity, units]"
5756 results = self .ordering_manager .list_items (self .capacity_package , mask = mask )
5857 return results
5958
60- def get_available_routers (self ):
61- """Pulls down all backendRouterIds that are available"""
59+ def get_available_routers (self , dc = None ):
60+ """Pulls down all backendRouterIds that are available
61+
62+ :param string dc: A specific location to get routers for, like 'dal13'.
63+ :returns list: A list of locations where RESERVED_CAPACITY can be ordered.
64+ """
6265 mask = "mask[locations]"
6366 # Step 1, get the package id
6467 package = self .ordering_manager .get_package_by_key (self .capacity_package , mask = "id" )
6568
6669 # Step 2, get the regions this package is orderable in
67- regions = self .client .call ('Product_Package' , 'getRegions' , id = package ['id' ], mask = mask )
68- _filter = { 'datacenterName' : { 'operation' : '' }}
70+ regions = self .client .call ('Product_Package' , 'getRegions' , id = package ['id' ], mask = mask , iter = True )
71+ _filter = None
6972 routers = {}
73+ if dc is not None :
74+ _filter = {'datacenterName' : {'operation' : dc }}
7075
7176 # Step 3, for each location in each region, get the pod details, which contains the router id
77+ pods = self .client .call ('Network_Pod' , 'getAllObjects' , filter = _filter , iter = True )
7278 for region in regions :
7379 routers [region ['keyname' ]] = []
7480 for location in region ['locations' ]:
7581 location ['location' ]['pods' ] = list ()
76- _filter ['datacenterName' ]['operation' ] = location ['location' ]['name' ]
77- location ['location' ]['pods' ] = self .client .call ('Network_Pod' , 'getAllObjects' , filter = _filter )
82+ for pod in pods :
83+ if pod ['datacenterName' ] == location ['location' ]['name' ]:
84+ location ['location' ]['pods' ].append (pod )
7885
7986 # Step 4, return the data.
8087 return regions
8188
8289 def create (self , name , datacenter , backend_router_id , capacity , quantity , test = False ):
83- """Orders a Virtual_ReservedCapacityGroup"""
90+ """Orders a Virtual_ReservedCapacityGroup
91+
92+ :params string name: Name for the new reserved capacity
93+ :params string datacenter: like 'dal13'
94+ :params int backend_router_id: This selects the pod. See create_options for a list
95+ :params string capacity: Capacity KeyName, see create_options for a list
96+ :params int quantity: Number of guest this capacity can support
97+ :params bool test: If True, don't actually order, just test.
98+ """
8499 args = (self .capacity_package , datacenter , [capacity ])
85100 extras = {"backendRouterId" : backend_router_id , "name" : name }
86101 kwargs = {
@@ -96,6 +111,18 @@ def create(self, name, datacenter, backend_router_id, capacity, quantity, test=F
96111 return receipt
97112
98113 def create_guest (self , capacity_id , test , guest_object ):
114+ """Turns an empty Reserve Capacity into a real Virtual Guest
115+
116+ :params int capacity_id: ID of the RESERVED_CAPACITY_GROUP to create this guest into
117+ :params bool test: True will use verifyOrder, False will use placeOrder
118+ :params dictionary guest_object: Below is the minimum info you need to send in
119+ guest_object = {
120+ 'domain': 'test.com',
121+ 'hostname': 'A1538172419',
122+ 'os_code': 'UBUNTU_LATEST_64',
123+ 'primary_disk': '25',
124+ }
125+ """
99126 vs_manager = VSManager (self .client )
100127 mask = "mask[instances[id, billingItem[id, item[id,keyName]]], backendRouter[id, datacenter[name]]]"
101128 capacity = self .get_object (capacity_id )
0 commit comments