Unverified Commit 6caabaef authored by danfengliu's avatar danfengliu Committed by GitHub
Browse files

Merge pull request #13108 from danfengliu/add-2.1-upgrade-pipeline-in-nightly

Add 2.1 upgrade pipeline in nightly
parents aa71bc46 48510fde
......@@ -17,18 +17,18 @@ def docker_info_display():
ret = base.run_command(command)
print("Command return: ", ret)
def docker_login_cmd(harbor_host, user, password, enable_manifest = True):
def docker_login_cmd(harbor_host, user, password, cfg_file = "./tests/apitests/python/update_docker_cfg.sh", enable_manifest = True):
command = ["sudo", "docker", "login", harbor_host, "-u", user, "-p", password]
print( "Docker Login Command: ", command)
base.run_command(command)
if enable_manifest == True:
try:
ret = subprocess.check_output(["./tests/apitests/python/update_docker_cfg.sh"], shell=False)
ret = subprocess.check_output([cfg_file], shell=False)
except subprocess.CalledProcessError as exc:
raise Exception("Failed to update docker config, error is {} {}.".format(exc.returncode, exc.output))
def docker_manifest_create(index, manifests):
command = ["sudo", "docker","manifest","create",index]
command = ["sudo", "docker","manifest","create", "--amend", index]
command.extend(manifests)
print( "Docker Manifest Command: ", command)
base.run_command(command)
......@@ -46,8 +46,8 @@ def docker_manifest_push(index):
manifest_list.append(line[-71:])
return index_sha256, manifest_list
def docker_manifest_push_to_harbor(index, manifests, harbor_server, user, password):
docker_login_cmd(harbor_server, user, password)
def docker_manifest_push_to_harbor(index, manifests, harbor_server, user, password, cfg_file = "./tests/apitests/python/update_docker_cfg.sh"):
docker_login_cmd(harbor_server, user, password, cfg_file=cfg_file)
docker_manifest_create(index, manifests)
return docker_manifest_push(index)
......
......@@ -24,7 +24,7 @@ Verify User
Close Browser
Verify Project
[Arguments] ${json}
[Arguments] ${json} ${check_content_trust}=${true}
Log To Console "Verify Project..."
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
......@@ -32,7 +32,7 @@ Verify Project
FOR ${project} IN @{project}
Retry Wait Until Page Contains ${project}
END
Verify Project Metadata ${json}
Verify Project Metadata ${json} ${check_content_trust}
Close Browser
Verify Image Tag
......@@ -43,7 +43,7 @@ Verify Image Tag
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
@{repo}= Get Value From Json ${json} $.projects[?(@.name=${project})]..repo..name
Run Keyword If ${has_image} == ${true} Loop Image Repo @{repo}
......@@ -52,17 +52,17 @@ Verify Image Tag
Close Browser
Verify Project Metadata
[Arguments] ${json}
[Arguments] ${json} ${check_content_trust}
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Configuration
Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.public ${project_config_public_checkbox}
Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.enable_content_trust ${project_config_content_trust_checkbox}
Run Keyword If '${check_content_trust}' == '${true}' Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.enable_content_trust ${project_config_content_trust_checkbox}
Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.auto_scan ${project_config_scan_images_on_push_checkbox}
Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.prevent_vul ${project_config_prevent_vulnerable_images_from_running_checkbox}
${ret} Get Selected List Value ${project_config_severity_select}
......@@ -94,7 +94,7 @@ Verify Member Exist
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Member
@{members}= Get Value From Json ${json} $.projects[?(@.name=${project})].member..name
......@@ -111,7 +111,7 @@ Verify Webhook
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Webhooks
${enabled}= Get Value From Json ${json} $.projects[?(@.name=${project})].webhook.enabled
......@@ -130,6 +130,37 @@ Verify Webhook
END
Close Browser
Verify Webhook For 2.0
[Arguments] ${json}
Log To Console "Verify Webhook..."
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Webhooks
${enabled}= Get Value From Json ${json} $.projects[?(@.name=${project})].webhook.enabled
${enable_count} Get Element Count xpath=//span[contains(.,'Enabled')]
${disable_count} Get Element Count xpath=//span[contains(.,'Disabled')]
Log To Console '${enabled}[0]'
Log To Console '${true}'
Run Keyword If '${enabled}[0]' == '${true}' Page Should Contain Enabled
... ELSE Page Should Contain Disabled
${address}= Get Value From Json ${json} $.projects[?(@.name=${project})].webhook.address
${name}= Get Value From Json ${json} $.projects[?(@.name=${project})].webhook.name
${notify_type}= Get Value From Json ${json} $.projects[?(@.name=${project})].webhook.notify_type
Log To Console '${address}[0]'
Log To Console '${name}[0]'
Log To Console '${notify_type}[0]'
Page Should Contain ${address}[0]
Page Should Contain ${name}[0]
Page Should Contain ${notify_type}[0]
Navigate To Projects
END
Close Browser
Verify Tag Retention Rule
[Arguments] ${json}
Log To Console "Verify Tag Retention Rule..."
......@@ -137,6 +168,8 @@ Verify Tag Retention Rule
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
${tag_retention_rule}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule
Run Keyword If ${tag_retention_rule}[0] == ${null} Continue For Loop
${out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
......@@ -163,7 +196,7 @@ Verify Tag Immutability Rule
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Tag Immutability
@{repo_decoration}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_immutability_rule.repo_decoration
......@@ -193,7 +226,7 @@ Verify Robot Account Exist
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Robot Account
@{robot_accounts}= Get Value From Json ${json} $.projects[?(@.name=${project})].robot_account..name
......@@ -241,7 +274,7 @@ Verify Project Label
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Label
@{projectlabel}= Get Value From Json ${json} $.projects[?(@.name=${project})]..labels..name
......@@ -304,31 +337,6 @@ Verify Replicationrule
END
Close Browser
Verify Project Setting
[Arguments] ${json}
Log To Console "Verify Project Setting..."
@{projects}= Get Value From Json ${json} $.projects.[*].name
FOR ${project} IN @{Projects}
${public}= Get Value From Json ${json} $.projects[?(@.name=${project})].accesslevel
${contenttrust}= Get Value From Json ${json} $.projects[?(@.name=${project})]..enable_content_trust
${preventrunning}= Get Value From Json ${json} $.projects[?(@.name=${project})]..prevent_vulnerable_images_from_running
${scanonpush}= Get Value From Json ${json} $.projects[?(@.name=${project})]..automatically_scan_images_on_push
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Goto Project Config
Run Keyword If ${public} == "public" Checkbox Should Be Checked //clr-checkbox-wrapper[@name='public']//label
Run Keyword If ${contenttrust} == "true" Checkbox Should Be Checked //clr-checkbox-wrapper[@name='content-trust']//label
Run Keyword If ${contenttrust} == "false" Checkbox Should Not Be Checked //clr-checkbox-wrapper[@name='content-trust']//label
Run Keyword If ${preventrunning} == "true" Checkbox Should Be Checked //*[@id='prevent-vulenrability-image']//clr-checkbox-wrapper//label
Run Keyword If ${preventrunning} == "false" Checkbox Should Not Be Checked //*[@id='prevent-vulenrability-image']//clr-checkbox-wrapper//label
Run Keyword If ${scanonpush} == "true" Checkbox Should Be Checked //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//input
Run Keyword If ${scanonpush} == "true" Checkbox Should Not Be Checked //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//input
Close Browser
END
Verify Interrogation Services
[Arguments] ${json}
Log To Console "Verify Interrogation Services..."
......@@ -380,7 +388,7 @@ Verify Project-level Allowlist
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Configuration
@{is_reuse_sys_cve_allowlist}= Get Value From Json ${json} $.projects[?(@.name=${project})].configuration.reuse_sys_cve_allowlist
......@@ -423,3 +431,83 @@ Verify Trivy Is Default Scanner
Switch To Scanners Page
Should Display The Default Trivy Scanner
Close Browser
Verify Artifact Index
[Arguments] ${json}
Log To Console "Verify Artifact Index..."
# Only the 1st project has manifest image, so use index 0 of projects for verification.
@{project}= Get Value From Json ${json} $.projects.[0].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
${name}= Get Value From Json ${json} $.projects[?(@.name=${project})].artifact_index.name
${tag}= Get Value From Json ${json} $.projects[?(@.name=${project})].artifact_index.tag
Go Into Project ${project} has_image=${true}
Go Into Repo ${project}/${name}[0]
Go Into Index And Contain Artifacts ${tag}[0] limit=2
Pull image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${project} ${name}[0]:${tag}[0]
Navigate To Projects
END
Close Browser
Loop Repo
[Arguments] ${project} @{repos}
FOR ${repo} IN @{repos}
Navigate To Projects
Go Into Project ${project} has_image=${true}
Go Into Repo ${project}/${repo}[0][cache_image_namespace]/${repo}[0][cache_image]
Pull image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${project} ${repo}[0][cache_image_namespace]/${repo}[0][cache_image]:${repo}[0][tag]
END
Verify Proxy Cache Image Existence
[Arguments] ${json}
Log To Console "Verify Proxy Cache Image Existence..."
# Only the 3rd project has cached image, so use index 2 of projects for verification.
@{project}= Get Value From Json ${json} $.projects.[2].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{repo}= Get Value From Json ${json} $.projects[?(@.name=${project})].repo
Loop Repo ${project} @{repo}
END
Close Browser
Verify Distributions
[Arguments] ${json}
Log To Console "Verify Distributions..."
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
@{distribution_names}= Get Value From Json ${json} $.distributions..name
Switch To Distribution
FOR ${name} IN @{distribution_names}
${endpoint}= Get Value From Json ${json} $.distributions[?(@.name=${name})].endpoint
${vendor}= Get Value From Json ${json} $.distributions[?(@.name=${name})].vendor
${auth_mode}= Get Value From Json ${json} $.distributions[?(@.name=${name})].auth_mode
Retry Wait Until Page Contains Element //div[@class='datagrid-scrolling-cells' and contains(.,'${name}') and contains(.,'${endpoint}[0]') and contains(.,'${vendor}[0]') and contains(.,'${auth_mode}[0]')]
END
Verify P2P Preheat Policy
[Arguments] ${json}
Log To Console "P2P Preheat Policy..."
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Navigate To Projects
@{project}= Get Value From Json ${json} $.projects.[*].name
FOR ${project} IN @{project}
@{p2p_preheat_policys}= Get Value From Json ${json} $.projects[?(@.name=${project})].p2p_preheat_policy
@{policy_names}= Get Value From Json ${json} $.projects[?(@.name=${project})].p2p_preheat_policy..name
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Run Keyword If ${p2p_preheat_policys}[0] == ${null} Continue For Loop
Go Into Project ${project} has_image=${has_image}
Switch To P2P Preheat
Loop P2P Preheat Policys ${json} ${project} @{policy_names}
END
Close Browser
Loop P2P Preheat Policys
[Arguments] ${json} ${project} @{policy_names}
FOR ${policy} IN @{policy_names}
${provider_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].p2p_preheat_policy[?(@.name=${policy})].provider_name
Retry Wait Until Page Contains Element //div[@class='datagrid-scrolling-cells' and contains(.,'${policy}') and contains(.,'${provider_name}[0]')]
END
\ No newline at end of file
......@@ -19,6 +19,7 @@ Default Tags Nightly
*** Test Cases ***
Test Suites Setup
[Tags] setup
Nightly Test Setup ${ip} ${HARBOR_PASSWORD} ${ip1}
Setup API Test
......
This diff is collapsed.
......@@ -29,11 +29,11 @@
"version":"2.0"
},
{
"branch":2,
"branch":3,
"version":"2.1"
},
{
"branch":2,
"branch":3,
"version":"2.2"
}
],
......@@ -101,15 +101,15 @@
"version":"1.10"
},
{
"branch":2,
"branch":3,
"version":"2.0"
},
{
"branch":2,
"branch":3,
"version":"2.1"
},
{
"branch":2,
"branch":3,
"version":"2.2"
}
],
......@@ -203,11 +203,11 @@
"version":"2.0"
},
{
"branch":1,
"branch":2,
"version":"2.1"
},
{
"branch":1,
"branch":2,
"version":"2.2"
}
],
......@@ -225,11 +225,11 @@
"version":"2.0"
},
{
"branch":1,
"branch":2,
"version":"2.1"
},
{
"branch":1,
"branch":2,
"version":"2.2"
}
],
......@@ -309,15 +309,15 @@
"version":"1.10"
},
{
"branch":1,
"branch":2,
"version":"2.0"
},
{
"branch":1,
"branch":2,
"version":"2.1"
},
{
"branch":1,
"branch":2,
"version":"2.2"
}
],
......@@ -343,7 +343,7 @@
"version":"2.2"
}
],
"push_artifact":[
"push_artifact_index":[
{
"branch":1,
"version":"2.0"
......@@ -356,5 +356,101 @@
"branch":1,
"version":"2.2"
}
],
"add_distribution":[
{
"branch":1,
"version":"2.1"
},
{
"branch":1,
"version":"2.2"
}
],
"add_p2p_preheat_policy":[
{
"branch":1,
"version":"2.1"
},
{
"branch":1,
"version":"2.2"
}
],
"get_ca":[
{
"branch":1,
"version":"1.4"
},
{
"branch":1,
"version":"1.6"
},
{
"branch":1,
"version":"1.7"
},
{
"branch":1,
"version":"1.8"
},
{
"branch":1,
"version":"1.9"
},
{
"branch":1,
"version":"1.10"
},
{
"branch":2,
"version":"2.0"
},
{
"branch":2,
"version":"2.1"
},
{
"branch":2,
"version":"2.2"
}
],
"set_url":[
{
"branch":1,
"version":"1.4"
},
{
"branch":1,
"version":"1.6"
},
{
"branch":1,
"version":"1.7"
},
{
"branch":1,
"version":"1.8"
},
{
"branch":1,
"version":"1.9"
},
{
"branch":1,
"version":"1.10"
},
{
"branch":2,
"version":"2.0"
},
{
"branch":2,
"version":"2.1"
},
{
"branch":2,
"version":"2.2"
}
]
}
import os
import sys
import json
import time
import argparse
import requests
import urllib
from functools import wraps
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
......@@ -10,8 +12,16 @@ requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
parser = argparse.ArgumentParser(description='The script to generate data for harbor v1.4.0')
parser.add_argument('--endpoint', '-e', dest='endpoint', required=True, help='The endpoint to harbor')
parser.add_argument('--version', '-v', dest='version', required=False, help='The version to harbor')
parser.add_argument('--libpath', '-l', dest='libpath', required=False, help='e2e library')
args = parser.parse_args()
from os import path
sys.path.append(args.libpath)
sys.path.append(args.libpath + "/library")
from library.docker_api import docker_manifest_push_to_harbor
from library.repository import push_image_to_project
from library.repository import Repository
url = "https://"+args.endpoint+"/api/"
endpoint_url = "https://"+args.endpoint
print(url)
......@@ -48,9 +58,27 @@ class HarborAPI:
@get_feature_branch
def create_project(self, project, **kwargs):
if kwargs["branch"] == 1:
body=dict(body={"project_name": ""+project["name"]+"", "metadata": {"public": "true"}})
body=dict(body={"project_name": project["name"], "metadata": {"public": "true"}})
elif kwargs["branch"] == 2:
body=dict(body={"project_name": ""+project["name"]+"", "metadata": {"public": "true"},"count_limit":project["count_limit"],"storage_limit":project["storage_limit"]})
body=dict(body={"project_name": project["name"], "metadata": {"public": "true"},"count_limit":project["count_limit"],"storage_limit":project["storage_limit"]})
elif kwargs["branch"] == 3:
if project["registry_name"] is not None:
r = request(url+"registries?name="+project["registry_name"]+"", 'get')
registry_id = int(str(r.json()[0]['id']))
else:
registry_id=None
body=dict(body={"project_name": project["name"], "registry_id":registry_id, "metadata": {"public": "true"},"storage_limit":project["storage_limit"]})
request(url+"projects", 'post', **body)
if project["registry_name"] is not None:
USER_ADMIN=dict(endpoint = "https://"+args.endpoint+"/api/v2.0" , username = "admin", password = "Harbor12345")
repo = Repository()
for _repo in project["repo"]:
pull_image(args.endpoint+"/"+ project["name"]+"/"+_repo["cache_image_namespace"]+"/"+_repo["cache_image"])
time.sleep(180)
repo_name = urllib.parse.quote(_repo["cache_image_namespace"]+"/"+_repo["cache_image"],'utf-8')
repo_data = repo.get_repository(project["name"], repo_name, **USER_ADMIN)
print("=========repo_data:",repo_data)
return
else:
raise Exception(r"Error: Feature {} has no branch {}.".format(sys._getframe().f_code.co_name, branch))
request(url+"projects", 'post', **body)
......@@ -69,6 +97,8 @@ class HarborAPI:
body=dict(body={"has_admin_role": 1})
elif kwargs["branch"] == 2:
body=dict(body={"has_admin_role": True})
elif kwargs["branch"] == 3:
body=dict(body={"sysadmin_flag": True, "user_id":int(userid)})
else:
raise Exception(r"Error: Feature {} has no branch {}.".format(sys._getframe().f_code.co_name, branch))
request(url+"users/"+userid+"/sysadmin", 'put', **body)
......@@ -87,6 +117,38 @@ class HarborAPI:
body=dict(body=payload)
request(url+"projects/"+projectid+"/members", 'post', **body)
@get_feature_branch
def add_p2p_preheat_policy(self, project, **kwargs):
r = request(url+"projects?name="+project["name"]+"", 'get')
projectid = int(str(r.json()[0]['project_id']))
if kwargs["branch"] == 1:
if project["p2p_preheat_policy"] is not None:
instances = request(url+"p2p/preheat/instances", 'get')
if len(instances.json()) == 0:
raise Exception(r"Please add p2p preheat instances first.")
for instance in instances.json():
print("instance:", instance)
for policy in project["p2p_preheat_policy"]:
instance_str = [str(item) for item in instances]
if policy["provider_name"] in ''.join(instance_str):
print("policy:", policy)
if instance['name'] == policy["provider_name"]:
payload = {
"provider_id":int(instance['id']),
"name":policy["name"],
"filters":policy["filters"],
"trigger":policy["trigger"],
"project_id":projectid,
"enabled":policy["enabled"]
}