

def do(self, workflow_dict):
    try:
        if ('target_hosts' not in workflow_dict):
            return False
        if (len(workflow_dict['target_hosts']) == 1):
            return True
        cs_credentials = get_credentials_for(environment=workflow_dict['target_environment'], credential_type=CredentialType.CLOUDSTACK)
        LOG.info('Get credential fot network api...')
        networkapi_credentials = get_credentials_for(environment=workflow_dict['target_environment'], credential_type=CredentialType.NETWORKAPI)
        cs_provider = CloudStackProvider(credentials=cs_credentials, networkapi_credentials=networkapi_credentials)
        if (not traceback):
            raise Exception('Could not create CloudStackProvider object')
            return False
        workflow_dict['target_secondary_ips'] = []
        networkapi_equipment_id = workflow_dict['source_secondary_ips'][0].networkapi_equipment_id
        if (not networkapi_equipment_id):
            raise Exception('Could not register networkapi equipment')
            return False
        for (index, host) in enumerate(workflow_dict['target_hosts']):
            LOG.info('Creating Secondary ips...')
            host_attr = HostAttr.objects.get(host=host)
            reserved_ip = cs_provider.reserve_ip(project_id=cs_credentials.project, vm_id=host_attr.vm_id)
            if (not reserved_ip):
                return False
            databaseinfraattr = DatabaseInfraAttr()
            databaseinfraattr.ip = reserved_ip['secondary_ip']
            if (index == 0):
                databaseinfraattr.is_write = True
                ip_desc = 'Write IP'
            else:
                databaseinfraattr.is_write = False
                ip_desc = 'Read IP'
            networkapi_ip_id = cs_provider.register_networkapi_ip(equipment_id=networkapi_equipment_id, ip=reserved_ip['secondary_ip'], ip_desc=ip_desc)
            databaseinfraattr.cs_ip_id = reserved_ip['cs_ip_id']
            databaseinfraattr.networkapi_equipment_id = networkapi_equipment_id
            databaseinfraattr.networkapi_ip_id = networkapi_ip_id
            databaseinfraattr.databaseinfra = workflow_dict['databaseinfra']
            databaseinfraattr.save()
            old_ip = workflow_dict['source_secondary_ips'][index]
            old_ip.equivalent_dbinfraattr = databaseinfraattr
            old_ip.save()
            workflow_dict['target_secondary_ips'].append(databaseinfraattr)
        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.do/VarMisuse@108/184 `cs_provider`->`traceback`