def __init__(self): super(AssistedVolumeSnapshotsController, self).__init__() self.compute_api = compute.API()
def __init__(self, ext_mgr): self.compute_api = compute.API() self.cells_rpcapi = cells_rpcapi.CellsAPI() self.ext_mgr = ext_mgr
def __init__(self): self.compute_api = compute.API() self.cells_rpcapi = cells_rpcapi.CellsAPI()
def __init__(self): super(InstanceActionsController, self).__init__() self.compute_api = compute.API() self.action_api = compute.InstanceActionAPI()
def compute_api(self): if self._compute_api is None: self._compute_api = compute_api.API() return self._compute_api
def __init__(self): super(DeferredDeleteController, self).__init__() self.compute_api = compute.API()
def __init__(self): super(RescueController, self).__init__() self.compute_api = compute.API()
def _tenant_usages_for_period(self, context, period_start, period_stop, tenant_id=None, detailed=True): compute_api = api.API() instances = compute_api.get_active_by_window(context, period_start, period_stop, tenant_id) rval = {} flavors = {} for instance in instances: info = {} info['hours'] = self._hours_for(instance, period_start, period_stop) flavor_type = instance['instance_type_id'] if not flavors.get(flavor_type): try: it_ref = compute_api.get_instance_type( context, flavor_type) flavors[flavor_type] = it_ref except exception.InstanceTypeNotFound: # can't bill if there is no instance type continue flavor = flavors[flavor_type] info['name'] = instance['display_name'] info['memory_mb'] = flavor['memory_mb'] info['local_gb'] = flavor['root_gb'] + flavor['ephemeral_gb'] info['vcpus'] = flavor['vcpus'] info['tenant_id'] = instance['project_id'] info['flavor'] = flavor['name'] info['started_at'] = instance['launched_at'] info['ended_at'] = instance['terminated_at'] if info['ended_at']: info['state'] = 'terminated' else: info['state'] = instance['vm_state'] now = datetime.utcnow() if info['state'] == 'terminated': delta = info['ended_at'] - info['started_at'] else: delta = now - info['started_at'] info['uptime'] = delta.days * 24 * 3600 + delta.seconds if not info['tenant_id'] in rval: summary = {} summary['tenant_id'] = info['tenant_id'] if detailed: summary['server_usages'] = [] summary['total_local_gb_usage'] = 0 summary['total_vcpus_usage'] = 0 summary['total_memory_mb_usage'] = 0 summary['total_hours'] = 0 summary['start'] = period_start summary['stop'] = period_stop rval[info['tenant_id']] = summary summary = rval[info['tenant_id']] summary['total_local_gb_usage'] += info['local_gb'] * info['hours'] summary['total_vcpus_usage'] += info['vcpus'] * info['hours'] summary['total_memory_mb_usage'] += (info['memory_mb'] * info['hours']) summary['total_hours'] += info['hours'] if detailed: summary['server_usages'].append(info) return rval.values()
def __init__(self): self.zone_manager = None self.compute_api = compute_api.API()
def __init__(self): super(SecurityGroupControllerBase, self).__init__() self.compute_api = compute.API()
def __init__(self): super(ShelveController, self).__init__() self.compute_api = compute.API() self.network_api = neutron.API()
def __init__(self): super(SecurityGroupActionController, self).__init__() self.compute_api = compute.API()
def __init__(self, variables, hosts, instance_uuids, request_spec, filter_properties): self.compute_api = compute.API() [self.num_hosts, self.num_instances ] = self._get_host_instance_nums(hosts, instance_uuids, request_spec)
def __init__(self): super(ConsoleOutputController, self).__init__() self.compute_api = compute.API()
def __init__(self): super(ServerPasswordController, self).__init__() self.compute_api = compute.API()
def __init__(self): super(MigrateServerController, self).__init__() self.compute_api = compute.API() self.network_api = network.API()
def __init__(self): self.compute_api = compute.API() self.volume_api = cinder.API() super(VolumeAttachmentController, self).__init__()
def __init__(self): super(AdminActionsController, self).__init__() self.compute_api = compute.API()
def __init__(self): self.compute_api = compute.API()
def __init__(self): self.host_manager = importutils.import_object( FLAGS.scheduler_host_manager) self.compute_api = compute_api.API() self.compute_rpcapi = compute_rpcapi.ComputeAPI()
def __init__(self): super(EvacuateController, self).__init__() self.compute_api = compute.API() self.host_api = compute.HostAPI() self.network_api = neutron.API()
def __init__(self): super(ServerExternalEventsController, self).__init__() self.compute_api = compute.API()
def __init__(self): super(ServerMigrationsController, self).__init__() self.compute_api = compute.API()
def __init__(self): super(IPsController, self).__init__() self._compute_api = compute.API()
def _tenant_usages_for_period(self, context, period_start, period_stop, tenant_id=None, detailed=True): compute_api = api.API() instances = compute_api.get_active_by_window(context, period_start, period_stop, tenant_id) rval = {} flavors = {} for instance in instances: info = {} info['hours'] = self._hours_for(instance, period_start, period_stop) flavor = self._get_flavor(context, compute_api, instance, flavors) if not flavor: continue info['instance_id'] = instance['uuid'] info['name'] = instance['display_name'] info['memory_mb'] = flavor['memory_mb'] info['local_gb'] = flavor['root_gb'] + flavor['ephemeral_gb'] info['vcpus'] = flavor['vcpus'] info['tenant_id'] = instance['project_id'] info['flavor'] = flavor['name'] info['started_at'] = instance['launched_at'] info['ended_at'] = instance['terminated_at'] if info['ended_at']: info['state'] = 'terminated' else: info['state'] = instance['vm_state'] now = timeutils.utcnow() if info['state'] == 'terminated': delta = info['ended_at'] - info['started_at'] else: delta = now - info['started_at'] info['uptime'] = delta.days * 24 * 3600 + delta.seconds if info['tenant_id'] not in rval: summary = {} summary['tenant_id'] = info['tenant_id'] if detailed: summary['server_usages'] = [] summary['total_local_gb_usage'] = 0 summary['total_vcpus_usage'] = 0 summary['total_memory_mb_usage'] = 0 summary['total_hours'] = 0 summary['start'] = period_start summary['stop'] = period_stop rval[info['tenant_id']] = summary summary = rval[info['tenant_id']] summary['total_local_gb_usage'] += info['local_gb'] * info['hours'] summary['total_vcpus_usage'] += info['vcpus'] * info['hours'] summary['total_memory_mb_usage'] += (info['memory_mb'] * info['hours']) summary['total_hours'] += info['hours'] if detailed: summary['server_usages'].append(info) return rval.values()
def setUp(self): super().setUp() self.compute_api = compute_api.API() self.context = context.RequestContext('fake', 'fake')
def __init__(self): super(InterfaceAttachmentController, self).__init__() self.compute_api = compute.API() self.network_api = neutron.API()
def setUp(self): super(ComputeAPIUnitTestCase, self).setUp() self.compute_api = compute_api.API() self.is_cells = False
def __init__(self): super(SuspendServerController, self).__init__() self.compute_api = compute.API()
def __init__(self): super(FloatingIPController, self).__init__() self.compute_api = compute.API() self.network_api = neutron.API()