Adds support for --insecure.
fixes lp#1004281. Change-Id: I464e39515a7172bfb72921a92f46d31baac466d8
This commit is contained in:
@@ -29,13 +29,14 @@ USER_AGENT = 'python-glanceclient'
|
|||||||
|
|
||||||
class HTTPClient(httplib2.Http):
|
class HTTPClient(httplib2.Http):
|
||||||
|
|
||||||
def __init__(self, endpoint, token=None, timeout=600):
|
def __init__(self, endpoint, token=None, timeout=600, insecure=False):
|
||||||
super(HTTPClient, self).__init__(timeout=timeout)
|
super(HTTPClient, self).__init__(timeout=timeout)
|
||||||
self.endpoint = endpoint
|
self.endpoint = endpoint
|
||||||
self.auth_token = token
|
self.auth_token = token
|
||||||
|
|
||||||
# httplib2 overrides
|
# httplib2 overrides
|
||||||
self.force_exception_to_status_code = True
|
self.force_exception_to_status_code = True
|
||||||
|
self.disable_ssl_certificate_validation = insecure
|
||||||
|
|
||||||
def http_log(self, args, kwargs, resp, body):
|
def http_log(self, args, kwargs, resp, body):
|
||||||
if os.environ.get('GLANCECLIENT_DEBUG', False):
|
if os.environ.get('GLANCECLIENT_DEBUG', False):
|
||||||
|
@@ -53,6 +53,11 @@ class OpenStackImagesShell(object):
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help=argparse.SUPPRESS)
|
help=argparse.SUPPRESS)
|
||||||
|
|
||||||
|
parser.add_argument('--insecure',
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
help=argparse.SUPPRESS)
|
||||||
|
|
||||||
parser.add_argument('--os-username',
|
parser.add_argument('--os-username',
|
||||||
default=utils.env('OS_USERNAME'),
|
default=utils.env('OS_USERNAME'),
|
||||||
help='Defaults to env[OS_USERNAME]')
|
help='Defaults to env[OS_USERNAME]')
|
||||||
@@ -221,7 +226,8 @@ class OpenStackImagesShell(object):
|
|||||||
}
|
}
|
||||||
endpoint, token = self._authenticate(**kwargs)
|
endpoint, token = self._authenticate(**kwargs)
|
||||||
|
|
||||||
image_service = client_v1.Client(endpoint, token)
|
image_service = client_v1.Client(endpoint, token,
|
||||||
|
insecure=args.insecure)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
args.func(image_service, args)
|
args.func(image_service, args)
|
||||||
|
@@ -33,8 +33,9 @@ class Client(http.HTTPClient):
|
|||||||
http requests. (optional)
|
http requests. (optional)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, endpoint, token=None, timeout=600):
|
def __init__(self, endpoint, token=None, timeout=600, insecure=False):
|
||||||
""" Initialize a new client for the Images v1 API. """
|
""" Initialize a new client for the Images v1 API. """
|
||||||
super(Client, self).__init__(endpoint, token=token, timeout=timeout)
|
super(Client, self).__init__(endpoint, token=token,
|
||||||
|
timeout=timeout, insecure=insecure)
|
||||||
self.images = images.ImageManager(self)
|
self.images = images.ImageManager(self)
|
||||||
self.image_members = image_members.ImageMemberManager(self)
|
self.image_members = image_members.ImageMemberManager(self)
|
||||||
|
Reference in New Issue
Block a user