Esempio n. 1
0
    def create_service_profile(self, context, service_profile):
        sp = service_profile['service_profile']

        if sp['driver']:
            self._validate_driver(context, sp['driver'])
        else:
            if not sp['metainfo']:
                raise ext_flavors.ServiceProfileEmpty()

        obj = obj_flavor.ServiceProfile(
            context, description=sp['description'], driver=sp['driver'],
            enabled=sp['enabled'], metainfo=sp['metainfo'])
        obj.create()
        return self._make_service_profile_dict(obj)
Esempio n. 2
0
    def create_service_profile(self, context, service_profile):
        sp = service_profile['service_profile']

        if sp['driver']:
            self._validate_driver(context, sp['driver'])
        else:
            if not sp['metainfo']:
                raise ext_flavors.ServiceProfileEmpty()

        with db_api.context_manager.writer.using(context):
            sp_db = flavor_models.ServiceProfile(id=uuidutils.generate_uuid(),
                                                 description=sp['description'],
                                                 driver=sp['driver'],
                                                 enabled=sp['enabled'],
                                                 metainfo=sp['metainfo'])
            context.session.add(sp_db)
            return self._make_service_profile_dict(sp_db)
Esempio n. 3
0
    def create_service_profile(self, context, service_profile):
        sp = service_profile['service_profile']

        if sp['driver']:
            self._validate_driver(context, sp['driver'])
        else:
            if not sp['metainfo']:
                raise ext_flavors.ServiceProfileEmpty()

        with context.session.begin(subtransactions=True):
            sp_db = ServiceProfile(id=uuidutils.generate_uuid(),
                                   description=sp['description'],
                                   driver=sp['driver'],
                                   enabled=sp['enabled'],
                                   metainfo=sp['metainfo'])
            context.session.add(sp_db)

        return self._make_service_profile_dict(sp_db)