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
This commit is contained in:
Brian Waldon 2012-08-14 14:12:53 -04:00
parent 3d93ca6655
commit c189324735
2 changed files with 18 additions and 2 deletions

View File

@ -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 <command> [options] [args]
WARNING! This tool is deprecated in favor of python-glanceclient (see
http://github.com/openstack/python-glanceclient).
Commands:
help <command> 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())

View File

@ -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):