Example #1
0
    def create_instance_db_entry(self, context, request_spec):
        """Create instance DB entry based on request_spec"""
        base_options = request_spec['instance_properties']
        if base_options.get('uuid'):
            # Instance was already created before calling scheduler
            return db.instance_get_by_uuid(context, base_options['uuid'])
        image = request_spec['image']
        instance_type = request_spec.get('instance_type')
        security_group = request_spec.get('security_group', 'default')
        block_device_mapping = request_spec.get('block_device_mapping', [])

        instance = self.compute_api.create_db_entry_for_new_instance(
            context, instance_type, image, base_options, security_group,
            block_device_mapping)
        # NOTE(comstud): This needs to be set for the generic exception
        # checking in scheduler manager, so that it'll set this instance
        # to ERROR properly.
        base_options['uuid'] = instance['uuid']
        return instance
Example #2
0
    def create_instance_db_entry(self, context, request_spec):
        """Create instance DB entry based on request_spec"""
        base_options = request_spec['instance_properties']
        if base_options.get('uuid'):
            # Instance was already created before calling scheduler
            return db.instance_get_by_uuid(context, base_options['uuid'])
        image = request_spec['image']
        instance_type = request_spec.get('instance_type')
        security_group = request_spec.get('security_group', 'default')
        block_device_mapping = request_spec.get('block_device_mapping', [])

        instance = self.compute_api.create_db_entry_for_new_instance(
                context, instance_type, image, base_options,
                security_group, block_device_mapping)
        # NOTE(comstud): This needs to be set for the generic exception
        # checking in scheduler manager, so that it'll set this instance
        # to ERROR properly.
        base_options['uuid'] = instance['uuid']
        return instance
Example #3
0
        def wrapped_f(*args, **kwargs):
            collection, context, item_id_or_uuid = self.get_collection_context_and_id(args, kwargs)

            attempt_reroute = False
            if utils.is_uuid_like(item_id_or_uuid):
                item_uuid = item_id_or_uuid
                try:
                    instance = db.instance_get_by_uuid(context, item_uuid)
                except exception.InstanceNotFound, e:
                    # NOTE(sirp): since a UUID was passed in, we can attempt
                    # to reroute to a child zone
                    attempt_reroute = True
                    LOG.debug(_("Instance %(item_uuid)s not found " "locally: '%(e)s'" % locals()))
                else:
                    # NOTE(sirp): since we're not re-routing in this case, and
                    # we we were passed a UUID, we need to replace that UUID
                    # with an integer ID in the argument list so that the
                    # zone-local code can continue to use integer IDs.
                    item_id = instance["id"]
                    args = list(args)  # needs to be mutable to replace
                    self.replace_uuid_with_id(args, kwargs, item_id)
Example #4
0
        def wrapped_f(*args, **kwargs):
            collection, context, item_id_or_uuid = \
                            self.get_collection_context_and_id(args, kwargs)

            attempt_reroute = False
            if utils.is_uuid_like(item_id_or_uuid):
                item_uuid = item_id_or_uuid
                try:
                    instance = db.instance_get_by_uuid(context, item_uuid)
                except exception.InstanceNotFound, e:
                    # NOTE(sirp): since a UUID was passed in, we can attempt
                    # to reroute to a child zone
                    attempt_reroute = True
                    LOG.debug(
                        _("Instance %(item_uuid)s not found "
                          "locally: '%(e)s'" % locals()))
                else:
                    # NOTE(sirp): since we're not re-routing in this case, and
                    # we we were passed a UUID, we need to replace that UUID
                    # with an integer ID in the argument list so that the
                    # zone-local code can continue to use integer IDs.
                    item_id = instance['id']
                    args = list(args)  # needs to be mutable to replace
                    self.replace_uuid_with_id(args, kwargs, item_id)