import sys
import tempfile
-import shade
+import openstack
+import openstack.config
+from openstack.cloud.exc import OpenStackCloudException
from six.moves import urllib
log = logging.getLogger(__name__)
def list(os_cloud, days=0, hide_public=False, ci_managed=True):
"""List images found according to parameters."""
- cloud = shade.openstack_cloud(cloud=os_cloud)
+ cloud = openstack.connection.from_config(cloud=os_cloud)
images = cloud.list_images()
filtered_images = _filter_images(images, days, hide_public, ci_managed)
try:
result = cloud.delete_image(image.name)
- except shade.exc.OpenStackCloudException as e:
+ except OpenStackCloudException as e:
if str(e).startswith("Multiple matches found for"):
log.warning("{}. Skipping image...".format(str(e)))
continue
else:
log.info('Removed "{}" from {}.'.format(image.name, cloud.cloud_config.name))
- cloud = shade.openstack_cloud(cloud=os_cloud)
+ cloud = openstack.connection.from_config(cloud=os_cloud)
if clouds:
cloud_list = []
for c in clouds.split(","):
- cloud_list.append(shade.openstack_cloud(cloud=c))
+ cloud_list.append(openstack.connection.from_config(cloud=c))
images = cloud.list_images()
filtered_images = _filter_images(images, days, hide_public, ci_managed)
def upload(os_cloud, image, name, disk_format="raw"):
"""Upload image to openstack."""
log.info('Uploading image {} with name "{}".'.format(image, name))
- cloud = shade.openstack_cloud(cloud=os_cloud)
+ cloud = openstack.connection.from_config(cloud=os_cloud)
if re.match(r"^http[s]?://", image):
tmp = tempfile.NamedTemporaryFile(suffix=".img")