def __init__(self, origin, prefix, pool): super(OpenstackClone, self).__init__(origin, prefix, pool) self.platform = origin.short_name from core.utils import openstack_utils self.nova_client = openstack_utils.nova_client() self.network_client = openstack_utils.neutron_client() self.network_id = self.get_network_id() self.network_name = self.get_network_name(self.network_id)
def __init__(self, origin): self.client = openstack_utils.nova_client() self.id = origin.id self.name = origin.name self.short_name = origin.name.split( config.OPENSTACK_PLATFORM_NAME_PREFIX)[1] self.min_disk = origin.min_disk self.min_ram = origin.min_ram try: self.flavor_id = origin.instance_type_flavorid self.flavor_name = ( lambda s: s.client.flavors.get(s.flavor_id).name)(self) except Exception: self.flavor_name = config.OPENSTACK_DEFAULT_FLAVOR
def _get_nova_client(): from core.utils import openstack_utils return openstack_utils.nova_client()
def __init__(self, origin, prefix, pool): super(OpenstackClone, self).__init__(origin, prefix, pool) self.platform = origin.short_name from core.utils import openstack_utils self.nova_client = openstack_utils.nova_client()
def images(): return openstack_utils.nova_client().glance.list()
def flavor_params(cls, flavor_name): return openstack_utils.nova_client().flavors.find( name=flavor_name).to_dict()
def limits(cls, if_none): return openstack_utils.nova_client().limits.get().to_dict().get( 'absolute', if_none)