Exemple #1
0
    def _modify_instance(self, context, req, instance, **kwargs):
        """Modifies the instance using the specified keyword arguments
        'detach_replica': ignored if not present or False, if True,
        specifies the instance is a replica that will be detached from
        its master
        'configuration_id': Ignored if not present, if None, detaches an
        an attached configuration group, if not None, attaches the
        specified configuration group
        """

        if 'detach_replica' in kwargs and kwargs['detach_replica']:
            LOG.debug("Detaching replica from source.")
            context.notification = notification.DBaaSInstanceDetach(
                context, request=req)
            with StartNotification(context, instance_id=instance.id):
                instance.detach_replica()
        if 'configuration_id' in kwargs:
            if kwargs['configuration_id']:
                context.notification = (
                    notification.DBaaSInstanceAttachConfiguration(context,
                                                                  request=req))
                configuration_id = kwargs['configuration_id']
                with StartNotification(context, instance_id=instance.id,
                                       configuration_id=configuration_id):
                    instance.assign_configuration(configuration_id)
            else:
                context.notification = (
                    notification.DBaaSInstanceDetachConfiguration(context,
                                                                  request=req))
                with StartNotification(context, instance_id=instance.id):
                    instance.unassign_configuration()
        if kwargs:
            instance.update_db(**kwargs)
Exemple #2
0
 def _modify_instance(self, context, req, instance, **kwargs):
     if 'detach_replica' in kwargs and kwargs['detach_replica']:
         LOG.debug("Detaching replica from source.")
         context.notification = notification.DBaaSInstanceDetach(
             context, request=req)
         with StartNotification(context, instance_id=instance.id):
             instance.detach_replica()
     if 'configuration_id' in kwargs:
         if kwargs['configuration_id']:
             context.notification = (
                 notification.DBaaSInstanceAttachConfiguration(context,
                                                               request=req))
             configuration_id = kwargs['configuration_id']
             with StartNotification(context,
                                    instance_id=instance.id,
                                    configuration_id=configuration_id):
                 instance.assign_configuration(configuration_id)
         else:
             context.notification = (
                 notification.DBaaSInstanceDetachConfiguration(context,
                                                               request=req))
             with StartNotification(context, instance_id=instance.id):
                 instance.unassign_configuration()
     if 'datastore_version' in kwargs:
         datastore_version = datastore_models.DatastoreVersion.load(
             instance.datastore, kwargs['datastore_version'])
         context.notification = (notification.DBaaSInstanceUpgrade(
             context, request=req))
         with StartNotification(context,
                                instance_id=instance.id,
                                datastore_version_id=datastore_version.id):
             instance.upgrade(datastore_version)
     if kwargs:
         instance.update_db(**kwargs)
Exemple #3
0
    def _modify_instance(self, context, req, instance, **kwargs):
        if 'detach_replica' in kwargs and kwargs['detach_replica']:
            context.notification = notification.DBaaSInstanceDetach(
                context, request=req)
            with StartNotification(context, instance_id=instance.id):
                instance.detach_replica()
        elif 'configuration_id' in kwargs:
            if kwargs['configuration_id']:
                context.notification = (
                    notification.DBaaSInstanceAttachConfiguration(context,
                                                                  request=req))
                configuration_id = kwargs['configuration_id']
                with StartNotification(context,
                                       instance_id=instance.id,
                                       configuration_id=configuration_id):
                    instance.attach_configuration(configuration_id)
            else:
                context.notification = (
                    notification.DBaaSInstanceDetachConfiguration(context,
                                                                  request=req))
                with StartNotification(context, instance_id=instance.id):
                    instance.detach_configuration()
        elif 'datastore_version' in kwargs:
            datastore_version = ds_models.DatastoreVersion.load(
                instance.datastore, kwargs['datastore_version'])

            if datastore_version.name == instance.ds_version.name:
                LOG.warning(f"Same datastore version {datastore_version.name} "
                            f"for upgrading")
                return

            context.notification = (notification.DBaaSInstanceUpgrade(
                context, request=req))
            with StartNotification(context,
                                   instance_id=instance.id,
                                   datastore_version_id=datastore_version.id):
                instance.upgrade(datastore_version)
        elif 'access' in kwargs:
            instance.update_access(kwargs['access'])