From c189324735191b76ec1d21b77d76f25c78e3829c Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Tue, 14 Aug 2012 14:12:53 -0400 Subject: [PATCH] Mark bin/glance as deprecated * Add a WARNING to the usage of bin/glance * Print a WARNING line to stderr when bin/glance is called * Raise a UserWarning on 'import glance.client' * Implements bp glance-deprecate-client Change-Id: Iabce7569d28c5dc73b5e1ceb55e4e4f2fc47727b --- bin/glance | 14 ++++++++++++-- glance/client.py | 6 ++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bin/glance b/bin/glance index fc3f309380..62a218546c 100755 --- a/bin/glance +++ b/bin/glance @@ -28,7 +28,7 @@ import optparse import os import sys import time - +import warnings from urlparse import urlparse # If ../glance/__init__.py exists, add ../ to Python search path, so that @@ -41,7 +41,10 @@ if os.path.exists(os.path.join(possible_topdir, 'glance', '__init__.py')): gettext.install('glance', unicode=1) -from glance import client as glance_client +with warnings.catch_warnings(): + warnings.simplefilter("ignore") + from glance import client as glance_client + from glance.common import exception from glance.common import utils from glance.version import version_info as version @@ -1022,6 +1025,9 @@ if __name__ == '__main__': usage = """ %prog [options] [args] +WARNING! This tool is deprecated in favor of python-glanceclient (see +http://github.com/openstack/python-glanceclient). + Commands: help Output help for one of the commands below @@ -1056,6 +1062,10 @@ Member Commands: members-replace Replaces all membership for an image """ + print >> sys.stderr, ("WARNING! This tool is deprecated in favor of " + "python-glanceclient (see " + "http://github.com/openstack/python-glanceclient).") + oparser = optparse.OptionParser(version='%%prog %s' % version.version_string(), usage=usage.strip()) diff --git a/glance/client.py b/glance/client.py index cbfabe9ead..287a259be7 100644 --- a/glance/client.py +++ b/glance/client.py @@ -25,6 +25,7 @@ import json import os import socket import sys +import warnings import glance.api.v1 from glance.common import animation @@ -35,6 +36,11 @@ from glance.common import utils SUPPORTED_PARAMS = glance.api.v1.SUPPORTED_PARAMS SUPPORTED_FILTERS = glance.api.v1.SUPPORTED_FILTERS +warn_msg = ("The 'glance.client' module is deprecated in favor of the " + "'glanceclient' module provided by python-glanceclient (see " + "http://github.com/openstack/python-glanceclient).") +warnings.warn(warn_msg, stacklevel=2) + class V1Client(base_client.BaseClient):