removed disabled volume functionality
This commit is contained in:
parent
041bfa455c
commit
db3cf9f46b
manilaclient
tests/old
@ -58,9 +58,9 @@ class ServiceCatalog(object):
|
||||
service.get('name') != service_name):
|
||||
continue
|
||||
|
||||
# if (share_service_name and service_type == 'volume' and
|
||||
# service.get('name') != share_service_name):
|
||||
# continue
|
||||
if (share_service_name and service_type == 'share' and
|
||||
service.get('name') != share_service_name):
|
||||
continue
|
||||
|
||||
endpoints = service['endpoints']
|
||||
for endpoint in endpoints:
|
||||
|
Binary file not shown.
@ -4,11 +4,6 @@ from manilaclient.v1 import quota_classes
|
||||
from manilaclient.v1 import quotas
|
||||
from manilaclient.v1 import shares
|
||||
from manilaclient.v1 import share_snapshots
|
||||
# from manilaclient.v1 import volumes
|
||||
# from manilaclient.v1 import volume_snapshots
|
||||
# from manilaclient.v1 import volume_types
|
||||
# from manilaclient.v1 import volume_backups
|
||||
# from manilaclient.v1 import volume_backups_restore
|
||||
|
||||
|
||||
class Client(object):
|
||||
@ -37,11 +32,6 @@ class Client(object):
|
||||
password = api_key
|
||||
self.limits = limits.LimitsManager(self)
|
||||
|
||||
# extensions
|
||||
# self.volumes = volumes.VolumeManager(self)
|
||||
# self.volume_snapshots = volume_snapshots.SnapshotManager(self)
|
||||
# self.volume_types = volume_types.VolumeTypeManager(self)
|
||||
|
||||
# self.quota_classes = quota_classes.QuotaClassSetManager(self)
|
||||
# self.quotas = quotas.QuotaSetManager(self)
|
||||
|
||||
|
Binary file not shown.
@ -52,25 +52,6 @@ def _poll_for_status(poll_fn, obj_id, action, final_ok_states,
|
||||
time.sleep(poll_period)
|
||||
|
||||
|
||||
# def _find_volume(cs, volume):
|
||||
# """Get a volume by ID."""
|
||||
# return utils.find_resource(cs.volumes, volume)
|
||||
|
||||
|
||||
# def _find_volume_snapshot(cs, snapshot):
|
||||
# """Get a volume snapshot by ID."""
|
||||
# return utils.find_resource(cs.volume_snapshots, snapshot)
|
||||
|
||||
|
||||
# def _find_backup(cs, backup):
|
||||
# """Get a backup by ID."""
|
||||
# return utils.find_resource(cs.backups, backup)
|
||||
|
||||
|
||||
# def _print_volume_snapshot(snapshot):
|
||||
# utils.print_dict(snapshot._info)
|
||||
|
||||
|
||||
def _find_share(cs, share):
|
||||
"""Get a share by ID."""
|
||||
return utils.find_resource(cs.shares, share)
|
||||
@ -101,16 +82,6 @@ def _translate_keys(collection, convert):
|
||||
setattr(item, to_key, item._info[from_key])
|
||||
|
||||
|
||||
# def _translate_volume_keys(collection):
|
||||
# convert = [('volumeType', 'volume_type')]
|
||||
# _translate_keys(collection, convert)
|
||||
|
||||
|
||||
# def _translate_volume_snapshot_keys(collection):
|
||||
# convert = [('volumeId', 'volume_id')]
|
||||
# _translate_keys(collection, convert)
|
||||
|
||||
|
||||
def _extract_metadata(args):
|
||||
metadata = {}
|
||||
for metadatum in args.metadata[0]:
|
||||
@ -138,35 +109,35 @@ def do_credentials(cs, args):
|
||||
utils.print_dict(catalog['access']['user'], "User Credentials")
|
||||
utils.print_dict(catalog['access']['token'], "Token")
|
||||
|
||||
_quota_resources = ['volumes', 'snapshots', 'gigabytes']
|
||||
|
||||
#
|
||||
# def _quota_show(quotas):
|
||||
# quota_dict = {}
|
||||
# for resource in _quota_resources:
|
||||
# quota_dict[resource] = getattr(quotas, resource, None)
|
||||
# utils.print_dict(quota_dict)
|
||||
_quota_resources = ['shares', 'snapshots', 'gigabytes']
|
||||
|
||||
|
||||
# def _quota_update(manager, identifier, args):
|
||||
# updates = {}
|
||||
# for resource in _quota_resources:
|
||||
# val = getattr(args, resource, None)
|
||||
# if val is not None:
|
||||
# updates[resource] = val
|
||||
#
|
||||
# if updates:
|
||||
# manager.update(identifier, **updates)
|
||||
def _quota_show(quotas):
|
||||
quota_dict = {}
|
||||
for resource in _quota_resources:
|
||||
quota_dict[resource] = getattr(quotas, resource, None)
|
||||
utils.print_dict(quota_dict)
|
||||
|
||||
#
|
||||
# @utils.arg('tenant',
|
||||
# metavar='<tenant_id>',
|
||||
# help='UUID of tenant to list the quotas for.')
|
||||
# @utils.service_type('share')
|
||||
# def do_quota_show(cs, args):
|
||||
# """List the quotas for a tenant."""
|
||||
#
|
||||
# _quota_show(cs.quotas.get(args.tenant))
|
||||
|
||||
def _quota_update(manager, identifier, args):
|
||||
updates = {}
|
||||
for resource in _quota_resources:
|
||||
val = getattr(args, resource, None)
|
||||
if val is not None:
|
||||
updates[resource] = val
|
||||
|
||||
if updates:
|
||||
manager.update(identifier, **updates)
|
||||
|
||||
|
||||
@utils.arg('tenant',
|
||||
metavar='<tenant_id>',
|
||||
help='UUID of tenant to list the quotas for.')
|
||||
@utils.service_type('share')
|
||||
def do_quota_show(cs, args):
|
||||
"""List the quotas for a tenant."""
|
||||
|
||||
_quota_show(cs.quotas.get(args.tenant))
|
||||
|
||||
|
||||
# @utils.arg('tenant',
|
||||
|
Binary file not shown.
1
tests/old/contrib/__init__.py
Normal file
1
tests/old/contrib/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
__author__ = 'vkostenko'
|
@ -1,15 +0,0 @@
|
||||
# Copyright (c) 2013 OpenStack, LLC.
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,411 +0,0 @@
|
||||
# Copyright 2013 OpenStack, LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import urlparse
|
||||
|
||||
from manilaclient import client as base_client
|
||||
from manilaclient.v2 import client
|
||||
from tests import fakes
|
||||
import tests.utils as utils
|
||||
|
||||
|
||||
# def _stub_volume(**kwargs):
|
||||
# volume = {
|
||||
# 'id': '1234',
|
||||
# 'name': None,
|
||||
# 'description': None,
|
||||
# "attachments": [],
|
||||
# "bootable": "false",
|
||||
# "availability_zone": "manila",
|
||||
# "created_at": "2012-08-27T00:00:00.000000",
|
||||
# "id": '00000000-0000-0000-0000-000000000000',
|
||||
# "metadata": {},
|
||||
# "size": 1,
|
||||
# "snapshot_id": None,
|
||||
# "status": "available",
|
||||
# "volume_type": "None",
|
||||
# "links": [
|
||||
# {
|
||||
# "href": "http://localhost/v2/fake/volumes/1234",
|
||||
# "rel": "self"
|
||||
# },
|
||||
# {
|
||||
# "href": "http://localhost/fake/volumes/1234",
|
||||
# "rel": "bookmark"
|
||||
# }
|
||||
# ],
|
||||
# }
|
||||
# volume.update(kwargs)
|
||||
# return volume
|
||||
#
|
||||
#
|
||||
# def _stub_snapshot(**kwargs):
|
||||
# snapshot = {
|
||||
# "created_at": "2012-08-28T16:30:31.000000",
|
||||
# "display_description": None,
|
||||
# "display_name": None,
|
||||
# "id": '11111111-1111-1111-1111-111111111111',
|
||||
# "size": 1,
|
||||
# "status": "available",
|
||||
# "volume_id": '00000000-0000-0000-0000-000000000000',
|
||||
# }
|
||||
# snapshot.update(kwargs)
|
||||
# return snapshot
|
||||
#
|
||||
#
|
||||
# def _self_href(base_uri, tenant_id, backup_id):
|
||||
# return '%s/v2/%s/backups/%s' % (base_uri, tenant_id, backup_id)
|
||||
#
|
||||
#
|
||||
# def _bookmark_href(base_uri, tenant_id, backup_id):
|
||||
# return '%s/%s/backups/%s' % (base_uri, tenant_id, backup_id)
|
||||
#
|
||||
#
|
||||
# def _stub_backup_full(id, base_uri, tenant_id):
|
||||
# return {
|
||||
# 'id': id,
|
||||
# 'name': 'backup',
|
||||
# 'description': 'nightly backup',
|
||||
# 'volume_id': '712f4980-5ac1-41e5-9383-390aa7c9f58b',
|
||||
# 'container': 'volumebackups',
|
||||
# 'object_count': 220,
|
||||
# 'size': 10,
|
||||
# 'availability_zone': 'az1',
|
||||
# 'created_at': '2013-04-12T08:16:37.000000',
|
||||
# 'status': 'available',
|
||||
# 'links': [
|
||||
# {
|
||||
# 'href': _self_href(base_uri, tenant_id, id),
|
||||
# 'rel': 'self'
|
||||
# },
|
||||
# {
|
||||
# 'href': _bookmark_href(base_uri, tenant_id, id),
|
||||
# 'rel': 'bookmark'
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
#
|
||||
#
|
||||
# def _stub_backup(id, base_uri, tenant_id):
|
||||
# return {
|
||||
# 'id': id,
|
||||
# 'name': 'backup',
|
||||
# 'links': [
|
||||
# {
|
||||
# 'href': _self_href(base_uri, tenant_id, id),
|
||||
# 'rel': 'self'
|
||||
# },
|
||||
# {
|
||||
# 'href': _bookmark_href(base_uri, tenant_id, id),
|
||||
# 'rel': 'bookmark'
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
#
|
||||
#
|
||||
# def _stub_restore():
|
||||
# return {'volume_id': '712f4980-5ac1-41e5-9383-390aa7c9f58b'}
|
||||
#
|
||||
|
||||
class FakeClient(fakes.FakeClient, client.Client):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
client.Client.__init__(self, 'username', 'password',
|
||||
'project_id', 'auth_url',
|
||||
extensions=kwargs.get('extensions'))
|
||||
self.client = FakeHTTPClient(**kwargs)
|
||||
|
||||
|
||||
class FakeHTTPClient(base_client.HTTPClient):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.username = 'username'
|
||||
self.password = 'password'
|
||||
self.auth_url = 'auth_url'
|
||||
self.callstack = []
|
||||
|
||||
def _cs_request(self, url, method, **kwargs):
|
||||
# Check that certain things are called correctly
|
||||
if method in ['GET', 'DELETE']:
|
||||
assert 'body' not in kwargs
|
||||
elif method == 'PUT':
|
||||
assert 'body' in kwargs
|
||||
|
||||
# Call the method
|
||||
args = urlparse.parse_qsl(urlparse.urlparse(url)[4])
|
||||
kwargs.update(args)
|
||||
munged_url = url.rsplit('?', 1)[0]
|
||||
munged_url = munged_url.strip('/').replace('/', '_').replace('.', '_')
|
||||
munged_url = munged_url.replace('-', '_')
|
||||
|
||||
callback = "%s_%s" % (method.lower(), munged_url)
|
||||
|
||||
if not hasattr(self, callback):
|
||||
raise AssertionError('Called unknown API method: %s %s, '
|
||||
'expected fakes method name: %s' %
|
||||
(method, url, callback))
|
||||
|
||||
# Note the call
|
||||
self.callstack.append((method, url, kwargs.get('body', None)))
|
||||
status, headers, body = getattr(self, callback)(**kwargs)
|
||||
r = utils.TestResponse({
|
||||
"status_code": status,
|
||||
"text": body,
|
||||
"headers": headers,
|
||||
})
|
||||
return r, body
|
||||
|
||||
if hasattr(status, 'items'):
|
||||
return utils.TestResponse(status), body
|
||||
else:
|
||||
return utils.TestResponse({"status": status}), body
|
||||
|
||||
# #
|
||||
# # Snapshots
|
||||
# #
|
||||
#
|
||||
# def get_snapshots_detail(self, **kw):
|
||||
# return (200, {}, {'snapshots': [
|
||||
# _stub_snapshot(),
|
||||
# ]})
|
||||
#
|
||||
# def get_snapshots_1234(self, **kw):
|
||||
# return (200, {}, {'snapshot': _stub_snapshot(id='1234')})
|
||||
#
|
||||
# def put_snapshots_1234(self, **kw):
|
||||
# snapshot = _stub_snapshot(id='1234')
|
||||
# snapshot.update(kw['body']['snapshot'])
|
||||
# return (200, {}, {'snapshot': snapshot})
|
||||
#
|
||||
# #
|
||||
# # Volumes
|
||||
# #
|
||||
#
|
||||
# def put_volumes_1234(self, **kw):
|
||||
# volume = _stub_volume(id='1234')
|
||||
# volume.update(kw['body']['volume'])
|
||||
# return (200, {}, {'volume': volume})
|
||||
#
|
||||
# def get_volumes(self, **kw):
|
||||
# return (200, {}, {"volumes": [
|
||||
# {'id': 1234, 'name': 'sample-volume'},
|
||||
# {'id': 5678, 'name': 'sample-volume2'}
|
||||
# ]})
|
||||
#
|
||||
# # TODO(jdg): This will need to change
|
||||
# # at the very least it's not complete
|
||||
# def get_volumes_detail(self, **kw):
|
||||
# return (200, {}, {"volumes": [
|
||||
# {'id': 1234,
|
||||
# 'name': 'sample-volume',
|
||||
# 'attachments': [{'server_id': 1234}]},
|
||||
# ]})
|
||||
#
|
||||
# def get_volumes_1234(self, **kw):
|
||||
# r = {'volume': self.get_volumes_detail()[2]['volumes'][0]}
|
||||
# return (200, {}, r)
|
||||
#
|
||||
# def post_volumes_1234_action(self, body, **kw):
|
||||
# _body = None
|
||||
# resp = 202
|
||||
# assert len(body.keys()) == 1
|
||||
# action = body.keys()[0]
|
||||
# if action == 'os-attach':
|
||||
# assert body[action].keys() == ['instance_uuid', 'mountpoint']
|
||||
# elif action == 'os-detach':
|
||||
# assert body[action] is None
|
||||
# elif action == 'os-reserve':
|
||||
# assert body[action] is None
|
||||
# elif action == 'os-unreserve':
|
||||
# assert body[action] is None
|
||||
# elif action == 'os-initialize_connection':
|
||||
# assert body[action].keys() == ['connector']
|
||||
# return (202, {}, {'connection_info': 'foos'})
|
||||
# elif action == 'os-terminate_connection':
|
||||
# assert body[action].keys() == ['connector']
|
||||
# elif action == 'os-begin_detaching':
|
||||
# assert body[action] is None
|
||||
# elif action == 'os-roll_detaching':
|
||||
# assert body[action] is None
|
||||
# else:
|
||||
# raise AssertionError("Unexpected server action: %s" % action)
|
||||
# return (resp, {}, _body)
|
||||
#
|
||||
# def post_volumes(self, **kw):
|
||||
# return (202, {}, {'volume': {}})
|
||||
#
|
||||
# def delete_volumes_1234(self, **kw):
|
||||
# return (202, {}, None)
|
||||
#
|
||||
# #
|
||||
# # Quotas
|
||||
# #
|
||||
#
|
||||
# def get_os_quota_sets_test(self, **kw):
|
||||
# return (200, {}, {'quota_set': {
|
||||
# 'tenant_id': 'test',
|
||||
# 'metadata_items': [],
|
||||
# 'volumes': 1,
|
||||
# 'snapshots': 1,
|
||||
# 'gigabytes': 1}})
|
||||
#
|
||||
# def get_os_quota_sets_test_defaults(self):
|
||||
# return (200, {}, {'quota_set': {
|
||||
# 'tenant_id': 'test',
|
||||
# 'metadata_items': [],
|
||||
# 'volumes': 1,
|
||||
# 'snapshots': 1,
|
||||
# 'gigabytes': 1}})
|
||||
#
|
||||
# def put_os_quota_sets_test(self, body, **kw):
|
||||
# assert body.keys() == ['quota_set']
|
||||
# fakes.assert_has_keys(body['quota_set'],
|
||||
# required=['tenant_id'])
|
||||
# return (200, {}, {'quota_set': {
|
||||
# 'tenant_id': 'test',
|
||||
# 'metadata_items': [],
|
||||
# 'volumes': 2,
|
||||
# 'snapshots': 2,
|
||||
# 'gigabytes': 1}})
|
||||
#
|
||||
# #
|
||||
# # Quota Classes
|
||||
# #
|
||||
#
|
||||
# def get_os_quota_class_sets_test(self, **kw):
|
||||
# return (200, {}, {'quota_class_set': {
|
||||
# 'class_name': 'test',
|
||||
# 'metadata_items': [],
|
||||
# 'volumes': 1,
|
||||
# 'snapshots': 1,
|
||||
# 'gigabytes': 1}})
|
||||
#
|
||||
# def put_os_quota_class_sets_test(self, body, **kw):
|
||||
# assert body.keys() == ['quota_class_set']
|
||||
# fakes.assert_has_keys(body['quota_class_set'],
|
||||
# required=['class_name'])
|
||||
# return (200, {}, {'quota_class_set': {
|
||||
# 'class_name': 'test',
|
||||
# 'metadata_items': [],
|
||||
# 'volumes': 2,
|
||||
# 'snapshots': 2,
|
||||
# 'gigabytes': 1}})
|
||||
#
|
||||
# #
|
||||
# # VolumeTypes
|
||||
# #
|
||||
# def get_types(self, **kw):
|
||||
# return (200, {}, {
|
||||
# 'volume_types': [{'id': 1,
|
||||
# 'name': 'test-type-1',
|
||||
# 'extra_specs':{}},
|
||||
# {'id': 2,
|
||||
# 'name': 'test-type-2',
|
||||
# 'extra_specs':{}}]})
|
||||
#
|
||||
# def get_types_1(self, **kw):
|
||||
# return (200, {}, {'volume_type': {'id': 1,
|
||||
# 'name': 'test-type-1',
|
||||
# 'extra_specs': {}}})
|
||||
#
|
||||
# def post_types(self, body, **kw):
|
||||
# return (202, {}, {'volume_type': {'id': 3,
|
||||
# 'name': 'test-type-3',
|
||||
# 'extra_specs': {}}})
|
||||
#
|
||||
# def post_types_1_extra_specs(self, body, **kw):
|
||||
# assert body.keys() == ['extra_specs']
|
||||
# return (200, {}, {'extra_specs': {'k': 'v'}})
|
||||
#
|
||||
# def delete_types_1_extra_specs_k(self, **kw):
|
||||
# return(204, {}, None)
|
||||
#
|
||||
# def delete_types_1(self, **kw):
|
||||
# return (202, {}, None)
|
||||
#
|
||||
# #
|
||||
# # Set/Unset metadata
|
||||
# #
|
||||
# def delete_volumes_1234_metadata_test_key(self, **kw):
|
||||
# return (204, {}, None)
|
||||
#
|
||||
# def delete_volumes_1234_metadata_key1(self, **kw):
|
||||
# return (204, {}, None)
|
||||
#
|
||||
# def delete_volumes_1234_metadata_key2(self, **kw):
|
||||
# return (204, {}, None)
|
||||
#
|
||||
# def post_volumes_1234_metadata(self, **kw):
|
||||
# return (204, {}, {'metadata': {'test_key': 'test_value'}})
|
||||
#
|
||||
# #
|
||||
# # List all extensions
|
||||
# #
|
||||
# def get_extensions(self, **kw):
|
||||
# exts = [
|
||||
# {
|
||||
# "alias": "FAKE-1",
|
||||
# "description": "Fake extension number 1",
|
||||
# "links": [],
|
||||
# "name": "Fake1",
|
||||
# "namespace": ("http://docs.openstack.org/"
|
||||
# "/ext/fake1/api/v1.1"),
|
||||
# "updated": "2011-06-09T00:00:00+00:00"
|
||||
# },
|
||||
# {
|
||||
# "alias": "FAKE-2",
|
||||
# "description": "Fake extension number 2",
|
||||
# "links": [],
|
||||
# "name": "Fake2",
|
||||
# "namespace": ("http://docs.openstack.org/"
|
||||
# "/ext/fake1/api/v1.1"),
|
||||
# "updated": "2011-06-09T00:00:00+00:00"
|
||||
# },
|
||||
# ]
|
||||
# return (200, {}, {"extensions": exts, })
|
||||
#
|
||||
# #
|
||||
# # VolumeBackups
|
||||
# #
|
||||
#
|
||||
# def get_backups_76a17945_3c6f_435c_975b_b5685db10b62(self, **kw):
|
||||
# base_uri = 'http://localhost:8776'
|
||||
# tenant_id = '0fa851f6668144cf9cd8c8419c1646c1'
|
||||
# backup1 = '76a17945-3c6f-435c-975b-b5685db10b62'
|
||||
# return (200, {},
|
||||
# {'backup': _stub_backup_full(backup1, base_uri, tenant_id)})
|
||||
#
|
||||
# def get_backups_detail(self, **kw):
|
||||
# base_uri = 'http://localhost:8776'
|
||||
# tenant_id = '0fa851f6668144cf9cd8c8419c1646c1'
|
||||
# backup1 = '76a17945-3c6f-435c-975b-b5685db10b62'
|
||||
# backup2 = 'd09534c6-08b8-4441-9e87-8976f3a8f699'
|
||||
# return (200, {},
|
||||
# {'backups': [
|
||||
# _stub_backup_full(backup1, base_uri, tenant_id),
|
||||
# _stub_backup_full(backup2, base_uri, tenant_id)]})
|
||||
#
|
||||
# def delete_backups_76a17945_3c6f_435c_975b_b5685db10b62(self, **kw):
|
||||
# return (202, {}, None)
|
||||
#
|
||||
# def post_backups(self, **kw):
|
||||
# base_uri = 'http://localhost:8776'
|
||||
# tenant_id = '0fa851f6668144cf9cd8c8419c1646c1'
|
||||
# backup1 = '76a17945-3c6f-435c-975b-b5685db10b62'
|
||||
# return (202, {},
|
||||
# {'backup': _stub_backup(backup1, base_uri, tenant_id)})
|
||||
#
|
||||
# def post_backups_76a17945_3c6f_435c_975b_b5685db10b62_restore(self, **kw):
|
||||
# return (200, {},
|
||||
# {'restore': _stub_restore()})
|
Binary file not shown.
@ -1,85 +0,0 @@
|
||||
# Copyright (c) 2011 X.commerce, a business unit of eBay Inc.
|
||||
# Copyright 2011 OpenStack, LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from manilaclient.v2 import shares as shares_ext_module
|
||||
from manilaclient.v2 import client
|
||||
from tests.v2 import fakes
|
||||
|
||||
|
||||
class FakeClient(fakes.FakeClient):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
client.Client.__init__(self, 'username', 'password',
|
||||
'project_id', 'auth_url',
|
||||
extensions=kwargs.get('extensions'))
|
||||
self.client = FakeHTTPClient(**kwargs)
|
||||
|
||||
|
||||
class FakeHTTPClient(fakes.FakeHTTPClient):
|
||||
|
||||
def get_shares_1234(self, **kw):
|
||||
share = {'share': {'id': 1234, 'name': 'sharename'}}
|
||||
return (200, {}, share)
|
||||
|
||||
def get_shares_detail(self):
|
||||
shares = {'shares': [{'id': 1234,
|
||||
'name': 'sharename',
|
||||
'attachments': [{'server_id': 111}]}]}
|
||||
return (200, {}, shares)
|
||||
|
||||
def get_share_snapshots_1234(self, **kw):
|
||||
snapshot = {'share-snapshot': {'id': 1234, 'name': 'sharename'}}
|
||||
return (200, {}, snapshot)
|
||||
|
||||
def get_share_snapshots_detail(self):
|
||||
snapshots = {'share-snapshots': [{
|
||||
'id': 1234,
|
||||
'created_at': '2012-08-27T00:00:00.000000',
|
||||
'share_size': 1,
|
||||
'share_id': 4321,
|
||||
'status': 'available',
|
||||
'name': 'sharename',
|
||||
'display_description': 'description',
|
||||
'share_proto': 'type',
|
||||
'export_location': 'location',
|
||||
}]}
|
||||
return (200, {}, snapshots)
|
||||
|
||||
def post_shares_1234_action(self, body, **kw):
|
||||
_body = None
|
||||
resp = 202
|
||||
assert len(body.keys()) == 1
|
||||
action = body.keys()[0]
|
||||
if action == 'os-allow_access':
|
||||
assert body[action].keys() == ['access_type', 'access_to']
|
||||
elif action == 'os-deny_access':
|
||||
assert body[action].keys() == ['access_id']
|
||||
elif action == 'os-access_list':
|
||||
assert body[action] is None
|
||||
else:
|
||||
raise AssertionError("Unexpected share action: %s" % action)
|
||||
return (resp, {}, _body)
|
||||
|
||||
def post_shares(self, **kwargs):
|
||||
return (202, {}, {'share': {}})
|
||||
|
||||
def post_share_snapshots(self, **kwargs):
|
||||
return (202, {}, {'share-snapshot': {}})
|
||||
|
||||
def delete_shares_1234(self, **kw):
|
||||
return (202, {}, None)
|
||||
|
||||
def delete_share_snapshots_1234(self, **kwargs):
|
||||
return (202, {}, None)
|
@ -1,44 +0,0 @@
|
||||
# Copyright 2010 Jacob Kaplan-Moss
|
||||
|
||||
# Copyright 2011 OpenStack LLC.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from manilaclient import extension
|
||||
from manilaclient.v2 import share_snapshots
|
||||
|
||||
from tests import utils
|
||||
from tests.v2.shares import fakes
|
||||
|
||||
|
||||
extensions = [
|
||||
extension.Extension('share_snapshots', share_snapshots),
|
||||
]
|
||||
cs = fakes.FakeClient(extensions=extensions)
|
||||
|
||||
|
||||
class ShareSnapshotsTest(utils.TestCase):
|
||||
|
||||
def test_create_share_snapshot(self):
|
||||
cs.share_snapshots.create(1234)
|
||||
cs.assert_called('POST', '/share-snapshots')
|
||||
|
||||
def test_delete_share(self):
|
||||
snapshot = cs.share_snapshots.get(1234)
|
||||
cs.share_snapshots.delete(snapshot)
|
||||
cs.assert_called('DELETE', '/share-snapshots/1234')
|
||||
|
||||
def test_list_shares(self):
|
||||
cs.share_snapshots.list()
|
||||
cs.assert_called('GET', '/share-snapshots/detail')
|
Binary file not shown.
@ -1,54 +0,0 @@
|
||||
# Copyright 2010 Jacob Kaplan-Moss
|
||||
|
||||
# Copyright 2011 OpenStack LLC.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from manilaclient import extension
|
||||
from manilaclient.v2 import shares
|
||||
|
||||
from tests import utils
|
||||
from tests.v2.shares import fakes
|
||||
|
||||
|
||||
extensions = [
|
||||
extension.Extension('shares', shares),
|
||||
]
|
||||
cs = fakes.FakeClient(extensions=extensions)
|
||||
|
||||
|
||||
class SharesTest(utils.TestCase):
|
||||
|
||||
def test_create_nfs_share(self):
|
||||
cs.shares.create('nfs', 1)
|
||||
cs.assert_called('POST', '/shares')
|
||||
|
||||
def test_create_cifs_share(self):
|
||||
cs.shares.create('cifs', 2)
|
||||
cs.assert_called('POST', '/shares')
|
||||
|
||||
def test_delete_share(self):
|
||||
share = cs.shares.get('1234')
|
||||
cs.shares.delete(share)
|
||||
cs.assert_called('DELETE', '/shares/1234')
|
||||
|
||||
def test_list_shares(self):
|
||||
cs.shares.list()
|
||||
cs.assert_called('GET', '/shares/detail')
|
||||
|
||||
def test_allow_access_to_share(self):
|
||||
share = cs.shares.get(1234)
|
||||
ip = '192.168.0.1'
|
||||
cs.shares.allow(share, 'ip', ip)
|
||||
cs.assert_called('POST', '/shares/1234/action')
|
Binary file not shown.
@ -1,50 +0,0 @@
|
||||
# # Copyright (c) 2013 OpenStack, LLC.
|
||||
# #
|
||||
# # All Rights Reserved.
|
||||
# #
|
||||
# # Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# # not use this file except in compliance with the License. You may obtain
|
||||
# # a copy of the License at
|
||||
# #
|
||||
# # http://www.apache.org/licenses/LICENSE-2.0
|
||||
# #
|
||||
# # Unless required by applicable law or agreed to in writing, software
|
||||
# # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# # License for the specific language governing permissions and limitations
|
||||
# # under the License.
|
||||
#
|
||||
# from manilaclient.v2 import volume_types
|
||||
# from tests import utils
|
||||
# from tests.v2 import fakes
|
||||
#
|
||||
# cs = fakes.FakeClient()
|
||||
#
|
||||
#
|
||||
# class TypesTest(utils.TestCase):
|
||||
# def test_list_types(self):
|
||||
# tl = cs.volume_types.list()
|
||||
# cs.assert_called('GET', '/types')
|
||||
# for t in tl:
|
||||
# self.assertTrue(isinstance(t, volume_types.VolumeType))
|
||||
#
|
||||
# def test_create(self):
|
||||
# t = cs.volume_types.create('test-type-3')
|
||||
# cs.assert_called('POST', '/types')
|
||||
# self.assertTrue(isinstance(t, volume_types.VolumeType))
|
||||
#
|
||||
# def test_set_key(self):
|
||||
# t = cs.volume_types.get(1)
|
||||
# t.set_keys({'k': 'v'})
|
||||
# cs.assert_called('POST',
|
||||
# '/types/1/extra_specs',
|
||||
# {'extra_specs': {'k': 'v'}})
|
||||
#
|
||||
# def test_unsset_keys(self):
|
||||
# t = cs.volume_types.get(1)
|
||||
# t.unset_keys(['k'])
|
||||
# cs.assert_called('DELETE', '/types/1/extra_specs/k')
|
||||
#
|
||||
# def test_delete(self):
|
||||
# cs.volume_types.delete(1)
|
||||
# cs.assert_called('DELETE', '/types/1')
|
Loading…
x
Reference in New Issue
Block a user