Skip to content

Commit

Permalink
Chore: Clean-up pre-commit issues
Browse files Browse the repository at this point in the history
Pre-commit issues all need to be clean before GitHub Actions can be
setup.

Issue: RELENG-4689
Signed-off-by: Andrew Grimberg <[email protected]>
Change-Id: I4f08a7ed8f05caaa9430b50bc83aeceb8f4fd71e
  • Loading branch information
tykeal committed Apr 12, 2023
1 parent 9f944a6 commit 4d5f1d7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
1 change: 0 additions & 1 deletion lftools/api/endpoints/nexus2.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def role_list(self):

role_list = []
for role in result["data"]:

# wacky string concat is to provide the right format
# so that tabulate will iterate the string at the newline
# breaks and show multiline columns in a nice way
Expand Down
5 changes: 4 additions & 1 deletion lftools/api/endpoints/nexus3.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ def search_asset(self, query, repository, details=False):
"repository": repository,
}
json_data = json.dumps(data)
result = self.get("v1/search/assets?q={}&repository={}".format(query, repository), data=json_data,)[
result = self.get(
"v1/search/assets?q={}&repository={}".format(query, repository),
data=json_data,
)[
1
]["items"]
list_of_assets = []
Expand Down
9 changes: 4 additions & 5 deletions lftools/nexus/release_docker_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ class DockerTagClass(TagClass):
Doing this manually from command line, you will give this command:
curl -s https://registry.hub.docker.com:443/v2/namespaces/onap/repositories/base_sdc-sanity/tags
which gives you a json output. Just looking for the tag names we do this
curl -s https://registry.hub.docker.com:443/v2/namespaces/onap/repositories/base_sdc-sanity/tags | jq -r ".results[].name"
curl -s https://registry.hub.docker.com:443/v2/namespaces/onap/repositories/base_sdc-sanity/tags | \
jq -r ".results[].name"
latest
1.7.0
1.6.0
Expand Down Expand Up @@ -336,9 +337,7 @@ def __init__(self, org_name, repo_name, repo_from_file):
log.debug("r.status_code = {}, ok={}".format(r.status_code, r.status_code == requests.codes.ok))
if r.status_code == 429:
# Speed throttling in effect. Cancel program
raise requests.HTTPError(
"Dockerhub throttling at tag fetching.\n {}".format(r.text)
)
raise requests.HTTPError("Dockerhub throttling at tag fetching.\n {}".format(r.text))
if r.status_code == requests.codes.ok:
raw_json = json.loads(r.text)

Expand All @@ -347,7 +346,7 @@ def __init__(self, org_name, repo_name, repo_from_file):
tag_name = result["name"]
self.add_tag(tag_name)
log.debug("Docker {} has tag {}".format(combined_repo_name, tag_name))
except:
except Exception:
log.debug("Issue fetching tags for {}".format(combined_repo_name))
else:
self.repository_exist = False
Expand Down
14 changes: 8 additions & 6 deletions lftools/openstack/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import sys
import tempfile
from datetime import datetime, timedelta
from six.moves import urllib

import openstack
import openstack.config
from openstack.cloud.exc import OpenStackCloudException
from six.moves import urllib

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -85,7 +85,10 @@ def cleanup(os_cloud, days=0, hide_public=False, ci_managed=True, clouds=None):
from. Otherwise os_cloud will be used.
"""

bad_attribute = ""
def _log_bad_attribute(attribute):
"""Log a bad attribute."""
log.warning("Use of " + attribute + " resulted in an exception")

def _remove_images_from_cloud(images, cloud):
log.info("Removing {} images from {}.".format(len(images), cloud.config._name))
project_info = cloud._get_project_info()
Expand All @@ -96,13 +99,13 @@ def _remove_images_from_cloud(images, cloud):
log.warning("Image {} is protected. Cannot remove...".format(image.name))
continue
except AttributeError:
bad_attribute = "image.is_protected"
_log_bad_attribute("image.is_protected")
try:
if image.protected:
log.warning("Image {} is protected. Cannot remove...".format(image.name))
continue
except AttributeError:
bad_attribute = "image.protected"
_log_bad_attribute("image.protected")

if image.visibility == "shared":
log.warning("Image {} is shared. Cannot remove...".format(image.name))
Expand Down Expand Up @@ -144,8 +147,7 @@ def _remove_images_from_cloud(images, cloud):
filtered_images = _filter_images(images, days, hide_public, ci_managed)
if filtered_images:
_remove_images_from_cloud(filtered_images, cloud)
if bad_attribute:
log.warning("Use of " + bad_attribute + " resulted in an exception")


def share(os_cloud, image, clouds):
"""Share image with another tenant."""
Expand Down
6 changes: 1 addition & 5 deletions lftools/openstack/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,7 @@ def delete_stale(os_cloud, jenkins_servers):

log.debug("Active stacks")
for stack in stacks:
if (
stack.status == "CREATE_COMPLETE"
or stack.status == "CREATE_FAILED"
or stack.status == "DELETE_FAILED"
):
if stack.status == "CREATE_COMPLETE" or stack.status == "CREATE_FAILED" or stack.status == "DELETE_FAILED":
log.debug(" {}".format(stack.stack_name))

if stack.status == "DELETE_FAILED":
Expand Down
9 changes: 4 additions & 5 deletions tests/test_release_docker_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def test_ProjectClass_2_missing(self, responses, datafiles, mocker):
project = ["onap", "sdc-helm-validator", ""]

nexus_url = "https://nexus3.onap.org:10002/v2/onap/sdc-helm-validator/tags/list"
nexus_answer = '{"name":"onap/sdc-helm-validator","tags":["v1.0.0","1.3.0", "1.3.1", "1.4.0", "1.4.1","1.6.0", "1.7.0","latest"]}'
nexus_answer = '{"name":"onap/sdc-helm-validator","tags":["v1.0.0","1.3.0", "1.3.1", "1.4.0", "1.4.1","1.6.0", "1.7.0","latest"]}' # noqa
nexus_answer_valid_tags = ["1.3.0", "1.3.1", "1.4.0", "1.4.1", "1.6.0", "1.7.0"]
nexus_answer_invalid_tags = ["v1.0.0", "latest"]
docker_url = "https://registry.hub.docker.com/v2/namespaces/onap/repositories/sdc-helm-validator/tags"
Expand Down Expand Up @@ -483,7 +483,7 @@ def test_ProjectClass_1_missing(self, responses, datafiles, mocker):
project = ["onap", "sdc-helm-validator", ""]

nexus_url = "https://nexus3.onap.org:10002/v2/onap/sdc-helm-validator/tags/list"
nexus_answer = '{"name":"onap/sdc-helm-validator","tags":["v1.0.0","1.3.0", "1.3.1", "1.4.0", "1.4.1","1.6.0", "1.7.0","latest"]}'
nexus_answer = '{"name":"onap/sdc-helm-validator","tags":["v1.0.0","1.3.0", "1.3.1", "1.4.0", "1.4.1","1.6.0", "1.7.0","latest"]}' # noqa
nexus_answer_valid_tags = ["1.3.0", "1.3.1", "1.4.0", "1.4.1", "1.6.0", "1.7.0"]
nexus_answer_invalid_tags = ["v1.0.0", "latest"]
docker_url = "https://registry.hub.docker.com/v2/namespaces/onap/repositories/sdc-helm-validator/tags"
Expand Down Expand Up @@ -536,7 +536,7 @@ def test_ProjectClass_socket_timeout(self, responses, datafiles, mocker):

project = ["onap", "sdc-helm-validator", ""]
nexus_url = "https://nexus3.onap.org:10002/v2/onap/sdc-helm-validator/tags/list"
nexus_answer = '{"name":"onap/sdc-helm-validator","tags":["v1.0.0","1.3.0", "1.3.1", "1.4.0", "1.4.1","1.6.0", "1.7.0","latest"]}'
nexus_answer = '{"name":"onap/sdc-helm-validator","tags":["v1.0.0","1.3.0", "1.3.1", "1.4.0", "1.4.1","1.6.0", "1.7.0","latest"]}' # noqa
nexus_answer_valid_tags = ["1.3.0", "1.3.1", "1.4.0", "1.4.1", "1.6.0", "1.7.0"]
nexus_answer_invalid_tags = ["v1.0.0", "latest"]
docker_url = "https://registry.hub.docker.com/v2/namespaces/onap/repositories/sdc-helm-validator/tags"
Expand Down Expand Up @@ -609,7 +609,6 @@ def test_ProjectClass_socket_timeout(self, responses, datafiles, mocker):
os.path.join(FIXTURE_DIR, "nexus"),
)
class TestFetchNexus3Catalog:

url = "https://nexus3.onap.org:10002/v2/_catalog"
answer = """
{"repositories":["dcae_dmaapbc","onap/aaf/aaf-base-openssl_1.1.0","onap/aaf/aaf-base-xenial","onap/aaf/aaf_agent","onap/aaf/aaf_cass","onap/aaf/aaf_cm","onap/aaf/aaf_config","onap/aaf/aaf_core","onap/aaf/aaf_fs","onap/aaf/aaf_gui","onap/aaf/aaf_hello","onap/aaf/aaf_locate","onap/aaf/aaf_oauth","onap/aaf/aaf_service","onap/aaf/abrmd","onap/aaf/distcenter","onap/aaf/sms","onap/aaf/smsquorumclient","onap/aaf/testcaservice","onap/aai-cacher","onap/aai-graphadmin","onap/aai-resources","onap/aai-traversal","onap/aai/esr-gui","onap/aai/esr-server","onap/admportal-sdnc-image","onap/appc-cdt-image","onap/appc-image","onap/babel","onap/base_sdc-cassandra","onap/base_sdc-cqlsh","onap/base_sdc-elasticsearch","onap/base_sdc-jetty","onap/base_sdc-kibana","onap/base_sdc-python","onap/base_sdc-sanity","onap/base_sdc-vnc","onap/ccsdk-ansible-server-image","onap/ccsdk-apps-ms-neng","onap/ccsdk-controllerblueprints","onap/ccsdk-dgbuilder-image","onap/ccsdk-odl-image","onap/ccsdk-odl-oxygen-image","onap/ccsdk-odlsli-image","onap/ccsdk-ubuntu-image","onap/chameleon","onap/champ","onap/clamp","onap/clamp-dashboard-kibana","onap/clamp-dashboard-logstash","onap/cli","onap/data-router","onap/dcae-be","onap/dcae-ci-tests","onap/dcae-dt","onap/dcae-fe","onap/dcae-tools","onap/dcae-tosca-app","onap/dmaap/buscontroller","onap/dmaap/datarouter-node","onap/dmaap/datarouter-prov","onap/dmaap/datarouter-subscriber","onap/dmaap/dmaap-mr","onap/dmaap/kafka01101","onap/externalapi/nbi","onap/gallifrey","onap/gizmo","onap/holmes/engine-management","onap/holmes/rule-management","onap/model-loader","onap/msb/msb_apigateway","onap/msb/msb_base","onap/msb/msb_discovery","onap/multicloud/azure","onap/multicloud/framework","onap/multicloud/openstack-newton","onap/multicloud/openstack-ocata","onap/multicloud/openstack-pike","onap/multicloud/openstack-windriver","onap/multicloud/openstack/openstack-ocata","onap/multicloud/vio","onap/multicloud/vio-vesagent","onap/music/cassandra_3_11","onap/music/cassandra_job","onap/music/cassandra_music","onap/music/music","onap/music/prom","onap/network-discovery","onap/oom/kube2msb","onap/optf-cmso-dbinit","onap/optf-cmso-service","onap/optf-has","onap/optf-osdf","onap/org.onap.dcaegen2.collectors.datafile.datafile-app-server","onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-main","onap/org.onap.dcaegen2.collectors.snmptrap","onap/org.onap.dcaegen2.collectors.ves.vescollector","onap/org.onap.dcaegen2.deployments.bootstrap","onap/org.onap.dcaegen2.deployments.cm-container","onap/org.onap.dcaegen2.deployments.healthcheck-container","onap/org.onap.dcaegen2.deployments.k8s-bootstrap-container","onap/org.onap.dcaegen2.deployments.redis-cluster-container","onap/org.onap.dcaegen2.deployments.tca-cdap-container","onap/org.onap.dcaegen2.deployments.tls-init-container","onap/org.onap.dcaegen2.platform.cdapbroker","onap/org.onap.dcaegen2.platform.configbinding","onap/org.onap.dcaegen2.platform.configbinding.app-app","onap/org.onap.dcaegen2.platform.deployment-handler","onap/org.onap.dcaegen2.platform.inventory-api","onap/org.onap.dcaegen2.platform.policy-handler","onap/org.onap.dcaegen2.platform.servicechange-handler","onap/org.onap.dcaegen2.services.prh.prh-app-server","onap/policy-apex-pdp","onap/policy-distribution","onap/policy-drools","onap/policy-pe","onap/policy/policy-db","onap/policy/policy-drools","onap/policy/policy-nexus","onap/policy/policy-pe","onap/pomba-aai-context-builder","onap/pomba-context-aggregator","onap/pomba-network-discovery-context-builder","onap/pomba-sdc-context-builder","onap/portal-app","onap/portal-apps","onap/portal-db","onap/portal-sdk","onap/portal-wms","onap/refrepo/postgres","onap/sdc-api-tests","onap/sdc-backend","onap/sdc-backend-init","onap/sdc-cassandra","onap/sdc-cassandra-init","onap/sdc-elasticsearch","onap/sdc-frontend","onap/sdc-init-elasticsearch","onap/sdc-kibana","onap/sdc-onboard-backend","onap/sdc-onboard-cassandra-init","onap/sdc-simulator","onap/sdc-ui-tests","onap/sdc/sdc-workflow-designer","onap/sdnc-ansible-server-image","onap/sdnc-dmaap-listener-image","onap/sdnc-image","onap/sdnc-ueb-listener-image","onap/search-data-service","onap/service-decomposition","onap/sniroemulator","onap/so/api-handler-infra","onap/so/asdc-controller","onap/so/base-image","onap/so/bpmn-infra","onap/so/catalog-db-adapter","onap/so/openstack-adapter","onap/so/request-db-adapter","onap/so/sdc-controller","onap/so/sdnc-adapter","onap/so/so-monitoring","onap/so/vfc-adapter","onap/sparky-be","onap/spike","onap/testsuite","onap/usecase-ui","onap/usecase-ui-server","onap/usecase-ui/usecase-ui-server","onap/validation","onap/vfc/catalog","onap/vfc/db","onap/vfc/emsdriver","onap/vfc/gvnfmdriver","onap/vfc/jujudriver","onap/vfc/multivimproxy","onap/vfc/nfvo/svnfm/huawei","onap/vfc/nfvo/svnfm/nokia","onap/vfc/nfvo/svnfm/nokiav2","onap/vfc/nslcm","onap/vfc/resmanagement","onap/vfc/vnflcm","onap/vfc/vnfmgr","onap/vfc/vnfres","onap/vfc/wfengine-activiti","onap/vfc/wfengine-mgrservice","onap/vfc/ztesdncdriver","onap/vfc/ztevmanagerdriver","onap/vfc/ztevnfmdriver","onap/vid","onap/vnfsdk/ice","onap/vnfsdk/refrepo","onap/vnfsdk/refrepo/postgres","onap/vnfsdk/vnftest","onap/vvp/cms","onap/vvp/engagementmgr","onap/vvp/gitlab","onap/vvp/image-scanner","onap/vvp/jenkins","onap/vvp/portal","onap/vvp/postgresql","onap/vvp/test-engine","onap/workflow-backend","onap/workflow-frontend","onap/workflow-init","openecomp/aai-cacher","openecomp/aai-resources","openecomp/aai-traversal","openecomp/appc-image","openecomp/base_sdc-backend","openecomp/base_sdc-cassandra","openecomp/base_sdc-elasticsearch","openecomp/base_sdc-frontend","openecomp/base_sdc-kibana","openecomp/base_sdc-sanity","openecomp/jacoco","openecomp/mso","openecomp/mso-arquillian","openecomp/portalapps","openecomp/portaldb","openecomp/sdc-backend","openecomp/sdc-cassandra","openecomp/sdc-elasticsearch","openecomp/sdc-frontend","openecomp/sdc-kibana","openecomp/sdc-sanity","openecomp/ubuntu-update","openecomp/vid","openecomp/wildfly"]}
Expand Down Expand Up @@ -755,7 +754,7 @@ def initiate_test_fetch(self, responses, datafiles, mocker, repo=""):

# Missing one tag in docker
nexus_url1 = "https://nexus3.onap.org:10002/v2/onap/sdc-helm-validator/tags/list"
nexus_answer1 = '{"name":"onap/sdc-helm-validator","tags":["v1.0.0","1.3.0", "1.3.1", "1.4.0", "1.4.1","1.6.0", "1.7.0","latest"]}'
nexus_answer1 = '{"name":"onap/sdc-helm-validator","tags":["v1.0.0","1.3.0", "1.3.1", "1.4.0", "1.4.1","1.6.0", "1.7.0","latest"]}' # noqa
docker_url1 = "https://registry.hub.docker.com/v2/namespaces/onap/repositories/sdc-helm-validator/tags"
docker_answer1 = data_from_file(
os.path.join(str(datafiles), "releasedockerhub_dockertags-sdc-helm-validator-missing1.json")
Expand Down

0 comments on commit 4d5f1d7

Please sign in to comment.