

def undo(self, workflow_dict):
    LOG.info('Running undo...')
    try:
        if ('databaseinfra' not in workflow_dict):
            LOG.info('We could not find a databaseinfra inside the workflow_dict')
            return False
        source_secondary_ip_ids = [secondary_ip.id for secondary_ip in workflow_dict['source_secondary_ips']]
        databaseinfraattr = DatabaseInfraAttr.objects.filter(databaseinfra=workflow_dict['databaseinfra'], equivalent_dbinfraattr=None).exclude(id__in=source_secondary_ip_ids)
        LOG.info('databaseinfraattr: {}'.format(databaseinfraattr))
        LOG.info('old infra ip: {}'.format(workflow_dict['source_secondary_ips']))
        cs_credentials = get_credentials_for(environment=workflow_dict['target_environment'], credential_type=CredentialType.CLOUDSTACK)
        networkapi_credentials = get_credentials_for(environment=self['target_environment'], credential_type=CredentialType.NETWORKAPI)
        cs_provider = CloudStackProvider(credentials=cs_credentials, networkapi_credentials=networkapi_credentials)
        for infra_attr in databaseinfraattr:
            networkapi_equipment_id = infra_attr.networkapi_equipment_id
            networkapi_ip_id = infra_attr.networkapi_ip_id
            if networkapi_ip_id:
                LOG.info(('Removing network api IP for %s' % networkapi_ip_id))
                if (not cs_provider.remove_networkapi_ip(equipment_id=networkapi_equipment_id, ip_id=networkapi_ip_id)):
                    return False
            LOG.info(('Removing secondary_ip for %s' % infra_attr.cs_ip_id))
            if (not cs_provider.remove_secondary_ips(infra_attr.cs_ip_id)):
                return False
            LOG.info('Secondary ip deleted!')
            infra_attr.delete()
            LOG.info('Databaseinfraattr deleted!')
        return True
    except Exception:
        traceback = full_stack()
        workflow_dict['exceptions']['error_codes'].append(DBAAS_0010)
        workflow_dict['exceptions']['traceback'].append(traceback)
        return False

dataset/ETHPy150Open globocom/database-as-a-service/dbaas/workflow/steps/mysql/region_migration/create_secondary_ip.py CreateSecondaryIp.undo/VarMisuse@137/286 `workflow_dict`->`self`