def __init__(self):
     super(AssistedVolumeSnapshotsController, self).__init__()
     self.compute_api = compute.API()
Esempio n. 2
0
 def __init__(self, ext_mgr):
     self.compute_api = compute.API()
     self.cells_rpcapi = cells_rpcapi.CellsAPI()
     self.ext_mgr = ext_mgr
Esempio n. 3
0
 def __init__(self):
     self.compute_api = compute.API()
     self.cells_rpcapi = cells_rpcapi.CellsAPI()
Esempio n. 4
0
 def __init__(self):
     super(InstanceActionsController, self).__init__()
     self.compute_api = compute.API()
     self.action_api = compute.InstanceActionAPI()
Esempio n. 5
0
 def compute_api(self):
     if self._compute_api is None:
         self._compute_api = compute_api.API()
     return self._compute_api
Esempio n. 6
0
 def __init__(self):
     super(DeferredDeleteController, self).__init__()
     self.compute_api = compute.API()
Esempio n. 7
0
 def __init__(self):
     super(RescueController, self).__init__()
     self.compute_api = compute.API()
Esempio n. 8
0
    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()
Esempio n. 9
0
 def __init__(self):
     self.zone_manager = None
     self.compute_api = compute_api.API()
Esempio n. 10
0
 def __init__(self):
     super(SecurityGroupControllerBase, self).__init__()
     self.compute_api = compute.API()
Esempio n. 11
0
 def __init__(self):
     super(ShelveController, self).__init__()
     self.compute_api = compute.API()
     self.network_api = neutron.API()
Esempio n. 12
0
 def __init__(self):
     super(SecurityGroupActionController, self).__init__()
     self.compute_api = compute.API()
Esempio n. 13
0
 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()
Esempio n. 16
0
 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__()
Esempio n. 18
0
 def __init__(self):
     super(AdminActionsController, self).__init__()
     self.compute_api = compute.API()
Esempio n. 19
0
 def __init__(self):
     self.compute_api = compute.API()
Esempio n. 20
0
 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()
Esempio n. 21
0
 def __init__(self):
     super(EvacuateController, self).__init__()
     self.compute_api = compute.API()
     self.host_api = compute.HostAPI()
     self.network_api = neutron.API()
Esempio n. 22
0
 def __init__(self):
     super(ServerExternalEventsController, self).__init__()
     self.compute_api = compute.API()
Esempio n. 23
0
 def __init__(self):
     super(ServerMigrationsController, self).__init__()
     self.compute_api = compute.API()
Esempio n. 24
0
 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()
Esempio n. 26
0
 def setUp(self):
     super().setUp()
     self.compute_api = compute_api.API()
     self.context = context.RequestContext('fake', 'fake')
Esempio n. 27
0
 def __init__(self):
     super(InterfaceAttachmentController, self).__init__()
     self.compute_api = compute.API()
     self.network_api = neutron.API()
Esempio n. 28
0
 def setUp(self):
     super(ComputeAPIUnitTestCase, self).setUp()
     self.compute_api = compute_api.API()
     self.is_cells = False
Esempio n. 29
0
 def __init__(self):
     super(SuspendServerController, self).__init__()
     self.compute_api = compute.API()
Esempio n. 30
0
 def __init__(self):
     super(FloatingIPController, self).__init__()
     self.compute_api = compute.API()
     self.network_api = neutron.API()