rhtconsulting / rhc-ose

OpenShift Automation and Utilities by Red Hat Consulting
42 stars 34 forks source link

initial commit of conversion of script to python #249

Closed stratus-ss closed 7 years ago

stratus-ss commented 7 years ago

What does this PR do?

This PR converts the existing shell script into python. It now queries the registry.access.redhat.com v2 docker json to determine the latest version of images specified in its' json configuration. This is done based on the version of OpenShift specified. It uses the same --from, --local, and --file arguments as the original script as well as a --output which, when specified will print the docker pull/tag/push commands to the screen in the event you wish to save them.

How should this be manually tested?

The sample config docker_tags.json is simply a json file which currently is a multi-dimensional dictionary with the following structure: {<tag type>: {<image namespace>: [ <list of image names>]}}

Currently tag type is broken into two camps, those images which are supposed to have a 'v' in their version (i.e. ose-deployer:v3.3.1.11 ) and those which do not (i.e. metrics-deployer:3.4.1)

./docker-registry-sync.py --from=registry.access.redhat.com --local=docker-reg.example.com:5000 --file=docker_tags.json --output

The script is currently using the 'os' module in python to do the docker interaction. There is a docker 'pip' module that is also available which may be more elegant if less portable

Is there a relevant Issue open for this?

https://trello.com/c/5OXQugrU/227-disconnected-installs-update-docker-sync-script-to-pull-tag-information-from-upstream-registry

Who would you like to review this?

/cc @etsauer @oybed

etsauer commented 7 years ago

@stratus-ss I'm getting an error now trying to run the script with the following:

[esauer@localhost rhc-ose]$ python ./solutions/disconnected_installs/docker-registry-sync.py --from registry.access.redhat.com --local localhost:5000 --file ./solutions/disconnected_installs/docker_tags.json  --dry-run
Traceback (most recent call last):
  File "./solutions/disconnected_installs/docker-registry-sync.py", line 156, in <module>
    generate_url_list('core_components', retrieve_v_tags_from_redhat_list)
  File "./solutions/disconnected_installs/docker-registry-sync.py", line 65, in generate_url_list
    for namespace in config_file_dict[dictionary_key]:
KeyError: 'core_components'