示例#1
0
        def _get_and_extend_all(context, body):
            # TODO(mdietz): This is a brilliant argument for this to *not*
            # be an extension. The problem is we either have to 1) duplicate
            # the logic from the servers controller or 2) do what we did
            # and iterate over the list of potentially sorted, limited
            # and whatever else elements and find each individual.
            compute_api = compute.API()

            for server in list(body['servers']):
                try:
                    inst_ref = compute_api.routing_get(context, server['id'])
                except exception.NotFound:
                    # NOTE(dtroyer): A NotFound exception at this point
                    # happens because a delete was in progress and the
                    # server that was present in the original call to
                    # compute.api.get_all() is no longer present.
                    # Delete it from the response and move on.
                    LOG.warn("Instance %s not found (all)" % server['id'])
                    body['servers'].remove(server)
                    continue

                #TODO(bcwaldon): these attributes should be prefixed with
                # something specific to this extension
                for state in ['task_state', 'vm_state', 'power_state']:
                    key = "%s:%s" % (Extended_status.alias, state)
                    server[key] = inst_ref[state]
示例#2
0
 def test_no_injected_files(self):
     self.flags(image_service='engine.image.fake.FakeImageService')
     api = compute.API(image_service=self.StubImageService())
     inst_type = instance_types.get_instance_type_by_name('m1.small')
     image_uuid = 'cedef40a-ed67-4d10-800e-17455edce175'
     api.create(self.context,
                instance_type=inst_type,
                image_href=image_uuid)
示例#3
0
    def __init__(self, ext_mgr):
        """Initialize the extension.

        Gets a compute.API object so we can call the back-end
        add_fixed_ip() and remove_fixed_ip() methods.
        """

        super(Multinic, self).__init__(ext_mgr)
        self.compute_api = compute.API()
示例#4
0
    def index(self, req, server_id):
        context = req.environ["engine.context"]
        compute_api = compute.API()
        try:
            instance = compute_api.get(context, id)
        except exception.NotFound():
            raise webob.exc.HTTPNotFound(_("Instance not found"))

        return compute_api.get_diagnostics(context, instance)
示例#5
0
        def _get_and_extend_one(context, server_id, body):
            compute_api = compute.API()
            try:
                inst_ref = compute_api.routing_get(context, server_id)
            except exception.NotFound:
                LOG.warn("Instance %s not found (one)" % server_id)
                explanation = _("Server not found.")
                raise exc.HTTPNotFound(explanation=explanation)

            for state in ['task_state', 'vm_state', 'power_state']:
                key = "%s:%s" % (Extended_status.alias, state)
                body['server'][key] = inst_ref[state]
示例#6
0
 def test_too_many_metadata_items(self):
     metadata = {}
     for i in range(FLAGS.quota_metadata_items + 1):
         metadata['key%s' % i] = 'value%s' % i
     inst_type = instance_types.get_instance_type_by_name('m1.small')
     image_uuid = 'cedef40a-ed67-4d10-800e-17455edce175'
     self.assertRaises(exception.QuotaError,
                       compute.API().create,
                       self.context,
                       min_count=1,
                       max_count=1,
                       instance_type=inst_type,
                       image_href=image_uuid,
                       metadata=metadata)
示例#7
0
    def __init__(self, vsa_driver=None, *args, **kwargs):
        if not vsa_driver:
            vsa_driver = FLAGS.vsa_driver
        self.driver = utils.import_object(vsa_driver)
        self.compute_manager = utils.import_object(FLAGS.compute_manager)

        self.compute_api = compute.API()
        self.volume_api = volume.API()
        self.vsa_api = vsa.API()

        if FLAGS.vsa_ec2_user_id is None or \
           FLAGS.vsa_ec2_access_key is None:
            raise exception.VSAEngineAccessParamNotFound()

        super(VsaManager, self).__init__(*args, **kwargs)
示例#8
0
 def test_too_many_cores(self):
     instance_ids = []
     instance_id = self._create_instance(cores=4)
     instance_ids.append(instance_id)
     inst_type = instance_types.get_instance_type_by_name('m1.small')
     image_uuid = 'cedef40a-ed67-4d10-800e-17455edce175'
     self.assertRaises(exception.QuotaError,
                       compute.API().create,
                       self.context,
                       min_count=1,
                       max_count=1,
                       instance_type=inst_type,
                       image_href=image_uuid)
     for instance_id in instance_ids:
         db.instance_destroy(self.context, instance_id)
示例#9
0
    def create(self, req, body):
        context = req.environ['engine.context']
        instance_id = body['snapshot'].get('instance_id')
        name = body['snapshot'].get('name')

        compute_api = compute.API()
        meta = compute_api.snapshot(context, instance_id, name)

        return {
            'snapshot': {
                'id': '',
                'instance_id': instance_id,
                'meta': meta,
                'name': name
            }
        }
示例#10
0
 def create(self, req, body):
     context = req.environ['engine.context']
     console_type = body['console'].get('type')
     server_id = body['console'].get('server_id')
     compute_api = compute.API()
     if console_type == 'text':
         output = compute_api.get_console_output(context,
                                                 instance=compute_api.get(
                                                     context, server_id))
     elif console_type == 'vnc':
         output = compute_api.get_vnc_console(context,
                                              instance=compute_api.get(
                                                  context,
                                                  server_id))['url']
     else:
         raise Exception("Not Implemented")
     return {'console': {'id': '', 'type': console_type, 'output': output}}
示例#11
0
    def index(self, req, server_id):
        context = req.environ["engine.context"]
        compute_api = compute.API()

        try:
            instance = compute_api.get(context, server_id)
        except exception.NotFound:
            raise webob.exc.HTTPNotFound(_("Instance not found"))

        items = compute_api.get_actions(context, instance)

        def _format_item(item):
            return {
                'created_at': str(item['created_at']),
                'action': item['action'],
                'error': item['error'],
            }

        return {'actions': [_format_item(item) for item in items]}
示例#12
0
 def __init__(self):
     self.compute_api = compute.API(network_api=network.API(),
                                    volume_api=volume.API())
示例#13
0
 def __init__(self, ext_mgr):
     super(Admin_actions, self).__init__(ext_mgr)
     self.compute_api = compute.API()
示例#14
0
 def __init__(self):
     self.compute_api = compute.API()
     self.auth_manager = manager.AuthManager()
     self.cloudpipe = pipelib.CloudPipe()
     self.setup()
 def __init__(self):
     self.vsa_api = vsa.API()
     self.compute_api = compute.API()
     self.vsa_id = None  # VP-TODO: temporary ugly hack
     super(VsaVCController, self).__init__()
 def __init__(self):
     self.vsa_api = vsa.API()
     self.compute_api = compute.API()
     self.network_api = network.API()
     super(VsaController, self).__init__()
示例#17
0
 def __init__(self, ext_mgr):
     self.compute_api = compute.API()
     super(Console_output, self).__init__(ext_mgr)
示例#18
0
文件: api.py 项目: wendy-king/x7_venv
 def __init__(self, compute_api=None, volume_api=None, **kwargs):
     self.compute_api = compute_api or compute.API()
     self.volume_api = volume_api or volume.API()
     super(API, self).__init__(**kwargs)
示例#19
0
 def __init__(self):
     self.compute_api = compute.API()
     super(SecurityGroupController, self).__init__()
示例#20
0
 def __init__(self, ext_mgr):
     self.compute_api = compute.API()
     super(Security_groups, self).__init__(ext_mgr)
示例#21
0
 def __init__(self, **kwargs):
     super(Controller, self).__init__(**kwargs)
     self.compute_api = compute.API()
     self.network_api = network.API()
示例#22
0
 def __init__(self):
     self.compute_api = compute.API()
     super(HostController, self).__init__()
示例#23
0
 def __init__(self):
     self.compute_api = compute.API()
     self.volume_api = volume.API()
     super(VolumeAttachmentController, self).__init__()
示例#24
0
 def __init__(self):
     self.compute_api = compute.API()
示例#25
0
 def __init__(self, ext_mgr):
     super(Disk_config, self).__init__(ext_mgr)
     self.compute_api = compute.API()
示例#26
0
 def __init__(self, ext_mgr):
     self.compute_api = compute.API()
     self.network_api = network.API()
     super(Floating_ips, self).__init__(ext_mgr)
示例#27
0
 def __init__(self, ext_mgr):
     super(Deferred_delete, self).__init__(ext_mgr)
     self.compute_api = compute.API()
示例#28
0
 def __init__(self, ext_mgr):
     super(Rescue, self).__init__(ext_mgr)
     self.compute_api = compute.API()