Exemplo n.º 1
0
 def create(self, req, body, tenant_id, instance_id):
     """Creates a set of schemas"""
     LOG.info(_("Creating schema for instance '%s'") % instance_id)
     LOG.info(_("req : '%s'\n\n") % req)
     LOG.info(_("body : '%s'\n\n") % body)
     context = req.environ[wsgi.CONTEXT_KEY]
     self.validate(body)
     schemas = body['databases']
     model_schemas = populate_validated_databases(schemas)
     models.Schema.create(context, instance_id, model_schemas)
     return wsgi.Result(None, 202)
Exemplo n.º 2
0
 def create(self, req, body, tenant_id, instance_id):
     """Creates a set of schemas"""
     LOG.info(_("Creating schema for instance '%s'") % instance_id)
     LOG.info(_("req : '%s'\n\n") % req)
     LOG.info(_("body : '%s'\n\n") % body)
     context = req.environ[wsgi.CONTEXT_KEY]
     self.validate(body)
     schemas = body['databases']
     model_schemas = populate_validated_databases(schemas)
     models.Schema.create(context, instance_id, model_schemas)
     return wsgi.Result(None, 202)
Exemplo n.º 3
0
    def create(self, req, body, tenant_id):
        # TODO(hub-cap): turn this into middleware
        LOG.info(_("Creating a database instance for tenant '%s'") % tenant_id)
        LOG.info(_("req : '%s'\n\n") % req)
        LOG.info(_("body : '%s'\n\n") % body)
        context = req.environ[wsgi.CONTEXT_KEY]
        # Set the service type to mysql if its not in the request
        service_type = (body['instance'].get('service_type') or
                        CONF.service_type)
        service = models.ServiceImage.find_by(service_name=service_type)
        image_id = service['image_id']
        name = body['instance']['name']
        flavor_ref = body['instance']['flavorRef']
        flavor_id = utils.get_id_from_href(flavor_ref)
        databases = populate_validated_databases(
            body['instance'].get('databases', []))
        users = None
        try:
            users = populate_users(body['instance'].get('users', []))
        except ValueError as ve:
            raise exception.BadRequest(msg=ve)
        if 'volume' in body['instance']:
            try:
                volume_size = int(body['instance']['volume']['size'])
            except ValueError as e:
                raise exception.BadValue(msg=e)
        else:
            volume_size = None

        if 'restorePoint' in body['instance']:
            backupRef = body['instance']['restorePoint']['backupRef']
            backup_id = utils.get_id_from_href(backupRef)

        else:
            backup_id = None

        instance = models.Instance.create(context, name, flavor_id,
                                          image_id, databases, users,
                                          service_type, volume_size,
                                          backup_id)

        view = views.InstanceDetailView(instance, req=req)
        return wsgi.Result(view.data(), 200)
Exemplo n.º 4
0
    def create(self, req, body, tenant_id):
        # TODO(hub-cap): turn this into middleware
        LOG.info(_("Creating a database instance for tenant '%s'") % tenant_id)
        LOG.info(_("req : '%s'\n\n") % req)
        LOG.info(_("body : '%s'\n\n") % body)
        context = req.environ[wsgi.CONTEXT_KEY]
        # Set the service type to mysql if its not in the request
        service_type = (body['instance'].get('service_type')
                        or CONF.service_type)
        service = models.ServiceImage.find_by(service_name=service_type)
        image_id = service['image_id']
        name = body['instance']['name']
        flavor_ref = body['instance']['flavorRef']
        flavor_id = utils.get_id_from_href(flavor_ref)
        databases = populate_validated_databases(body['instance'].get(
            'databases', []))
        users = None
        try:
            users = populate_users(body['instance'].get('users', []))
        except ValueError as ve:
            raise exception.BadRequest(msg=ve)
        if 'volume' in body['instance']:
            try:
                volume_size = int(body['instance']['volume']['size'])
            except ValueError as e:
                raise exception.BadValue(msg=e)
        else:
            volume_size = None

        if 'restorePoint' in body['instance']:
            backupRef = body['instance']['restorePoint']['backupRef']
            backup_id = utils.get_id_from_href(backupRef)

        else:
            backup_id = None

        instance = models.Instance.create(context, name, flavor_id, image_id,
                                          databases, users, service_type,
                                          volume_size, backup_id)

        view = views.InstanceDetailView(instance, req=req)
        return wsgi.Result(view.data(), 200)