def _get_private_region_flavors(self, region):
     token = session['token_keystone']
     infrastructure = self.database_manager.get_infrastructure(region)
     openstack_manager = OpenStackManager(region, token)
     openstack_flavors = openstack_manager.get_flavors()
     #TODO review how to manage the infrastructure to be aligned with the data base definition.
     return FlavorCollection.from_openstack_flavor_list(openstack_flavors, infrastructure)
def from_empty_openstack_flavor_list_test():
    mordor = util.create_example_infrastructure()
    
    flavor_collection = FlavorCollection([])
    
    converted_collection = FlavorCollection.from_openstack_flavor_list(
                                                    [], mordor)
    
    assert util.json_are_equal(
                flavor_collection.to_dict(), converted_collection.to_dict())
def from_openstack_flavor_list_test():
    data = util.load_json_from_file('flavor_collection_response.json')
    
    for flavor in data['flavors']:
        del(flavor['nodes'])
    
    openstackflavors = [OpenStackFlavor(None, data['flavors'][0]),
                        OpenStackFlavor(None, data['flavors'][1])]
    
    mordor = util.create_example_infrastructure()
    
    flavor_collection = util.create_example_flavor_collection(mordor)
    for flavor in flavor_collection.flavors:
        flavor.public = False
    
    converted_collection = FlavorCollection.from_openstack_flavor_list(
                                                    openstackflavors, mordor)
    
    assert util.json_are_equal(
                flavor_collection.to_dict(), converted_collection.to_dict())
 def _get_private_flavors(self):
     infrastructure = self.database_manager.get_infrastructure('Mordor')
     openstack_manager = OpenStackManager(infrastructure)
     openstack_flavors = openstack_manager.get_flavors()
     return FlavorCollection.from_openstack_flavor_list(openstack_flavors, infrastructure)