Example #1
0
 def cleanup_resource(self, res_type=None):
     change_set = mana_utils.ChangeSet()
     if res_type is None:
         res_types = ['compute', 'network', 'storage']
     else:
         res_types = [res_type]
     for res_type in res_types:
         change_set.cleanup(res_type)
     return self.change_dedicated_resource(change_set)
Example #2
0
 def add_resources(self, ress):
     change_set = mana_utils.ChangeSet()
     # a tree like this: {compute:[...], network: [...], ...}
     if isinstance(ress, dict):
         flatten = []
         for res_type, typed_ress in ress.iteritems():
             for res in typed_ress:
                 res['res_type'] = res.get('res_type') or res_type
                 flatten.append(res)
         ress = flatten
     # a flatten list
     for res in ress:
         change_set.add(res['res_type'], res['res_sub_type'], res['num'])
     return self.change_dedicated_resource(change_set)
Example #3
0
 def add_storage_resource(self, res_sub_type, num):
     change_set = mana_utils.ChangeSet()
     change_set.add('storage', res_sub_type, num)
     return self.change_dedicated_resource(change_set)
Example #4
0
 def add_network_resource(self, res_sub_type, num):
     change_set = mana_utils.ChangeSet()
     change_set.add('network', res_sub_type, num)
     return self.change_dedicated_resource(change_set)
Example #5
0
 def remove_compute_resource(self, res_sub_type, num):
     change_set = mana_utils.ChangeSet()
     change_set.remove('compute', res_sub_type, num)
     return self.change_dedicated_resource(change_set)