def undo(self, workflow_dict):
        try:
            if 'databaseinfra' not in workflow_dict:
                return False

            database = workflow_dict['databaseinfra'].databases.get()
            databaseinfra = database.databaseinfra

            acl_credential = get_credentials_for(
                environment=database.environment,
                credential_type=CredentialType.ACLAPI)
            acl_client = AclClient(
                acl_credential.endpoint, acl_credential.user,
                acl_credential.password, database.environment)

            for database_bind in database.acl_binds.all():
                infra_instances_binds = DatabaseInfraInstanceBind.objects.filter(
                    databaseinfra=databaseinfra,
                    bind_address=database_bind.bind_address)
                try:
                    helpers.unbind_address(
                        database_bind, acl_client, infra_instances_binds, True)
                except Exception as e:
                    LOG.warn(e)
                    continue

                return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0019)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
Ejemplo n.º 2
0
    def undo(self, workflow_dict):
        try:
            if 'databaseinfra' not in workflow_dict:
                return False

            database = workflow_dict['databaseinfra'].databases.get()
            databaseinfra = database.databaseinfra

            acl_credential = get_credentials_for(
                environment=database.environment,
                credential_type=CredentialType.ACLAPI)
            acl_client = AclClient(acl_credential.endpoint,
                                   acl_credential.user,
                                   acl_credential.password,
                                   database.environment)

            for database_bind in database.acl_binds.all():
                infra_instances_binds = DatabaseInfraInstanceBind.objects.filter(
                    databaseinfra=databaseinfra,
                    bind_address=database_bind.bind_address)
                try:
                    helpers.unbind_address(database_bind, acl_client,
                                           infra_instances_binds)
                except Exception as e:
                    LOG.warn(e)
                    continue

                return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0019)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
Ejemplo n.º 3
0
 def undo(self):
     for database_bind in self.database.acl_binds.all():
         infra_instances_binds = DatabaseInfraInstanceBind.objects.filter(
             databaseinfra=self.databaseinfra,
             bind_address=database_bind.bind_address,
             instance__in=self.instance_address_list,
         )
         helpers.unbind_address(
             database_bind=database_bind,
             acl_client=self.acl_client,
             infra_instances_binds=infra_instances_binds,
             delete_database_bind=False
         )
    def undo(self, workflow_dict):

        LOG.info("Running undo...")
        try:
            database = workflow_dict['database']
            databaseinfra = workflow_dict['databaseinfra']

            acl_credential = get_credentials_for(
                environment=database.environment,
                credential_type=CredentialType.ACLAPI)
            acl_client = AclClient(acl_credential.endpoint,
                                   acl_credential.user,
                                   acl_credential.password,
                                   database.environment)

            instances = databaseinfra.instances.filter(
                future_instance__isnull=True)
            databaseinfraattr_instances = DatabaseInfraAttr.objects.filter(
                databaseinfra=databaseinfra,
                equivalent_dbinfraattr__isnull=True)

            instance_address_list = []
            for instance in instances:
                instance_address_list.append(instance.address)
            for instance in databaseinfraattr_instances:
                instance_address_list.append(instance.ip)

            for database_bind in database.acl_binds.all():
                infra_instances_binds = DatabaseInfraInstanceBind.objects.filter(
                    databaseinfra=databaseinfra,
                    instance__in=instance_address_list,
                    bind_address=database_bind.bind_address)
                if helpers.unbind_address(database_bind, acl_client,
                                          infra_instances_binds):
                    continue

            return True

        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
    def undo(self, workflow_dict):

        LOG.info("Running undo...")
        try:
            database = workflow_dict['database']
            databaseinfra = workflow_dict['databaseinfra']

            acl_credential = get_credentials_for(environment=database.environment,
                                                 credential_type=CredentialType.ACLAPI)
            acl_client = AclClient(acl_credential.endpoint,
                                   acl_credential.user,
                                   acl_credential.password,
                                   database.environment)

            instances = databaseinfra.instances.filter(
                future_instance__isnull=True)
            databaseinfraattr_instances = DatabaseInfraAttr.objects.filter(databaseinfra=databaseinfra,
                                                                           equivalent_dbinfraattr__isnull=True)

            instance_address_list = []
            for instance in instances:
                instance_address_list.append(instance.address)
            for instance in databaseinfraattr_instances:
                instance_address_list.append(instance.ip)

            for database_bind in database.acl_binds.all():
                infra_instances_binds = DatabaseInfraInstanceBind.objects.filter(
                    databaseinfra=databaseinfra,
                    instance__in=instance_address_list,
                    bind_address=database_bind.bind_address)
                if helpers.unbind_address(
                    database_bind, acl_client, infra_instances_binds, False
                ):
                    continue

            return True

        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False