Set pep8 version to 1.1 in test_requires
* Fixes bug 1007520 * Changes in pep8 cause new failures Change-Id: Ie678f01a5008b0df6ef43a360b599890cab40776
This commit is contained in:
@@ -197,7 +197,7 @@ class ManagerWithFind(Manager):
|
|||||||
for obj in self.list():
|
for obj in self.list():
|
||||||
try:
|
try:
|
||||||
if all(getattr(obj, attr) == value
|
if all(getattr(obj, attr) == value
|
||||||
for (attr, value) in searches):
|
for (attr, value) in searches):
|
||||||
found.append(obj)
|
found.append(obj)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
@@ -265,7 +265,7 @@ class Resource(object):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
reprkeys = sorted(k for k in self.__dict__.keys() if k[0] != '_' and
|
reprkeys = sorted(k for k in self.__dict__.keys() if k[0] != '_' and
|
||||||
k != 'manager')
|
k != 'manager')
|
||||||
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
||||||
return "<%s %s>" % (self.__class__.__name__, info)
|
return "<%s %s>" % (self.__class__.__name__, info)
|
||||||
|
|
||||||
|
|||||||
@@ -160,12 +160,12 @@ class HTTPClient(httplib2.Http):
|
|||||||
self.auth_token = self.service_catalog.get_token()
|
self.auth_token = self.service_catalog.get_token()
|
||||||
|
|
||||||
management_url = self.service_catalog.url_for(
|
management_url = self.service_catalog.url_for(
|
||||||
attr='region',
|
attr='region',
|
||||||
filter_value=self.region_name,
|
filter_value=self.region_name,
|
||||||
endpoint_type=self.endpoint_type,
|
endpoint_type=self.endpoint_type,
|
||||||
service_type=self.service_type,
|
service_type=self.service_type,
|
||||||
service_name=self.service_name,
|
service_name=self.service_name,
|
||||||
volume_service_name=self.volume_service_name,)
|
volume_service_name=self.volume_service_name)
|
||||||
self.management_url = management_url.rstrip('/')
|
self.management_url = management_url.rstrip('/')
|
||||||
return None
|
return None
|
||||||
except exceptions.AmbiguousEndpoints:
|
except exceptions.AmbiguousEndpoints:
|
||||||
@@ -219,8 +219,8 @@ class HTTPClient(httplib2.Http):
|
|||||||
# TODO(sandy): Assume admin endpoint is 35357 for now.
|
# TODO(sandy): Assume admin endpoint is 35357 for now.
|
||||||
# Ideally this is going to have to be provided by the service catalog.
|
# Ideally this is going to have to be provided by the service catalog.
|
||||||
new_netloc = netloc.replace(':%d' % port, ':%d' % (35357,))
|
new_netloc = netloc.replace(':%d' % port, ':%d' % (35357,))
|
||||||
admin_url = urlparse.urlunsplit(
|
admin_url = urlparse.urlunsplit((scheme, new_netloc,
|
||||||
(scheme, new_netloc, path, query, frag))
|
path, query, frag))
|
||||||
|
|
||||||
auth_url = self.auth_url
|
auth_url = self.auth_url
|
||||||
if self.version == "v2.0":
|
if self.version == "v2.0":
|
||||||
@@ -277,8 +277,8 @@ class HTTPClient(httplib2.Http):
|
|||||||
def _v2_auth(self, url):
|
def _v2_auth(self, url):
|
||||||
"""Authenticate against a v2.0 auth service."""
|
"""Authenticate against a v2.0 auth service."""
|
||||||
body = {"auth": {
|
body = {"auth": {
|
||||||
"passwordCredentials": {"username": self.user,
|
"passwordCredentials": {"username": self.user,
|
||||||
"password": self.password}}}
|
"password": self.password}}}
|
||||||
|
|
||||||
if self.projectid:
|
if self.projectid:
|
||||||
body['auth']['tenantName'] = self.projectid
|
body['auth']['tenantName'] = self.projectid
|
||||||
@@ -289,9 +289,9 @@ class HTTPClient(httplib2.Http):
|
|||||||
"""Authenticate against the Rackspace auth service."""
|
"""Authenticate against the Rackspace auth service."""
|
||||||
body = {"auth": {
|
body = {"auth": {
|
||||||
"RAX-KSKEY:apiKeyCredentials": {
|
"RAX-KSKEY:apiKeyCredentials": {
|
||||||
"username": self.user,
|
"username": self.user,
|
||||||
"apiKey": self.password,
|
"apiKey": self.password,
|
||||||
"tenantName": self.projectid}}}
|
"tenantName": self.projectid}}}
|
||||||
|
|
||||||
self._authenticate(url, body)
|
self._authenticate(url, body)
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ def get_client_class(version):
|
|||||||
client_path = version_map[str(version)]
|
client_path = version_map[str(version)]
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
msg = "Invalid client version '%s'. must be one of: %s" % (
|
msg = "Invalid client version '%s'. must be one of: %s" % (
|
||||||
(version, ', '.join(version_map.keys())))
|
(version, ', '.join(version_map.keys())))
|
||||||
raise exceptions.UnsupportedVersion(msg)
|
raise exceptions.UnsupportedVersion(msg)
|
||||||
|
|
||||||
return utils.import_class(client_path)
|
return utils.import_class(client_path)
|
||||||
|
|||||||
@@ -117,7 +117,8 @@ class HTTPNotImplemented(ClientException):
|
|||||||
#
|
#
|
||||||
# Instead, we have to hardcode it:
|
# Instead, we have to hardcode it:
|
||||||
_code_map = dict((c.http_status, c) for c in [BadRequest, Unauthorized,
|
_code_map = dict((c.http_status, c) for c in [BadRequest, Unauthorized,
|
||||||
Forbidden, NotFound, OverLimit, HTTPNotImplemented])
|
Forbidden, NotFound,
|
||||||
|
OverLimit, HTTPNotImplemented])
|
||||||
|
|
||||||
|
|
||||||
def from_response(response, body):
|
def from_response(response, body):
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ class ServiceCatalog(object):
|
|||||||
return self.catalog['access']['token']['id']
|
return self.catalog['access']['token']['id']
|
||||||
|
|
||||||
def url_for(self, attr=None, filter_value=None,
|
def url_for(self, attr=None, filter_value=None,
|
||||||
service_type=None, endpoint_type='publicURL',
|
service_type=None, endpoint_type='publicURL',
|
||||||
service_name=None, volume_service_name=None):
|
service_name=None, volume_service_name=None):
|
||||||
"""Fetch the public URL from the Compute service for
|
"""Fetch the public URL from the Compute service for
|
||||||
a particular endpoint attribute. If none given, return
|
a particular endpoint attribute. If none given, return
|
||||||
the first. See tests for sample service catalog."""
|
the first. See tests for sample service catalog."""
|
||||||
@@ -72,6 +72,6 @@ class ServiceCatalog(object):
|
|||||||
raise cinderclient.exceptions.EndpointNotFound()
|
raise cinderclient.exceptions.EndpointNotFound()
|
||||||
elif len(matching_endpoints) > 1:
|
elif len(matching_endpoints) > 1:
|
||||||
raise cinderclient.exceptions.AmbiguousEndpoints(
|
raise cinderclient.exceptions.AmbiguousEndpoints(
|
||||||
endpoints=matching_endpoints)
|
endpoints=matching_endpoints)
|
||||||
else:
|
else:
|
||||||
return matching_endpoints[0][endpoint_type]
|
return matching_endpoints[0][endpoint_type]
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class OpenStackCinderShell(object):
|
|||||||
parser = CinderClientArgumentParser(
|
parser = CinderClientArgumentParser(
|
||||||
prog='cinder',
|
prog='cinder',
|
||||||
description=__doc__.strip(),
|
description=__doc__.strip(),
|
||||||
epilog='See "cinder help COMMAND" '\
|
epilog='See "cinder help COMMAND" '
|
||||||
'for help on a specific command.',
|
'for help on a specific command.',
|
||||||
add_help=False,
|
add_help=False,
|
||||||
formatter_class=OpenStackHelpFormatter,
|
formatter_class=OpenStackHelpFormatter,
|
||||||
@@ -77,87 +77,93 @@ class OpenStackCinderShell(object):
|
|||||||
|
|
||||||
# Global arguments
|
# Global arguments
|
||||||
parser.add_argument('-h', '--help',
|
parser.add_argument('-h', '--help',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help=argparse.SUPPRESS,
|
help=argparse.SUPPRESS)
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_argument('--debug',
|
parser.add_argument('--debug',
|
||||||
default=False,
|
default=False,
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Print debugging output")
|
help="Print debugging output")
|
||||||
|
|
||||||
parser.add_argument('--os_username',
|
parser.add_argument('--os_username',
|
||||||
default=utils.env('OS_USERNAME', 'CINDER_USERNAME'),
|
default=utils.env('OS_USERNAME',
|
||||||
help='Defaults to env[OS_USERNAME].')
|
'CINDER_USERNAME'),
|
||||||
|
help='Defaults to env[OS_USERNAME].')
|
||||||
|
|
||||||
parser.add_argument('--os_password',
|
parser.add_argument('--os_password',
|
||||||
default=utils.env('OS_PASSWORD', 'CINDER_PASSWORD'),
|
default=utils.env('OS_PASSWORD',
|
||||||
help='Defaults to env[OS_PASSWORD].')
|
'CINDER_PASSWORD'),
|
||||||
|
help='Defaults to env[OS_PASSWORD].')
|
||||||
|
|
||||||
parser.add_argument('--os_tenant_name',
|
parser.add_argument('--os_tenant_name',
|
||||||
default=utils.env('OS_TENANT_NAME', 'CINDER_PROJECT_ID'),
|
default=utils.env('OS_TENANT_NAME',
|
||||||
help='Defaults to env[OS_TENANT_NAME].')
|
'CINDER_PROJECT_ID'),
|
||||||
|
help='Defaults to env[OS_TENANT_NAME].')
|
||||||
|
|
||||||
parser.add_argument('--os_auth_url',
|
parser.add_argument('--os_auth_url',
|
||||||
default=utils.env('OS_AUTH_URL', 'CINDER_URL'),
|
default=utils.env('OS_AUTH_URL',
|
||||||
help='Defaults to env[OS_AUTH_URL].')
|
'CINDER_URL'),
|
||||||
|
help='Defaults to env[OS_AUTH_URL].')
|
||||||
|
|
||||||
parser.add_argument('--os_region_name',
|
parser.add_argument('--os_region_name',
|
||||||
default=utils.env('OS_REGION_NAME', 'CINDER_REGION_NAME'),
|
default=utils.env('OS_REGION_NAME',
|
||||||
help='Defaults to env[OS_REGION_NAME].')
|
'CINDER_REGION_NAME'),
|
||||||
|
help='Defaults to env[OS_REGION_NAME].')
|
||||||
|
|
||||||
parser.add_argument('--service_type',
|
parser.add_argument('--service_type',
|
||||||
help='Defaults to compute for most actions')
|
help='Defaults to compute for most actions')
|
||||||
|
|
||||||
parser.add_argument('--service_name',
|
parser.add_argument('--service_name',
|
||||||
default=utils.env('CINDER_SERVICE_NAME'),
|
default=utils.env('CINDER_SERVICE_NAME'),
|
||||||
help='Defaults to env[CINDER_SERVICE_NAME]')
|
help='Defaults to env[CINDER_SERVICE_NAME]')
|
||||||
|
|
||||||
parser.add_argument('--volume_service_name',
|
parser.add_argument('--volume_service_name',
|
||||||
default=utils.env('CINDER_VOLUME_SERVICE_NAME'),
|
default=utils.env('CINDER_VOLUME_SERVICE_NAME'),
|
||||||
help='Defaults to env[CINDER_VOLUME_SERVICE_NAME]')
|
help='Defaults to env[CINDER_VOLUME_SERVICE_NAME]')
|
||||||
|
|
||||||
parser.add_argument('--endpoint_type',
|
parser.add_argument('--endpoint_type',
|
||||||
default=utils.env('CINDER_ENDPOINT_TYPE',
|
default=utils.env('CINDER_ENDPOINT_TYPE',
|
||||||
default=DEFAULT_CINDER_ENDPOINT_TYPE),
|
default=DEFAULT_CINDER_ENDPOINT_TYPE),
|
||||||
help='Defaults to env[CINDER_ENDPOINT_TYPE] or '
|
help='Defaults to env[CINDER_ENDPOINT_TYPE] or '
|
||||||
+ DEFAULT_CINDER_ENDPOINT_TYPE + '.')
|
+ DEFAULT_CINDER_ENDPOINT_TYPE + '.')
|
||||||
|
|
||||||
parser.add_argument('--os_volume_api_version',
|
parser.add_argument('--os_volume_api_version',
|
||||||
default=utils.env('OS_VOLUME_API_VERSION',
|
default=utils.env('OS_VOLUME_API_VERSION',
|
||||||
default=DEFAULT_OS_VOLUME_API_VERSION),
|
default=DEFAULT_OS_VOLUME_API_VERSION),
|
||||||
help='Accepts 1, defaults to env[OS_VOLUME_API_VERSION].')
|
help='Accepts 1,defaults '
|
||||||
|
'to env[OS_VOLUME_API_VERSION].')
|
||||||
|
|
||||||
parser.add_argument('--insecure',
|
parser.add_argument('--insecure',
|
||||||
default=utils.env('CINDERCLIENT_INSECURE', default=False),
|
default=utils.env('CINDERCLIENT_INSECURE',
|
||||||
action='store_true',
|
default=False),
|
||||||
help=argparse.SUPPRESS)
|
action='store_true',
|
||||||
|
help=argparse.SUPPRESS)
|
||||||
|
|
||||||
# FIXME(dtroyer): The args below are here for diablo compatibility,
|
# FIXME(dtroyer): The args below are here for diablo compatibility,
|
||||||
# remove them in folsum cycle
|
# remove them in folsum cycle
|
||||||
|
|
||||||
# alias for --os_username, left in for backwards compatibility
|
# alias for --os_username, left in for backwards compatibility
|
||||||
parser.add_argument('--username',
|
parser.add_argument('--username',
|
||||||
help='Deprecated')
|
help='Deprecated')
|
||||||
|
|
||||||
# alias for --os_region_name, left in for backwards compatibility
|
# alias for --os_region_name, left in for backwards compatibility
|
||||||
parser.add_argument('--region_name',
|
parser.add_argument('--region_name',
|
||||||
help='Deprecated')
|
help='Deprecated')
|
||||||
|
|
||||||
# alias for --os_password, left in for backwards compatibility
|
# alias for --os_password, left in for backwards compatibility
|
||||||
parser.add_argument('--apikey', '--password', dest='apikey',
|
parser.add_argument('--apikey', '--password', dest='apikey',
|
||||||
default=utils.env('CINDER_API_KEY'),
|
default=utils.env('CINDER_API_KEY'),
|
||||||
help='Deprecated')
|
help='Deprecated')
|
||||||
|
|
||||||
# alias for --os_tenant_name, left in for backward compatibility
|
# alias for --os_tenant_name, left in for backward compatibility
|
||||||
parser.add_argument('--projectid', '--tenant_name', dest='projectid',
|
parser.add_argument('--projectid', '--tenant_name', dest='projectid',
|
||||||
default=utils.env('CINDER_PROJECT_ID'),
|
default=utils.env('CINDER_PROJECT_ID'),
|
||||||
help='Deprecated')
|
help='Deprecated')
|
||||||
|
|
||||||
# alias for --os_auth_url, left in for backward compatibility
|
# alias for --os_auth_url, left in for backward compatibility
|
||||||
parser.add_argument('--url', '--auth_url', dest='url',
|
parser.add_argument('--url', '--auth_url', dest='url',
|
||||||
default=utils.env('CINDER_URL'),
|
default=utils.env('CINDER_URL'),
|
||||||
help='Deprecated')
|
help='Deprecated')
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@@ -222,10 +228,11 @@ class OpenStackCinderShell(object):
|
|||||||
yield name, module
|
yield name, module
|
||||||
|
|
||||||
def _add_bash_completion_subparser(self, subparsers):
|
def _add_bash_completion_subparser(self, subparsers):
|
||||||
subparser = subparsers.add_parser('bash_completion',
|
subparser = subparsers.add_parser(
|
||||||
|
'bash_completion',
|
||||||
add_help=False,
|
add_help=False,
|
||||||
formatter_class=OpenStackHelpFormatter
|
formatter_class=OpenStackHelpFormatter)
|
||||||
)
|
|
||||||
self.subcommands['bash_completion'] = subparser
|
self.subcommands['bash_completion'] = subparser
|
||||||
subparser.set_defaults(func=self.do_bash_completion)
|
subparser.set_defaults(func=self.do_bash_completion)
|
||||||
|
|
||||||
@@ -238,16 +245,17 @@ class OpenStackCinderShell(object):
|
|||||||
help = desc.strip().split('\n')[0]
|
help = desc.strip().split('\n')[0]
|
||||||
arguments = getattr(callback, 'arguments', [])
|
arguments = getattr(callback, 'arguments', [])
|
||||||
|
|
||||||
subparser = subparsers.add_parser(command,
|
subparser = subparsers.add_parser(
|
||||||
|
command,
|
||||||
help=help,
|
help=help,
|
||||||
description=desc,
|
description=desc,
|
||||||
add_help=False,
|
add_help=False,
|
||||||
formatter_class=OpenStackHelpFormatter
|
formatter_class=OpenStackHelpFormatter)
|
||||||
)
|
|
||||||
subparser.add_argument('-h', '--help',
|
subparser.add_argument('-h', '--help',
|
||||||
action='help',
|
action='help',
|
||||||
help=argparse.SUPPRESS,
|
help=argparse.SUPPRESS,)
|
||||||
)
|
|
||||||
self.subcommands[command] = subparser
|
self.subcommands[command] = subparser
|
||||||
for (args, kwargs) in arguments:
|
for (args, kwargs) in arguments:
|
||||||
subparser.add_argument(*args, **kwargs)
|
subparser.add_argument(*args, **kwargs)
|
||||||
@@ -273,11 +281,11 @@ class OpenStackCinderShell(object):
|
|||||||
|
|
||||||
# build available subcommands based on version
|
# build available subcommands based on version
|
||||||
self.extensions = self._discover_extensions(
|
self.extensions = self._discover_extensions(
|
||||||
options.os_volume_api_version)
|
options.os_volume_api_version)
|
||||||
self._run_extension_hooks('__pre_parse_args__')
|
self._run_extension_hooks('__pre_parse_args__')
|
||||||
|
|
||||||
subcommand_parser = self.get_subcommand_parser(
|
subcommand_parser = self.get_subcommand_parser(
|
||||||
options.os_volume_api_version)
|
options.os_volume_api_version)
|
||||||
self.parser = subcommand_parser
|
self.parser = subcommand_parser
|
||||||
|
|
||||||
if options.help and len(args) == 0:
|
if options.help and len(args) == 0:
|
||||||
@@ -296,16 +304,16 @@ class OpenStackCinderShell(object):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
(os_username, os_password, os_tenant_name, os_auth_url,
|
(os_username, os_password, os_tenant_name, os_auth_url,
|
||||||
os_region_name, endpoint_type, insecure,
|
os_region_name, endpoint_type, insecure,
|
||||||
service_type, service_name, volume_service_name,
|
service_type, service_name, volume_service_name,
|
||||||
username, apikey, projectid, url, region_name) = (
|
username, apikey, projectid, url, region_name) = (
|
||||||
args.os_username, args.os_password,
|
args.os_username, args.os_password,
|
||||||
args.os_tenant_name, args.os_auth_url,
|
args.os_tenant_name, args.os_auth_url,
|
||||||
args.os_region_name, args.endpoint_type,
|
args.os_region_name, args.endpoint_type,
|
||||||
args.insecure, args.service_type, args.service_name,
|
args.insecure, args.service_type, args.service_name,
|
||||||
args.volume_service_name, args.username,
|
args.volume_service_name, args.username,
|
||||||
args.apikey, args.projectid,
|
args.apikey, args.projectid,
|
||||||
args.url, args.region_name)
|
args.url, args.region_name)
|
||||||
|
|
||||||
if not endpoint_type:
|
if not endpoint_type:
|
||||||
endpoint_type = DEFAULT_CINDER_ENDPOINT_TYPE
|
endpoint_type = DEFAULT_CINDER_ENDPOINT_TYPE
|
||||||
@@ -320,31 +328,33 @@ class OpenStackCinderShell(object):
|
|||||||
if not utils.isunauthenticated(args.func):
|
if not utils.isunauthenticated(args.func):
|
||||||
if not os_username:
|
if not os_username:
|
||||||
if not username:
|
if not username:
|
||||||
raise exc.CommandError("You must provide a username "
|
raise exc.CommandError(
|
||||||
"via either --os_username or env[OS_USERNAME]")
|
"You must provide a username "
|
||||||
|
"via either --os_username or env[OS_USERNAME]")
|
||||||
else:
|
else:
|
||||||
os_username = username
|
os_username = username
|
||||||
|
|
||||||
if not os_password:
|
if not os_password:
|
||||||
if not apikey:
|
if not apikey:
|
||||||
raise exc.CommandError("You must provide a password "
|
raise exc.CommandError("You must provide a password "
|
||||||
"via either --os_password or via "
|
"via either --os_password or via "
|
||||||
"env[OS_PASSWORD]")
|
"env[OS_PASSWORD]")
|
||||||
else:
|
else:
|
||||||
os_password = apikey
|
os_password = apikey
|
||||||
|
|
||||||
if not os_tenant_name:
|
if not os_tenant_name:
|
||||||
if not projectid:
|
if not projectid:
|
||||||
raise exc.CommandError("You must provide a tenant name "
|
raise exc.CommandError("You must provide a tenant name "
|
||||||
"via either --os_tenant_name or "
|
"via either --os_tenant_name or "
|
||||||
"env[OS_TENANT_NAME]")
|
"env[OS_TENANT_NAME]")
|
||||||
else:
|
else:
|
||||||
os_tenant_name = projectid
|
os_tenant_name = projectid
|
||||||
|
|
||||||
if not os_auth_url:
|
if not os_auth_url:
|
||||||
if not url:
|
if not url:
|
||||||
raise exc.CommandError("You must provide an auth url "
|
raise exc.CommandError(
|
||||||
"via either --os_auth_url or env[OS_AUTH_URL]")
|
"You must provide an auth url "
|
||||||
|
"via either --os_auth_url or env[OS_AUTH_URL]")
|
||||||
else:
|
else:
|
||||||
os_auth_url = url
|
os_auth_url = url
|
||||||
|
|
||||||
@@ -352,19 +362,23 @@ class OpenStackCinderShell(object):
|
|||||||
os_region_name = region_name
|
os_region_name = region_name
|
||||||
|
|
||||||
if not os_tenant_name:
|
if not os_tenant_name:
|
||||||
raise exc.CommandError("You must provide a tenant name "
|
raise exc.CommandError(
|
||||||
"via either --os_tenant_name or env[OS_TENANT_NAME]")
|
"You must provide a tenant name "
|
||||||
|
"via either --os_tenant_name or env[OS_TENANT_NAME]")
|
||||||
|
|
||||||
if not os_auth_url:
|
if not os_auth_url:
|
||||||
raise exc.CommandError("You must provide an auth url "
|
raise exc.CommandError(
|
||||||
"via either --os_auth_url or env[OS_AUTH_URL]")
|
"You must provide an auth url "
|
||||||
|
"via either --os_auth_url or env[OS_AUTH_URL]")
|
||||||
|
|
||||||
self.cs = client.Client(options.os_volume_api_version, os_username,
|
self.cs = client.Client(options.os_volume_api_version, os_username,
|
||||||
os_password, os_tenant_name, os_auth_url, insecure,
|
os_password, os_tenant_name, os_auth_url,
|
||||||
region_name=os_region_name, endpoint_type=endpoint_type,
|
insecure, region_name=os_region_name,
|
||||||
extensions=self.extensions, service_type=service_type,
|
endpoint_type=endpoint_type,
|
||||||
service_name=service_name,
|
extensions=self.extensions,
|
||||||
volume_service_name=volume_service_name)
|
service_type=service_type,
|
||||||
|
service_name=service_name,
|
||||||
|
volume_service_name=volume_service_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not utils.isunauthenticated(args.func):
|
if not utils.isunauthenticated(args.func):
|
||||||
@@ -398,7 +412,7 @@ class OpenStackCinderShell(object):
|
|||||||
print ' '.join(commands | options)
|
print ' '.join(commands | options)
|
||||||
|
|
||||||
@utils.arg('command', metavar='<subcommand>', nargs='?',
|
@utils.arg('command', metavar='<subcommand>', nargs='?',
|
||||||
help='Display help for <subcommand>')
|
help='Display help for <subcommand>')
|
||||||
def do_help(self, args):
|
def do_help(self, args):
|
||||||
"""
|
"""
|
||||||
Display help about this program or one of its subcommands.
|
Display help about this program or one of its subcommands.
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ class Client(object):
|
|||||||
|
|
||||||
# FIXME(jesse): project_id isn't required to authenticate
|
# FIXME(jesse): project_id isn't required to authenticate
|
||||||
def __init__(self, username, api_key, project_id, auth_url,
|
def __init__(self, username, api_key, project_id, auth_url,
|
||||||
insecure=False, timeout=None, proxy_tenant_id=None,
|
insecure=False, timeout=None, proxy_tenant_id=None,
|
||||||
proxy_token=None, region_name=None,
|
proxy_token=None, region_name=None,
|
||||||
endpoint_type='publicURL', extensions=None,
|
endpoint_type='publicURL', extensions=None,
|
||||||
service_type='compute', service_name=None,
|
service_type='compute', service_name=None,
|
||||||
volume_service_name=None):
|
volume_service_name=None):
|
||||||
# FIXME(comstud): Rename the api_key argument above when we
|
# FIXME(comstud): Rename the api_key argument above when we
|
||||||
# know it's not being used as keyword argument
|
# know it's not being used as keyword argument
|
||||||
password = api_key
|
password = api_key
|
||||||
@@ -44,19 +44,20 @@ class Client(object):
|
|||||||
setattr(self, extension.name,
|
setattr(self, extension.name,
|
||||||
extension.manager_class(self))
|
extension.manager_class(self))
|
||||||
|
|
||||||
self.client = client.HTTPClient(username,
|
self.client = client.HTTPClient(
|
||||||
password,
|
username,
|
||||||
project_id,
|
password,
|
||||||
auth_url,
|
project_id,
|
||||||
insecure=insecure,
|
auth_url,
|
||||||
timeout=timeout,
|
insecure=insecure,
|
||||||
proxy_token=proxy_token,
|
timeout=timeout,
|
||||||
proxy_tenant_id=proxy_tenant_id,
|
proxy_token=proxy_token,
|
||||||
region_name=region_name,
|
proxy_tenant_id=proxy_tenant_id,
|
||||||
endpoint_type=endpoint_type,
|
region_name=region_name,
|
||||||
service_type=service_type,
|
endpoint_type=endpoint_type,
|
||||||
service_name=service_name,
|
service_type=service_type,
|
||||||
volume_service_name=volume_service_name)
|
service_name=service_name,
|
||||||
|
volume_service_name=volume_service_name)
|
||||||
|
|
||||||
def authenticate(self):
|
def authenticate(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ def do_list(cs, args):
|
|||||||
servers = [s.get('server_id') for s in vol.attachments]
|
servers = [s.get('server_id') for s in vol.attachments]
|
||||||
setattr(vol, 'attached_to', ','.join(map(str, servers)))
|
setattr(vol, 'attached_to', ','.join(map(str, servers)))
|
||||||
utils.print_list(volumes, ['ID', 'Status', 'Display Name',
|
utils.print_list(volumes, ['ID', 'Status', 'Display Name',
|
||||||
'Size', 'Volume Type', 'Attached to'])
|
'Size', 'Volume Type', 'Attached to'])
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume', metavar='<volume>', help='ID of the volume.')
|
@utils.arg('volume', metavar='<volume>', help='ID of the volume.')
|
||||||
@@ -112,31 +112,32 @@ def do_show(cs, args):
|
|||||||
|
|
||||||
|
|
||||||
@utils.arg('size',
|
@utils.arg('size',
|
||||||
metavar='<size>',
|
metavar='<size>',
|
||||||
type=int,
|
type=int,
|
||||||
help='Size of volume in GB')
|
help='Size of volume in GB')
|
||||||
@utils.arg('--snapshot_id',
|
@utils.arg(
|
||||||
|
'--snapshot_id',
|
||||||
metavar='<snapshot_id>',
|
metavar='<snapshot_id>',
|
||||||
help='Optional snapshot id to create the volume from. (Default=None)',
|
help='Optional snapshot id to create the volume from. (Default=None)',
|
||||||
default=None)
|
default=None)
|
||||||
@utils.arg('--display_name', metavar='<display_name>',
|
@utils.arg('--display_name', metavar='<display_name>',
|
||||||
help='Optional volume name. (Default=None)',
|
help='Optional volume name. (Default=None)',
|
||||||
default=None)
|
default=None)
|
||||||
@utils.arg('--display_description', metavar='<display_description>',
|
@utils.arg('--display_description', metavar='<display_description>',
|
||||||
help='Optional volume description. (Default=None)',
|
help='Optional volume description. (Default=None)',
|
||||||
default=None)
|
default=None)
|
||||||
@utils.arg('--volume_type',
|
@utils.arg('--volume_type',
|
||||||
metavar='<volume_type>',
|
metavar='<volume_type>',
|
||||||
help='Optional volume type. (Default=None)',
|
help='Optional volume type. (Default=None)',
|
||||||
default=None)
|
default=None)
|
||||||
@utils.service_type('volume')
|
@utils.service_type('volume')
|
||||||
def do_create(cs, args):
|
def do_create(cs, args):
|
||||||
"""Add a new volume."""
|
"""Add a new volume."""
|
||||||
cs.volumes.create(args.size,
|
cs.volumes.create(args.size,
|
||||||
args.snapshot_id,
|
args.snapshot_id,
|
||||||
args.display_name,
|
args.display_name,
|
||||||
args.display_description,
|
args.display_description,
|
||||||
args.volume_type)
|
args.volume_type)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume', metavar='<volume>', help='ID of the volume to delete.')
|
@utils.arg('volume', metavar='<volume>', help='ID of the volume to delete.')
|
||||||
@@ -152,8 +153,8 @@ def do_snapshot_list(cs, args):
|
|||||||
"""List all the snapshots."""
|
"""List all the snapshots."""
|
||||||
snapshots = cs.volume_snapshots.list()
|
snapshots = cs.volume_snapshots.list()
|
||||||
_translate_volume_snapshot_keys(snapshots)
|
_translate_volume_snapshot_keys(snapshots)
|
||||||
utils.print_list(snapshots, ['ID', 'Volume ID', 'Status', 'Display Name',
|
utils.print_list(snapshots,
|
||||||
'Size'])
|
['ID', 'Volume ID', 'Status', 'Display Name', 'Size'])
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('snapshot', metavar='<snapshot>', help='ID of the snapshot.')
|
@utils.arg('snapshot', metavar='<snapshot>', help='ID of the snapshot.')
|
||||||
@@ -165,31 +166,32 @@ def do_snapshot_show(cs, args):
|
|||||||
|
|
||||||
|
|
||||||
@utils.arg('volume_id',
|
@utils.arg('volume_id',
|
||||||
metavar='<volume_id>',
|
metavar='<volume_id>',
|
||||||
help='ID of the volume to snapshot')
|
help='ID of the volume to snapshot')
|
||||||
@utils.arg('--force',
|
@utils.arg('--force',
|
||||||
metavar='<True|False>',
|
metavar='<True|False>',
|
||||||
help='Optional flag to indicate whether to snapshot a volume even if its '
|
help='Optional flag to indicate whether '
|
||||||
'attached to an instance. (Default=False)',
|
'to snapshot a volume even if its '
|
||||||
default=False)
|
'attached to an instance. (Default=False)',
|
||||||
|
default=False)
|
||||||
@utils.arg('--display_name', metavar='<display_name>',
|
@utils.arg('--display_name', metavar='<display_name>',
|
||||||
help='Optional snapshot name. (Default=None)',
|
help='Optional snapshot name. (Default=None)',
|
||||||
default=None)
|
default=None)
|
||||||
@utils.arg('--display_description', metavar='<display_description>',
|
@utils.arg('--display_description', metavar='<display_description>',
|
||||||
help='Optional snapshot description. (Default=None)',
|
help='Optional snapshot description. (Default=None)',
|
||||||
default=None)
|
default=None)
|
||||||
@utils.service_type('volume')
|
@utils.service_type('volume')
|
||||||
def do_snapshot_create(cs, args):
|
def do_snapshot_create(cs, args):
|
||||||
"""Add a new snapshot."""
|
"""Add a new snapshot."""
|
||||||
cs.volume_snapshots.create(args.volume_id,
|
cs.volume_snapshots.create(args.volume_id,
|
||||||
args.force,
|
args.force,
|
||||||
args.display_name,
|
args.display_name,
|
||||||
args.display_description)
|
args.display_description)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('snapshot_id',
|
@utils.arg('snapshot_id',
|
||||||
metavar='<snapshot_id>',
|
metavar='<snapshot_id>',
|
||||||
help='ID of the snapshot to delete.')
|
help='ID of the snapshot to delete.')
|
||||||
@utils.service_type('volume')
|
@utils.service_type('volume')
|
||||||
def do_snapshot_delete(cs, args):
|
def do_snapshot_delete(cs, args):
|
||||||
"""Remove a snapshot."""
|
"""Remove a snapshot."""
|
||||||
@@ -209,8 +211,8 @@ def do_type_list(cs, args):
|
|||||||
|
|
||||||
|
|
||||||
@utils.arg('name',
|
@utils.arg('name',
|
||||||
metavar='<name>',
|
metavar='<name>',
|
||||||
help="Name of the new flavor")
|
help="Name of the new flavor")
|
||||||
@utils.service_type('volume')
|
@utils.service_type('volume')
|
||||||
def do_type_create(cs, args):
|
def do_type_create(cs, args):
|
||||||
"""Create a new volume type."""
|
"""Create a new volume type."""
|
||||||
@@ -219,8 +221,8 @@ def do_type_create(cs, args):
|
|||||||
|
|
||||||
|
|
||||||
@utils.arg('id',
|
@utils.arg('id',
|
||||||
metavar='<id>',
|
metavar='<id>',
|
||||||
help="Unique ID of the volume type to delete")
|
help="Unique ID of the volume type to delete")
|
||||||
@utils.service_type('volume')
|
@utils.service_type('volume')
|
||||||
def do_type_delete(cs, args):
|
def do_type_delete(cs, args):
|
||||||
"""Delete a specific flavor"""
|
"""Delete a specific flavor"""
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SnapshotManager(base.ManagerWithFind):
|
|||||||
resource_class = Snapshot
|
resource_class = Snapshot
|
||||||
|
|
||||||
def create(self, volume_id, force=False,
|
def create(self, volume_id, force=False,
|
||||||
display_name=None, display_description=None):
|
display_name=None, display_description=None):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Create a snapshot of the given volume.
|
Create a snapshot of the given volume.
|
||||||
@@ -54,9 +54,9 @@ class SnapshotManager(base.ManagerWithFind):
|
|||||||
:rtype: :class:`Snapshot`
|
:rtype: :class:`Snapshot`
|
||||||
"""
|
"""
|
||||||
body = {'snapshot': {'volume_id': volume_id,
|
body = {'snapshot': {'volume_id': volume_id,
|
||||||
'force': force,
|
'force': force,
|
||||||
'display_name': display_name,
|
'display_name': display_name,
|
||||||
'display_description': display_description}}
|
'display_description': display_description}}
|
||||||
return self._create('/snapshots', body, 'snapshot')
|
return self._create('/snapshots', body, 'snapshot')
|
||||||
|
|
||||||
def get(self, snapshot_id):
|
def get(self, snapshot_id):
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
resource_class = Volume
|
resource_class = Volume
|
||||||
|
|
||||||
def create(self, size, snapshot_id=None,
|
def create(self, size, snapshot_id=None,
|
||||||
display_name=None, display_description=None,
|
display_name=None, display_description=None,
|
||||||
volume_type=None):
|
volume_type=None):
|
||||||
"""
|
"""
|
||||||
Create a volume.
|
Create a volume.
|
||||||
|
|
||||||
@@ -54,10 +54,10 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
:rtype: :class:`Volume`
|
:rtype: :class:`Volume`
|
||||||
"""
|
"""
|
||||||
body = {'volume': {'size': size,
|
body = {'volume': {'size': size,
|
||||||
'snapshot_id': snapshot_id,
|
'snapshot_id': snapshot_id,
|
||||||
'display_name': display_name,
|
'display_name': display_name,
|
||||||
'display_description': display_description,
|
'display_description': display_description,
|
||||||
'volume_type': volume_type}}
|
'volume_type': volume_type}}
|
||||||
return self._create('/volumes', body, 'volume')
|
return self._create('/volumes', body, 'volume')
|
||||||
|
|
||||||
def get(self, volume_id):
|
def get(self, volume_id):
|
||||||
@@ -98,9 +98,9 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
:rtype: :class:`Volume`
|
:rtype: :class:`Volume`
|
||||||
"""
|
"""
|
||||||
body = {'volumeAttachment': {'volumeId': volume_id,
|
body = {'volumeAttachment': {'volumeId': volume_id,
|
||||||
'device': device}}
|
'device': device}}
|
||||||
return self._create("/servers/%s/os-volume_attachments" % server_id,
|
return self._create("/servers/%s/os-volume_attachments" % server_id,
|
||||||
body, "volumeAttachment")
|
body, "volumeAttachment")
|
||||||
|
|
||||||
def get_server_volume(self, server_id, attachment_id):
|
def get_server_volume(self, server_id, attachment_id):
|
||||||
"""
|
"""
|
||||||
@@ -112,7 +112,7 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
:rtype: :class:`Volume`
|
:rtype: :class:`Volume`
|
||||||
"""
|
"""
|
||||||
return self._get("/servers/%s/os-volume_attachments/%s" % (server_id,
|
return self._get("/servers/%s/os-volume_attachments/%s" % (server_id,
|
||||||
attachment_id,), "volumeAttachment")
|
attachment_id,), "volumeAttachment")
|
||||||
|
|
||||||
def get_server_volumes(self, server_id):
|
def get_server_volumes(self, server_id):
|
||||||
"""
|
"""
|
||||||
@@ -122,7 +122,7 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
:rtype: list of :class:`Volume`
|
:rtype: list of :class:`Volume`
|
||||||
"""
|
"""
|
||||||
return self._list("/servers/%s/os-volume_attachments" % server_id,
|
return self._list("/servers/%s/os-volume_attachments" % server_id,
|
||||||
"volumeAttachments")
|
"volumeAttachments")
|
||||||
|
|
||||||
def delete_server_volume(self, server_id, attachment_id):
|
def delete_server_volume(self, server_id, attachment_id):
|
||||||
"""
|
"""
|
||||||
@@ -132,4 +132,4 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
:param attachment_id: The ID of the attachment
|
:param attachment_id: The ID of the attachment
|
||||||
"""
|
"""
|
||||||
self._delete("/servers/%s/os-volume_attachments/%s" %
|
self._delete("/servers/%s/os-volume_attachments/%s" %
|
||||||
(server_id, attachment_id,))
|
(server_id, attachment_id,))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# python-cinderclient documentation build configuration file, created by
|
# python-cinderclient documentation build configuration file, created by
|
||||||
# sphinx-quickstart on Sun Dec 6 14:19:25 2009.
|
# sphinx-quickstart on Sun Dec 6 14:19:25 2009.
|
||||||
#
|
#
|
||||||
# This file is execfile()d with the current directory set to its containing dir.
|
# This file is execfile()d with current directory set to its containing dir.
|
||||||
#
|
#
|
||||||
# Note that not all possible configuration values are present in this
|
# Note that not all possible configuration values are present in this
|
||||||
# autogenerated file.
|
# autogenerated file.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ def assert_has_keys(dict, required=[], optional=[]):
|
|||||||
except AssertionError:
|
except AssertionError:
|
||||||
extra_keys = set(keys).difference(set(required + optional))
|
extra_keys = set(keys).difference(set(required + optional))
|
||||||
raise AssertionError("found unexpected keys: %s" %
|
raise AssertionError("found unexpected keys: %s" %
|
||||||
list(extra_keys))
|
list(extra_keys))
|
||||||
|
|
||||||
|
|
||||||
class FakeClient(object):
|
class FakeClient(object):
|
||||||
@@ -27,11 +27,11 @@ class FakeClient(object):
|
|||||||
expected = (method, url)
|
expected = (method, url)
|
||||||
called = self.client.callstack[pos][0:2]
|
called = self.client.callstack[pos][0:2]
|
||||||
|
|
||||||
assert self.client.callstack, \
|
assert(self.client.callstack,
|
||||||
"Expected %s %s but no calls were made." % expected
|
"Expected %s %s but no calls were made." % expected)
|
||||||
|
|
||||||
assert expected == called, 'Expected %s %s; got %s %s' % \
|
assert (expected == called, 'Expected %s %s; got %s %s' %
|
||||||
(expected + called)
|
(expected + called))
|
||||||
|
|
||||||
if body is not None:
|
if body is not None:
|
||||||
assert self.client.callstack[pos][2] == body
|
assert self.client.callstack[pos][2] == body
|
||||||
@@ -42,8 +42,8 @@ class FakeClient(object):
|
|||||||
"""
|
"""
|
||||||
expected = (method, url)
|
expected = (method, url)
|
||||||
|
|
||||||
assert self.client.callstack, \
|
assert(self.client.callstack,
|
||||||
"Expected %s %s but no calls were made." % expected
|
"Expected %s %s but no calls were made." % expected)
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
for entry in self.client.callstack:
|
for entry in self.client.callstack:
|
||||||
@@ -51,8 +51,9 @@ class FakeClient(object):
|
|||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
|
|
||||||
assert found, 'Expected %s %s; got %s' % \
|
assert(found, 'Expected %s %s; got %s' %
|
||||||
(expected, self.client.callstack)
|
(expected, self.client.callstack))
|
||||||
|
|
||||||
if body is not None:
|
if body is not None:
|
||||||
try:
|
try:
|
||||||
assert entry[2] == body
|
assert entry[2] == body
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ class ClientTest(utils.TestCase):
|
|||||||
headers = {"X-Auth-Token": "token",
|
headers = {"X-Auth-Token": "token",
|
||||||
"X-Auth-Project-Id": "project_id",
|
"X-Auth-Project-Id": "project_id",
|
||||||
"User-Agent": cl.USER_AGENT,
|
"User-Agent": cl.USER_AGENT,
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json', }
|
||||||
}
|
|
||||||
mock_request.assert_called_with("http://example.com/hi",
|
mock_request.assert_called_with("http://example.com/hi",
|
||||||
"GET", headers=headers)
|
"GET", headers=headers)
|
||||||
# Automatic JSON parsing
|
# Automatic JSON parsing
|
||||||
|
|||||||
@@ -106,9 +106,9 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
self.assertRaises(exceptions.AmbiguousEndpoints, sc.url_for,
|
self.assertRaises(exceptions.AmbiguousEndpoints, sc.url_for,
|
||||||
service_type='compute')
|
service_type='compute')
|
||||||
self.assertEquals(sc.url_for('tenantId', '1', service_type='compute'),
|
self.assertEquals(sc.url_for('tenantId', '1', service_type='compute'),
|
||||||
"https://compute1.host/v1/1234")
|
"https://compute1.host/v1/1234")
|
||||||
self.assertEquals(sc.url_for('tenantId', '2', service_type='compute'),
|
self.assertEquals(sc.url_for('tenantId', '2', service_type='compute'),
|
||||||
"https://compute1.host/v1/3456")
|
"https://compute1.host/v1/3456")
|
||||||
|
|
||||||
self.assertRaises(exceptions.EndpointNotFound, sc.url_for,
|
self.assertRaises(exceptions.EndpointNotFound, sc.url_for,
|
||||||
"region", "South", service_type='compute')
|
"region", "South", service_type='compute')
|
||||||
@@ -119,9 +119,9 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
self.assertRaises(exceptions.AmbiguousEndpoints, sc.url_for,
|
self.assertRaises(exceptions.AmbiguousEndpoints, sc.url_for,
|
||||||
service_type='volume')
|
service_type='volume')
|
||||||
self.assertEquals(sc.url_for('tenantId', '1', service_type='volume'),
|
self.assertEquals(sc.url_for('tenantId', '1', service_type='volume'),
|
||||||
"https://volume1.host/v1/1234")
|
"https://volume1.host/v1/1234")
|
||||||
self.assertEquals(sc.url_for('tenantId', '2', service_type='volume'),
|
self.assertEquals(sc.url_for('tenantId', '2', service_type='volume'),
|
||||||
"https://volume1.host/v1/3456")
|
"https://volume1.host/v1/3456")
|
||||||
|
|
||||||
self.assertRaises(exceptions.EndpointNotFound, sc.url_for,
|
self.assertRaises(exceptions.EndpointNotFound, sc.url_for,
|
||||||
"region", "North", service_type='volume')
|
"region", "North", service_type='volume')
|
||||||
|
|||||||
@@ -120,10 +120,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
"maxServerMeta": 5,
|
"maxServerMeta": 5,
|
||||||
"maxImageMeta": 5,
|
"maxImageMeta": 5,
|
||||||
"maxPersonality": 5,
|
"maxPersonality": 5,
|
||||||
"maxPersonalitySize": 10240
|
"maxPersonalitySize": 10240}, }, })
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Servers
|
# Servers
|
||||||
@@ -141,8 +138,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
return (200, {"volumes": [
|
return (200, {"volumes": [
|
||||||
{'id': 1234,
|
{'id': 1234,
|
||||||
'name': 'sample-volume',
|
'name': 'sample-volume',
|
||||||
'attachments': [{'server_id': 1234}]
|
'attachments': [{'server_id': 1234}]},
|
||||||
},
|
|
||||||
]})
|
]})
|
||||||
|
|
||||||
def get_volumes_1234(self, **kw):
|
def get_volumes_1234(self, **kw):
|
||||||
@@ -152,8 +148,8 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
def post_servers(self, body, **kw):
|
def post_servers(self, body, **kw):
|
||||||
assert set(body.keys()) <= set(['server', 'os:scheduler_hints'])
|
assert set(body.keys()) <= set(['server', 'os:scheduler_hints'])
|
||||||
fakes.assert_has_keys(body['server'],
|
fakes.assert_has_keys(body['server'],
|
||||||
required=['name', 'imageRef', 'flavorRef'],
|
required=['name', 'imageRef', 'flavorRef'],
|
||||||
optional=['metadata', 'personality'])
|
optional=['metadata', 'personality'])
|
||||||
if 'personality' in body['server']:
|
if 'personality' in body['server']:
|
||||||
for pfile in body['server']['personality']:
|
for pfile in body['server']['personality']:
|
||||||
fakes.assert_has_keys(pfile, required=['path', 'contents'])
|
fakes.assert_has_keys(pfile, required=['path', 'contents'])
|
||||||
@@ -194,18 +190,19 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
return (200, {'data': 'Fake diagnostics'})
|
return (200, {'data': 'Fake diagnostics'})
|
||||||
|
|
||||||
def get_servers_1234_actions(self, **kw):
|
def get_servers_1234_actions(self, **kw):
|
||||||
return (200, {'actions': [
|
return (
|
||||||
{
|
200, {'actions': [
|
||||||
'action': 'rebuild',
|
{
|
||||||
'error': None,
|
'action': 'rebuild',
|
||||||
'created_at': '2011-12-30 11:45:36'
|
'error': None,
|
||||||
},
|
'created_at': '2011-12-30 11:45:36'
|
||||||
{
|
},
|
||||||
'action': 'reboot',
|
{
|
||||||
'error': 'Failed!',
|
'action': 'reboot',
|
||||||
'created_at': '2011-12-30 11:40:29'
|
'error': 'Failed!',
|
||||||
},
|
'created_at': '2011-12-30 11:40:29'
|
||||||
]})
|
},
|
||||||
|
]})
|
||||||
|
|
||||||
#
|
#
|
||||||
# Server Addresses
|
# Server Addresses
|
||||||
@@ -350,8 +347,8 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
|
|
||||||
def get_os_floating_ips_1(self, **kw):
|
def get_os_floating_ips_1(self, **kw):
|
||||||
return (200, {'floating_ip':
|
return (200, {'floating_ip':
|
||||||
{'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1'}
|
{'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1'}
|
||||||
})
|
})
|
||||||
|
|
||||||
def post_os_floating_ips(self, body, **kw):
|
def post_os_floating_ips(self, body, **kw):
|
||||||
return (202, self.get_os_floating_ips_1()[1])
|
return (202, self.get_os_floating_ips_1()[1])
|
||||||
@@ -359,12 +356,12 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
def post_os_floating_ips(self, body):
|
def post_os_floating_ips(self, body):
|
||||||
if body.get('pool'):
|
if body.get('pool'):
|
||||||
return (200, {'floating_ip':
|
return (200, {'floating_ip':
|
||||||
{'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1',
|
{'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1',
|
||||||
'pool': 'cinder'}})
|
'pool': 'cinder'}})
|
||||||
else:
|
else:
|
||||||
return (200, {'floating_ip':
|
return (200, {'floating_ip':
|
||||||
{'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1',
|
{'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1',
|
||||||
'pool': None}})
|
'pool': None}})
|
||||||
|
|
||||||
def delete_os_floating_ips_1(self, **kw):
|
def delete_os_floating_ips_1(self, **kw):
|
||||||
return (204, None)
|
return (204, None)
|
||||||
@@ -378,41 +375,41 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
if kw.get('ip'):
|
if kw.get('ip'):
|
||||||
return (205, {'dns_entries':
|
return (205, {'dns_entries':
|
||||||
[{'dns_entry':
|
[{'dns_entry':
|
||||||
{'ip': kw.get('ip'),
|
{'ip': kw.get('ip'),
|
||||||
'name': "host1",
|
'name': "host1",
|
||||||
'type': "A",
|
'type': "A",
|
||||||
'domain': 'testdomain'}},
|
'domain': 'testdomain'}},
|
||||||
{'dns_entry':
|
{'dns_entry':
|
||||||
{'ip': kw.get('ip'),
|
{'ip': kw.get('ip'),
|
||||||
'name': "host2",
|
'name': "host2",
|
||||||
'type': "A",
|
'type': "A",
|
||||||
'domain': 'testdomain'}}]})
|
'domain': 'testdomain'}}]})
|
||||||
else:
|
else:
|
||||||
return (404, None)
|
return (404, None)
|
||||||
|
|
||||||
def get_os_floating_ip_dns_testdomain_entries_testname(self, **kw):
|
def get_os_floating_ip_dns_testdomain_entries_testname(self, **kw):
|
||||||
return (205, {'dns_entry':
|
return (205, {'dns_entry':
|
||||||
{'ip': "10.10.10.10",
|
{'ip': "10.10.10.10",
|
||||||
'name': 'testname',
|
'name': 'testname',
|
||||||
'type': "A",
|
'type': "A",
|
||||||
'domain': 'testdomain'}})
|
'domain': 'testdomain'}})
|
||||||
|
|
||||||
def put_os_floating_ip_dns_testdomain(self, body, **kw):
|
def put_os_floating_ip_dns_testdomain(self, body, **kw):
|
||||||
if body['domain_entry']['scope'] == 'private':
|
if body['domain_entry']['scope'] == 'private':
|
||||||
fakes.assert_has_keys(body['domain_entry'],
|
fakes.assert_has_keys(body['domain_entry'],
|
||||||
required=['availability_zone', 'scope'])
|
required=['availability_zone', 'scope'])
|
||||||
elif body['domain_entry']['scope'] == 'public':
|
elif body['domain_entry']['scope'] == 'public':
|
||||||
fakes.assert_has_keys(body['domain_entry'],
|
fakes.assert_has_keys(body['domain_entry'],
|
||||||
required=['project', 'scope'])
|
required=['project', 'scope'])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
fakes.assert_has_keys(body['domain_entry'],
|
fakes.assert_has_keys(body['domain_entry'],
|
||||||
required=['project', 'scope'])
|
required=['project', 'scope'])
|
||||||
return (205, None)
|
return (205, None)
|
||||||
|
|
||||||
def put_os_floating_ip_dns_testdomain_entries_testname(self, body, **kw):
|
def put_os_floating_ip_dns_testdomain_entries_testname(self, body, **kw):
|
||||||
fakes.assert_has_keys(body['dns_entry'],
|
fakes.assert_has_keys(body['dns_entry'],
|
||||||
required=['ip', 'dns_type'])
|
required=['ip', 'dns_type'])
|
||||||
return (205, None)
|
return (205, None)
|
||||||
|
|
||||||
def delete_os_floating_ip_dns_testdomain(self, **kw):
|
def delete_os_floating_ip_dns_testdomain(self, **kw):
|
||||||
@@ -471,7 +468,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
fakes.assert_has_keys(body['metadata'],
|
fakes.assert_has_keys(body['metadata'],
|
||||||
required=['test_key'])
|
required=['test_key'])
|
||||||
return (200,
|
return (200,
|
||||||
{'metadata': self.get_images_1()[1]['image']['metadata']})
|
{'metadata': self.get_images_1()[1]['image']['metadata']})
|
||||||
|
|
||||||
def delete_images_1(self, **kw):
|
def delete_images_1(self, **kw):
|
||||||
return (204, None)
|
return (204, None)
|
||||||
@@ -588,14 +585,16 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
# Security Groups
|
# Security Groups
|
||||||
#
|
#
|
||||||
def get_os_security_groups(self, **kw):
|
def get_os_security_groups(self, **kw):
|
||||||
return (200, {"security_groups": [
|
return (200, {"security_groups":
|
||||||
{'id': 1, 'name': 'test', 'description': 'FAKE_SECURITY_GROUP'}
|
[
|
||||||
]})
|
{'id': 1, 'name': 'test',
|
||||||
|
'description': 'FAKE_SECURITY_GROUP'}
|
||||||
|
]})
|
||||||
|
|
||||||
def get_os_security_groups_1(self, **kw):
|
def get_os_security_groups_1(self, **kw):
|
||||||
return (200, {"security_group":
|
return (200, {"security_group":
|
||||||
{'id': 1, 'name': 'test', 'description': 'FAKE_SECURITY_GROUP'}
|
{'id': 1, 'name': 'test', 'description': 'FAKE_SECURITY_GROUP'}
|
||||||
})
|
})
|
||||||
|
|
||||||
def delete_os_security_groups_1(self, **kw):
|
def delete_os_security_groups_1(self, **kw):
|
||||||
return (202, None)
|
return (202, None)
|
||||||
@@ -605,7 +604,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
fakes.assert_has_keys(body['security_group'],
|
fakes.assert_has_keys(body['security_group'],
|
||||||
required=['name', 'description'])
|
required=['name', 'description'])
|
||||||
r = {'security_group':
|
r = {'security_group':
|
||||||
self.get_os_security_groups()[1]['security_groups'][0]}
|
self.get_os_security_groups()[1]['security_groups'][0]}
|
||||||
return (202, r)
|
return (202, r)
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -616,7 +615,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
{'id': 1, 'parent_group_id': 1, 'group_id': 2,
|
{'id': 1, 'parent_group_id': 1, 'group_id': 2,
|
||||||
'ip_protocol': 'TCP', 'from_port': '22', 'to_port': 22,
|
'ip_protocol': 'TCP', 'from_port': '22', 'to_port': 22,
|
||||||
'cidr': '10.0.0.0/8'}
|
'cidr': '10.0.0.0/8'}
|
||||||
]})
|
]})
|
||||||
|
|
||||||
def delete_os_security_group_rules_1(self, **kw):
|
def delete_os_security_group_rules_1(self, **kw):
|
||||||
return (202, None)
|
return (202, None)
|
||||||
@@ -624,11 +623,11 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
def post_os_security_group_rules(self, body, **kw):
|
def post_os_security_group_rules(self, body, **kw):
|
||||||
assert body.keys() == ['security_group_rule']
|
assert body.keys() == ['security_group_rule']
|
||||||
fakes.assert_has_keys(body['security_group_rule'],
|
fakes.assert_has_keys(body['security_group_rule'],
|
||||||
required=['parent_group_id'],
|
required=['parent_group_id'],
|
||||||
optional=['group_id', 'ip_protocol', 'from_port',
|
optional=['group_id', 'ip_protocol', 'from_port',
|
||||||
'to_port', 'cidr'])
|
'to_port', 'cidr'])
|
||||||
r = {'security_group_rule':
|
r = {'security_group_rule':
|
||||||
self.get_os_security_group_rules()[1]['security_group_rules'][0]}
|
self.get_os_security_group_rules()[1]['security_group_rules'][0]}
|
||||||
return (202, r)
|
return (202, r)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||||||
}
|
}
|
||||||
auth_response = httplib2.Response({
|
auth_response = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps(resp),
|
"body": json.dumps(resp), })
|
||||||
})
|
|
||||||
|
|
||||||
mock_request = mock.Mock(return_value=(auth_response,
|
mock_request = mock.Mock(return_value=(auth_response,
|
||||||
json.dumps(resp)))
|
json.dumps(resp)))
|
||||||
@@ -85,8 +84,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||||||
resp = {"unauthorized": {"message": "Unauthorized", "code": "401"}}
|
resp = {"unauthorized": {"message": "Unauthorized", "code": "401"}}
|
||||||
auth_response = httplib2.Response({
|
auth_response = httplib2.Response({
|
||||||
"status": 401,
|
"status": 401,
|
||||||
"body": json.dumps(resp),
|
"body": json.dumps(resp), })
|
||||||
})
|
|
||||||
|
|
||||||
mock_request = mock.Mock(return_value=(auth_response,
|
mock_request = mock.Mock(return_value=(auth_response,
|
||||||
json.dumps(resp)))
|
json.dumps(resp)))
|
||||||
@@ -138,8 +136,8 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||||||
"body": correct_response}
|
"body": correct_response}
|
||||||
]
|
]
|
||||||
|
|
||||||
responses = [(to_http_response(resp), resp['body']) \
|
responses = [(to_http_response(resp), resp['body'])
|
||||||
for resp in dict_responses]
|
for resp in dict_responses]
|
||||||
|
|
||||||
def side_effect(*args, **kwargs):
|
def side_effect(*args, **kwargs):
|
||||||
return responses.pop(0)
|
return responses.pop(0)
|
||||||
@@ -159,9 +157,9 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||||||
'passwordCredentials': {
|
'passwordCredentials': {
|
||||||
'username': cs.client.user,
|
'username': cs.client.user,
|
||||||
'password': cs.client.password,
|
'password': cs.client.password,
|
||||||
},
|
},
|
||||||
'tenantName': cs.client.projectid,
|
'tenantName': cs.client.projectid,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
token_url = cs.client.auth_url + "/tokens"
|
token_url = cs.client.auth_url + "/tokens"
|
||||||
@@ -214,9 +212,10 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
auth_response = httplib2.Response({
|
auth_response = httplib2.Response(
|
||||||
"status": 200,
|
{
|
||||||
"body": json.dumps(resp),
|
"status": 200,
|
||||||
|
"body": json.dumps(resp),
|
||||||
})
|
})
|
||||||
|
|
||||||
mock_request = mock.Mock(return_value=(auth_response,
|
mock_request = mock.Mock(return_value=(auth_response,
|
||||||
|
|||||||
@@ -207,8 +207,8 @@ def print_help():
|
|||||||
python-cinderclient development uses virtualenv to track and manage Python
|
python-cinderclient development uses virtualenv to track and manage Python
|
||||||
dependencies while in development and testing.
|
dependencies while in development and testing.
|
||||||
|
|
||||||
To activate the python-cinderclient virtualenv for the extent of your current
|
To activate the python-cinderclient virtualenv for the extent of your
|
||||||
shell session you can run:
|
current shell session you can run:
|
||||||
|
|
||||||
$ source .venv/bin/activate
|
$ source .venv/bin/activate
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
|
|
||||||
distribute>=0.6.24
|
distribute>=0.6.24
|
||||||
|
|
||||||
mock
|
mock
|
||||||
nose
|
nose
|
||||||
nosexcover
|
nosexcover
|
||||||
openstack.nose_plugin
|
openstack.nose_plugin
|
||||||
pep8>=1.0
|
pep8==1.1
|
||||||
sphinx>=1.1.2
|
sphinx>=1.1.2
|
||||||
unittest2
|
unittest2
|
||||||
|
|||||||
Reference in New Issue
Block a user