summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xglance-gateway.py25
1 files changed, 9 insertions, 16 deletions
diff --git a/glance-gateway.py b/glance-gateway.py
index 0a7f2c6..747a0ca 100755
--- a/glance-gateway.py
+++ b/glance-gateway.py
@@ -4,7 +4,6 @@ from __future__ import print_function
from libs.environment import *
from libs.glance import *
from libs.keystone import *
-# from libs.openbook_client import *
from libs.service_status_client import *
import argparse
import glob
@@ -26,9 +25,9 @@ def read_manifests(env):
return manifests
-# def check_image_exists_up2date(glance, manifest):
-# image = glance.find("%s.%s" % (manifest["image_name"], manifest["image_type"]))
-# return image and str(manifest["tag"]) in image.tags
+def check_image_exists_up2date(glance, manifest):
+ image = glance.find("%s.%s" % (manifest["image_name"], manifest["image_type"]))
+ return image and str(manifest["tag"]) in image.tags
def main(args):
@@ -57,12 +56,6 @@ def main(args):
# download private image to /tmp
glance_src.download("%s.%s.unvetted" % (manifest["image_name"], manifest["image_type"]),
"/tmp/%s.%s" % (manifest["image_name"], manifest["image_type"]))
- # get AUTH_URLs
- # ob_client = OpenbookClient(host=env_src.extra_envs["openbook_host"],
- # port=env_src.extra_envs["openbook_port"],
- # username=env_src.extra_envs["openbook_user"],
- # password=env_src.extra_envs["openbook_pass"])
- # regions = ob_client.get_service_managers()
service_status_client = ServiceStatusClient(host=env_src.extra_envs["service_status_host"])
regions = service_status_client.get_service_managers()
if manifest["regions_to_exclude"] is None and manifest["regions_to_include"] is None:
@@ -73,7 +66,6 @@ def main(args):
regions_filtered = [r for r in regions if r["name"] in manifest["regions_to_include"]]
else:
regions_filtered = [r for r in regions if r["name"] not in manifest["regions_to_exclude"] and r["name"] in manifest["regions_to_include"]]
- # regions_filtered = [{"name": "RegionOne", "connectionUrl": "http://os.pippiandcarlos.com:5000/v3"}]
for region in regions_filtered:
# upload image as public
env_dest = Environment(region["connectionUrl"],
@@ -95,11 +87,12 @@ def main(args):
})
keystone_dest = Keystone(env_dest)
glance_dest = Glance(keystone_dest, endpoint_type="publicURL")
- glance_dest.upload("%s.%s" % (manifest["image_name"], manifest["image_type"]),
- manifest["image_type"],
- "/tmp/%s.%s" % (manifest["image_name"], manifest["image_type"]),
- "public",
- manifest["tag"])
+ if not check_image_exists_up2date(glance_dest, manifest):
+ glance_dest.upload("%s.%s" % (manifest["image_name"], manifest["image_type"]),
+ manifest["image_type"],
+ "/tmp/%s.%s" % (manifest["image_name"], manifest["image_type"]),
+ "public",
+ manifest["tag"])
if __name__ == "__main__":