Blackify openstack.shared_file_system

Black used with the '-l 79 -S' flags.

A future change will ignore this commit in git-blame history by adding a
'git-blame-ignore-revs' file.

Change-Id: I54209e6cbfeec18a15771882d38730aca273238c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-05-05 10:59:36 +01:00
parent 82c2a53402
commit 3d2511f980
36 changed files with 768 additions and 600 deletions

View File

@ -16,6 +16,7 @@ from openstack.shared_file_system.v2 import _proxy
class SharedFilesystemService(service_description.ServiceDescription):
"""The shared file systems service."""
supported_versions = {
'2': _proxy.Proxy,
}

View File

@ -13,34 +13,27 @@
from openstack import proxy
from openstack import resource
from openstack.shared_file_system.v2 import (
availability_zone as _availability_zone)
from openstack.shared_file_system.v2 import (
share_access_rule as _share_access_rule
)
from openstack.shared_file_system.v2 import (
share_export_locations as _share_export_locations
)
from openstack.shared_file_system.v2 import (
share_network as _share_network
)
from openstack.shared_file_system.v2 import (
share_network_subnet as _share_network_subnet
)
from openstack.shared_file_system.v2 import (
share_snapshot as _share_snapshot
)
from openstack.shared_file_system.v2 import (
share_snapshot_instance as _share_snapshot_instance
)
from openstack.shared_file_system.v2 import (
storage_pool as _storage_pool
)
from openstack.shared_file_system.v2 import (
user_message as _user_message
availability_zone as _availability_zone,
)
from openstack.shared_file_system.v2 import limit as _limit
from openstack.shared_file_system.v2 import share as _share
from openstack.shared_file_system.v2 import (
share_access_rule as _share_access_rule,
)
from openstack.shared_file_system.v2 import (
share_export_locations as _share_export_locations,
)
from openstack.shared_file_system.v2 import share_instance as _share_instance
from openstack.shared_file_system.v2 import share_network as _share_network
from openstack.shared_file_system.v2 import (
share_network_subnet as _share_network_subnet,
)
from openstack.shared_file_system.v2 import share_snapshot as _share_snapshot
from openstack.shared_file_system.v2 import (
share_snapshot_instance as _share_snapshot_instance,
)
from openstack.shared_file_system.v2 import storage_pool as _storage_pool
from openstack.shared_file_system.v2 import user_message as _user_message
class Proxy(proxy.Proxy):
@ -53,11 +46,9 @@ class Proxy(proxy.Proxy):
"share": _share.Share,
"share_network": _share_network.ShareNetwork,
"share_network_subnet": _share_network_subnet.ShareNetworkSubnet,
"share_snapshot_instance":
_share_snapshot_instance.ShareSnapshotInstance,
"share_snapshot_instance": _share_snapshot_instance.ShareSnapshotInstance, # noqa: E501
"share_instance": _share_instance.ShareInstance,
"share_export_locations":
_share_export_locations.ShareExportLocation,
"share_export_locations": _share_export_locations.ShareExportLocation,
"share_access_rule": _share_access_rule.ShareAccessRule,
}
@ -134,8 +125,7 @@ class Proxy(proxy.Proxy):
:returns: Result of the ``delete``
:rtype: ``None``
"""
self._delete(_share.Share, share,
ignore_missing=ignore_missing)
self._delete(_share.Share, share, ignore_missing=ignore_missing)
def update_share(self, share_id, **attrs):
"""Updates details of a single share.
@ -172,12 +162,7 @@ class Proxy(proxy.Proxy):
res.revert_to_snapshot(self, snapshot_id)
def resize_share(
self,
share_id,
new_size,
no_shrink=False,
no_extend=False,
force=False
self, share_id, new_size, no_shrink=False, no_extend=False, force=False
):
"""Resizes a share, extending/shrinking the share as needed.
@ -206,8 +191,9 @@ class Proxy(proxy.Proxy):
elif new_size < res.size and no_shrink is not True:
res.shrink_share(self, new_size)
def wait_for_status(self, res, status='active', failures=None,
interval=2, wait=120):
def wait_for_status(
self, res, status='active', failures=None, interval=2, wait=120
):
"""Wait for a resource to be in a particular status.
:param res: The resource to wait on to reach the specified status.
The resource must have a ``status`` attribute.
@ -229,7 +215,8 @@ class Proxy(proxy.Proxy):
"""
failures = [] if failures is None else failures
return resource.wait_for_status(
self, res, status, failures, interval, wait)
self, res, status, failures, interval, wait
)
def storage_pools(self, details=True, **query):
"""Lists all back-end storage pools with details
@ -248,7 +235,8 @@ class Proxy(proxy.Proxy):
"""
base_path = '/scheduler-stats/pools/detail' if details else None
return self._list(
_storage_pool.StoragePool, base_path=base_path, **query)
_storage_pool.StoragePool, base_path=base_path, **query
)
def user_messages(self, **query):
"""List shared file system user messages
@ -278,8 +266,7 @@ class Proxy(proxy.Proxy):
:rtype:
:class:`~openstack.shared_file_system.v2.user_message.UserMessage`
"""
return self._list(
_user_message.UserMessage, **query)
return self._list(_user_message.UserMessage, **query)
def get_user_message(self, message_id):
"""List details of a single user message
@ -300,8 +287,10 @@ class Proxy(proxy.Proxy):
:class:`~openstack.shared_file_system.v2.user_message.UserMessage`
"""
return self._delete(
_user_message.UserMessage, message_id,
ignore_missing=ignore_missing)
_user_message.UserMessage,
message_id,
ignore_missing=ignore_missing,
)
def limits(self, **query):
"""Lists all share limits.
@ -312,8 +301,7 @@ class Proxy(proxy.Proxy):
:returns: A generator of manila share limits resources
:rtype: :class:`~openstack.shared_file_system.v2.limit.Limit`
"""
return self._list(
_limit.Limit, **query)
return self._list(_limit.Limit, **query)
def share_snapshots(self, details=True, **query):
"""Lists all share snapshots with details.
@ -329,7 +317,8 @@ class Proxy(proxy.Proxy):
"""
base_path = '/snapshots/detail' if details else None
return self._list(
_share_snapshot.ShareSnapshot, base_path=base_path, **query)
_share_snapshot.ShareSnapshot, base_path=base_path, **query
)
def get_share_snapshot(self, snapshot_id):
"""Lists details of a single share snapshot
@ -359,8 +348,9 @@ class Proxy(proxy.Proxy):
:rtype:
:class:`~openstack.shared_file_system.v2.share_snapshot.ShareSnapshot`
"""
return self._update(_share_snapshot.ShareSnapshot, snapshot_id,
**attrs)
return self._update(
_share_snapshot.ShareSnapshot, snapshot_id, **attrs
)
def delete_share_snapshot(self, snapshot_id, ignore_missing=True):
"""Deletes a single share snapshot
@ -369,8 +359,11 @@ class Proxy(proxy.Proxy):
:returns: Result of the ``delete``
:rtype: ``None``
"""
self._delete(_share_snapshot.ShareSnapshot, snapshot_id,
ignore_missing=ignore_missing)
self._delete(
_share_snapshot.ShareSnapshot,
snapshot_id,
ignore_missing=ignore_missing,
)
# ========= Network Subnets ==========
def share_network_subnets(self, share_network_id):
@ -384,10 +377,13 @@ class Proxy(proxy.Proxy):
"""
return self._list(
_share_network_subnet.ShareNetworkSubnet,
share_network_id=share_network_id)
share_network_id=share_network_id,
)
def get_share_network_subnet(
self, share_network_id, share_network_subnet_id,
self,
share_network_id,
share_network_subnet_id,
):
"""Lists details of a single share network subnet.
@ -403,7 +399,8 @@ class Proxy(proxy.Proxy):
return self._get(
_share_network_subnet.ShareNetworkSubnet,
share_network_subnet_id,
share_network_id=share_network_id)
share_network_id=share_network_id,
)
def create_share_network_subnet(self, share_network_id, **attrs):
"""Creates a share network subnet from attributes
@ -419,7 +416,8 @@ class Proxy(proxy.Proxy):
return self._create(
_share_network_subnet.ShareNetworkSubnet,
**attrs,
share_network_id=share_network_id)
share_network_id=share_network_id
)
def delete_share_network_subnet(
self, share_network_id, share_network_subnet, ignore_missing=True
@ -438,7 +436,8 @@ class Proxy(proxy.Proxy):
_share_network_subnet.ShareNetworkSubnet,
share_network_subnet,
share_network_id=share_network_id,
ignore_missing=ignore_missing)
ignore_missing=ignore_missing,
)
def wait_for_delete(self, res, interval=2, wait=120):
"""Wait for a resource to be deleted.
@ -474,8 +473,11 @@ class Proxy(proxy.Proxy):
share_snapshot_instance.ShareSnapshotInstance`
"""
base_path = '/snapshot-instances/detail' if details else None
return self._list(_share_snapshot_instance.ShareSnapshotInstance,
base_path=base_path, **query)
return self._list(
_share_snapshot_instance.ShareSnapshotInstance,
base_path=base_path,
**query
)
def get_share_snapshot_instance(self, snapshot_instance_id):
"""Lists details of a single share snapshot instance
@ -485,8 +487,10 @@ class Proxy(proxy.Proxy):
:rtype: :class:`~openstack.shared_file_system.v2.
share_snapshot_instance.ShareSnapshotInstance`
"""
return self._get(_share_snapshot_instance.ShareSnapshotInstance,
snapshot_instance_id)
return self._get(
_share_snapshot_instance.ShareSnapshotInstance,
snapshot_instance_id,
)
def share_networks(self, details=True, **query):
"""Lists all share networks with details.
@ -508,7 +512,8 @@ class Proxy(proxy.Proxy):
"""
base_path = '/share-networks/detail' if details else None
return self._list(
_share_network.ShareNetwork, base_path=base_path, **query)
_share_network.ShareNetwork, base_path=base_path, **query
)
def get_share_network(self, share_network_id):
"""Lists details of a single share network
@ -527,8 +532,10 @@ class Proxy(proxy.Proxy):
:rtype: ``None``
"""
self._delete(
_share_network.ShareNetwork, share_network_id,
ignore_missing=ignore_missing)
_share_network.ShareNetwork,
share_network_id,
ignore_missing=ignore_missing,
)
def update_share_network(self, share_network_id, **attrs):
"""Updates details of a single share network.
@ -540,7 +547,8 @@ class Proxy(proxy.Proxy):
share_network.ShareNetwork`
"""
return self._update(
_share_network.ShareNetwork, share_network_id, **attrs)
_share_network.ShareNetwork, share_network_id, **attrs
)
def create_share_network(self, **attrs):
"""Creates a share network from attributes
@ -570,8 +578,7 @@ class Proxy(proxy.Proxy):
:rtype: :class:`~openstack.shared_file_system.v2.
share_instance.ShareInstance`
"""
return self._list(
_share_instance.ShareInstance, **query)
return self._list(_share_instance.ShareInstance, **query)
def get_share_instance(self, share_instance_id):
"""Shows details for a single share instance
@ -592,8 +599,9 @@ class Proxy(proxy.Proxy):
:returns: ``None``
"""
res = self._get_resource(_share_instance.ShareInstance,
share_instance_id)
res = self._get_resource(
_share_instance.ShareInstance, share_instance_id
)
res.reset_status(self, status)
def delete_share_instance(self, share_instance_id):
@ -603,8 +611,9 @@ class Proxy(proxy.Proxy):
:returns: ``None``
"""
res = self._get_resource(_share_instance.ShareInstance,
share_instance_id)
res = self._get_resource(
_share_instance.ShareInstance, share_instance_id
)
res.force_delete(self)
def export_locations(self, share_id):
@ -615,8 +624,9 @@ class Proxy(proxy.Proxy):
:rtype: List of :class:`~openstack.shared_filesystem_storage.v2.
share_export_locations.ShareExportLocations`
"""
return self._list(_share_export_locations.ShareExportLocation,
share_id=share_id)
return self._list(
_share_export_locations.ShareExportLocation, share_id=share_id
)
def get_export_location(self, export_location, share_id):
"""List details of export location
@ -631,7 +641,9 @@ class Proxy(proxy.Proxy):
export_location_id = resource.Resource._get_id(export_location)
return self._get(
_share_export_locations.ShareExportLocation,
export_location_id, share_id=share_id)
export_location_id,
share_id=share_id,
)
def access_rules(self, share, **query):
"""Lists the access rules on a share.
@ -642,8 +654,8 @@ class Proxy(proxy.Proxy):
"""
share = self._get_resource(_share.Share, share)
return self._list(
_share_access_rule.ShareAccessRule,
share_id=share.id, **query)
_share_access_rule.ShareAccessRule, share_id=share.id, **query
)
def get_access_rule(self, access_id):
"""List details of an access rule.
@ -653,8 +665,7 @@ class Proxy(proxy.Proxy):
:rtype: :class:`~openstack.shared_file_system.v2.
share_access_rules.ShareAccessRules`
"""
return self._get(
_share_access_rule.ShareAccessRule, access_id)
return self._get(_share_access_rule.ShareAccessRule, access_id)
def create_access_rule(self, share_id, **attrs):
"""Creates an access rule from attributes
@ -670,7 +681,8 @@ class Proxy(proxy.Proxy):
"""
base_path = "/shares/%s/action" % (share_id,)
return self._create(
_share_access_rule.ShareAccessRule, base_path=base_path, **attrs)
_share_access_rule.ShareAccessRule, base_path=base_path, **attrs
)
def delete_access_rule(self, access_id, share_id, ignore_missing=True):
"""Deletes an access rule
@ -680,6 +692,5 @@ class Proxy(proxy.Proxy):
:rtype: ``None``
"""
res = self._get_resource(
_share_access_rule.ShareAccessRule, access_id)
res = self._get_resource(_share_access_rule.ShareAccessRule, access_id)
res.delete(self, share_id, ignore_missing=ignore_missing)

View File

@ -29,47 +29,46 @@ class Limit(resource.Resource):
#: The maximum number of replica gigabytes that are allowed
#: in a project.
maxTotalReplicaGigabytes = resource.Body(
"maxTotalReplicaGigabytes", type=int)
"maxTotalReplicaGigabytes", type=int
)
#: The total maximum number of shares that are allowed in a project.
maxTotalShares = resource.Body("maxTotalShares", type=int)
#: The total maximum number of share gigabytes that are allowed in a
#: project.
maxTotalShareGigabytes = resource.Body(
"maxTotalShareGigabytes", type=int)
maxTotalShareGigabytes = resource.Body("maxTotalShareGigabytes", type=int)
#: The total maximum number of share-networks that are allowed in a
#: project.
maxTotalShareNetworks = resource.Body(
"maxTotalShareNetworks", type=int)
maxTotalShareNetworks = resource.Body("maxTotalShareNetworks", type=int)
#: The total maximum number of share snapshots that are allowed in a
#: project.
maxTotalShareSnapshots = resource.Body(
"maxTotalShareSnapshots", type=int)
maxTotalShareSnapshots = resource.Body("maxTotalShareSnapshots", type=int)
#: The maximum number of share replicas that is allowed.
maxTotalShareReplicas = resource.Body(
"maxTotalShareReplicas", type=int)
maxTotalShareReplicas = resource.Body("maxTotalShareReplicas", type=int)
#: The total maximum number of snapshot gigabytes that are allowed
#: in a project.
maxTotalSnapshotGigabytes = resource.Body(
"maxTotalSnapshotGigabytes", type=int)
"maxTotalSnapshotGigabytes", type=int
)
#: The total number of replica gigabytes used in a project by
#: share replicas.
totalReplicaGigabytesUsed = resource.Body(
"totalReplicaGigabytesUsed", type=int)
"totalReplicaGigabytesUsed", type=int
)
#: The total number of gigabytes used in a project by shares.
totalShareGigabytesUsed = resource.Body(
"totalShareGigabytesUsed", type=int)
"totalShareGigabytesUsed", type=int
)
#: The total number of created shares in a project.
totalSharesUsed = resource.Body(
"totalSharesUsed", type=int)
totalSharesUsed = resource.Body("totalSharesUsed", type=int)
#: The total number of created share-networks in a project.
totalShareNetworksUsed = resource.Body(
"totalShareNetworksUsed", type=int)
totalShareNetworksUsed = resource.Body("totalShareNetworksUsed", type=int)
#: The total number of created share snapshots in a project.
totalShareSnapshotsUsed = resource.Body(
"totalShareSnapshotsUsed", type=int)
"totalShareSnapshotsUsed", type=int
)
#: The total number of gigabytes used in a project by snapshots.
totalSnapshotGigabytesUsed = resource.Body(
"totalSnapshotGigabytesUsed", type=int)
"totalSnapshotGigabytesUsed", type=int
)
#: The total number of created share replicas in a project.
totalShareReplicasUsed = resource.Body(
"totalShareReplicasUsed", type=int)
totalShareReplicasUsed = resource.Body("totalShareReplicasUsed", type=int)

View File

@ -46,18 +46,20 @@ class Share(resource.Resource):
#: Whether or not this share supports snapshots that can be
#: cloned into new shares.
is_creating_new_share_from_snapshot_supported = resource.Body(
"create_share_from_snapshot_support", type=bool)
"create_share_from_snapshot_support", type=bool
)
#: Whether the share's snapshots can be mounted directly and access
#: controlled independently or not.
is_mounting_snapshot_supported = resource.Body(
"mount_snapshot_support", type=bool)
"mount_snapshot_support", type=bool
)
#: Whether the share can be reverted to its latest snapshot or not.
is_reverting_to_snapshot_supported = resource.Body(
"revert_to_snapshot_support", type=bool)
"revert_to_snapshot_support", type=bool
)
#: An extra specification that filters back ends by whether the share
#: supports snapshots or not.
is_snapshot_supported = resource.Body(
"snapshot_support", type=bool)
is_snapshot_supported = resource.Body("snapshot_support", type=bool)
#: Indicates whether the share has replicas or not.
is_replicated = resource.Body("has_replicas", type=bool)
#: One or more metadata key and value pairs as a dictionary of strings.
@ -91,7 +93,8 @@ class Share(resource.Resource):
#: The ID of the group snapshot instance that was used to create
#: this share.
source_share_group_snapshot_member_id = resource.Body(
"source_share_group_snapshot_member_id", type=str)
"source_share_group_snapshot_member_id", type=str
)
#: The share status
status = resource.Body("status", type=str)
#: For the share migration, the migration task state.
@ -109,14 +112,11 @@ class Share(resource.Resource):
headers = {'Accept': ''}
if microversion is None:
microversion = \
self._get_microversion(session, action=action)
microversion = self._get_microversion(session, action=action)
response = session.post(
url,
json=body,
headers=headers,
microversion=microversion)
url, json=body, headers=headers, microversion=microversion
)
exceptions.raise_from_response(response)
return response

View File

@ -55,28 +55,26 @@ class ShareAccessRule(resource.Resource):
#: the services database.
updated_at = resource.Body("updated_at", type=str)
def _action(self, session, body, url,
action='patch', microversion=None):
def _action(self, session, body, url, action='patch', microversion=None):
headers = {'Accept': ''}
if microversion is None:
microversion = \
self._get_microversion(session, action=action)
microversion = self._get_microversion(session, action=action)
session.post(
url,
json=body,
headers=headers,
microversion=microversion)
url, json=body, headers=headers, microversion=microversion
)
def create(self, session, **kwargs):
return super().create(session,
resource_request_key='allow_access',
resource_response_key='access',
**kwargs)
return super().create(
session,
resource_request_key='allow_access',
resource_response_key='access',
**kwargs
)
def delete(self, session, share_id, ignore_missing=True):
body = {'deny_access': {'access_id' : self.id}}
body = {'deny_access': {'access_id': self.id}}
url = utils.urljoin('/shares', share_id, 'action')
try:
response = self._action(session, body, url)

View File

@ -66,8 +66,9 @@ class ShareInstance(resource.Resource):
# Set microversion override
extra_attrs['microversion'] = microversion
else:
extra_attrs['microversion'] = \
self._get_microversion(session, action=action)
extra_attrs['microversion'] = self._get_microversion(
session, action=action
)
response = session.post(url, json=body, headers=headers, **extra_attrs)
exceptions.raise_from_response(response)
return response

View File

@ -27,9 +27,15 @@ class ShareNetwork(resource.Resource):
allow_head = False
_query_mapping = resource.QueryParameters(
"project_id", "name", "description",
"created_since", "created_before", "security_service_id",
"limit", "offset", all_projects="all_tenants",
"project_id",
"name",
"description",
"created_since",
"created_before",
"security_service_id",
"limit",
"offset",
all_projects="all_tenants",
)
#: Properties

View File

@ -56,7 +56,6 @@ class ShareNetworkSubnet(resource.Resource):
updated_at = resource.Body("updated_at", type=str)
def create(self, session, **kwargs):
return super().\
create(session,
resource_request_key='share-network-subnet',
**kwargs)
return super().create(
session, resource_request_key='share-network-subnet', **kwargs
)

View File

@ -26,9 +26,7 @@ class ShareSnapshot(resource.Resource):
allow_list = True
allow_head = False
_query_mapping = resource.QueryParameters(
"snapshot_id"
)
_query_mapping = resource.QueryParameters("snapshot_id")
#: Properties
#: The date and time stamp when the resource was
@ -39,8 +37,7 @@ class ShareSnapshot(resource.Resource):
#: The user defined name of the resource.
display_name = resource.Body("display_name", type=str)
#: The user defined description of the resource
display_description = resource.Body(
"display_description", type=str)
display_description = resource.Body("display_description", type=str)
#: ID of the project that the snapshot belongs to.
project_id = resource.Body("project_id", type=str)
#: The UUID of the source share that was used to

View File

@ -27,7 +27,11 @@ class StoragePool(resource.Resource):
allow_head = False
_query_mapping = resource.QueryParameters(
'pool', 'backend', 'host', 'capabilities', 'share_type',
'pool',
'backend',
'host',
'capabilities',
'share_type',
)
#: Properties

View File

@ -25,9 +25,7 @@ class UserMessage(resource.Resource):
allow_list = True
allow_head = False
_query_mapping = resource.QueryParameters(
"message_id"
)
_query_mapping = resource.QueryParameters("message_id")
_max_microversion = '2.37'

View File

@ -20,40 +20,49 @@ class BaseSharedFileSystemTest(base.BaseFunctionalTest):
def setUp(self):
super(BaseSharedFileSystemTest, self).setUp()
self.require_service('shared-file-system',
min_microversion=self.min_microversion)
self.require_service(
'shared-file-system', min_microversion=self.min_microversion
)
self._set_operator_cloud(shared_file_system_api_version='2.63')
self._set_user_cloud(shared_file_system_api_version='2.63')
def create_share(self, **kwargs):
share = self.user_cloud.share.create_share(**kwargs)
self.addCleanup(self.user_cloud.share.delete_share,
share.id,
ignore_missing=True)
self.addCleanup(
self.user_cloud.share.delete_share, share.id, ignore_missing=True
)
self.user_cloud.share.wait_for_status(
share,
status='available',
failures=['error'],
interval=5,
wait=self._wait_for_timeout)
wait=self._wait_for_timeout,
)
self.assertIsNotNone(share.id)
return share
def create_share_snapshot(self, share_id, **kwargs):
share_snapshot = self.user_cloud.share.create_share_snapshot(
share_id=share_id, force=True)
self.addCleanup(resource.wait_for_delete,
self.user_cloud.share, share_snapshot,
wait=self._wait_for_timeout,
interval=2)
self.addCleanup(self.user_cloud.share.delete_share_snapshot,
share_snapshot.id,
ignore_missing=False)
share_id=share_id, force=True
)
self.addCleanup(
resource.wait_for_delete,
self.user_cloud.share,
share_snapshot,
wait=self._wait_for_timeout,
interval=2,
)
self.addCleanup(
self.user_cloud.share.delete_share_snapshot,
share_snapshot.id,
ignore_missing=False,
)
self.user_cloud.share.wait_for_status(
share_snapshot,
status='available',
failures=['error'],
interval=5,
wait=self._wait_for_timeout)
wait=self._wait_for_timeout,
)
self.assertIsNotNone(share_snapshot.id)
return share_snapshot

View File

@ -22,8 +22,12 @@ class TestExportLocation(base.BaseSharedFileSystemTest):
self.SHARE_NAME = self.getUniqueString()
my_share = self.create_share(
name=self.SHARE_NAME, size=2, share_type="dhss_false",
share_protocol='NFS', description=None)
name=self.SHARE_NAME,
size=2,
share_type="dhss_false",
share_protocol='NFS',
description=None,
)
self.SHARE_ID = my_share.id
def test_export_locations(self):
@ -33,8 +37,12 @@ class TestExportLocation(base.BaseSharedFileSystemTest):
self.assertGreater(len(list(exs)), 0)
for ex in exs:
for attribute in (
'id', 'path', 'share_instance_id',
'updated_at', 'created_at'):
'id',
'path',
'share_instance_id',
'updated_at',
'created_at',
):
self.assertTrue(hasattr(ex, attribute))
self.assertIsInstance(getattr(ex, attribute), 'str')
for attribute in ('is_preferred', 'is_admin'):

View File

@ -14,23 +14,24 @@ from openstack.tests.functional.shared_file_system import base
class LimitTest(base.BaseSharedFileSystemTest):
def test_limits(self):
limits = self.user_cloud.shared_file_system.limits()
self.assertGreater(len(list(limits)), 0)
for limit in limits:
for attribute in ("maxTotalReplicaGigabytes",
"maxTotalShares",
"maxTotalShareGigabytes",
"maxTotalShareNetworks",
"maxTotalShareSnapshots",
"maxTotalShareReplicas",
"maxTotalSnapshotGigabytes",
"totalReplicaGigabytesUsed",
"totalShareGigabytesUsed",
"totalSharesUsed",
"totalShareNetworksUsed",
"totalShareSnapshotsUsed",
"totalSnapshotGigabytesUsed",
"totalShareReplicasUsed"):
for attribute in (
"maxTotalReplicaGigabytes",
"maxTotalShares",
"maxTotalShareGigabytes",
"maxTotalShareNetworks",
"maxTotalShareSnapshots",
"maxTotalShareReplicas",
"maxTotalSnapshotGigabytes",
"totalReplicaGigabytesUsed",
"totalShareGigabytesUsed",
"totalSharesUsed",
"totalShareNetworksUsed",
"totalShareSnapshotsUsed",
"totalSnapshotGigabytesUsed",
"totalShareReplicasUsed",
):
self.assertTrue(hasattr(limit, attribute))

View File

@ -15,19 +15,20 @@ from openstack.tests.functional.shared_file_system import base
class ShareTest(base.BaseSharedFileSystemTest):
def setUp(self):
super(ShareTest, self).setUp()
self.SHARE_NAME = self.getUniqueString()
my_share = self.create_share(
name=self.SHARE_NAME, size=2, share_type="dhss_false",
share_protocol='NFS', description=None)
name=self.SHARE_NAME,
size=2,
share_type="dhss_false",
share_protocol='NFS',
description=None,
)
self.SHARE_ID = my_share.id
self.SHARE_SIZE = my_share.size
my_share_snapshot = self.create_share_snapshot(
share_id=self.SHARE_ID
)
my_share_snapshot = self.create_share_snapshot(share_id=self.SHARE_ID)
self.SHARE_SNAPSHOT_ID = my_share_snapshot.id
def test_get(self):
@ -44,73 +45,73 @@ class ShareTest(base.BaseSharedFileSystemTest):
def test_update(self):
updated_share = self.user_cloud.share.update_share(
self.SHARE_ID, display_description='updated share')
get_updated_share = self.user_cloud.share.get_share(
updated_share.id)
self.SHARE_ID, display_description='updated share'
)
get_updated_share = self.user_cloud.share.get_share(updated_share.id)
self.assertEqual('updated share', get_updated_share.description)
def test_revert_share_to_snapshot(self):
self.user_cloud.share.revert_share_to_snapshot(
self.SHARE_ID, self.SHARE_SNAPSHOT_ID)
get_reverted_share = self.user_cloud.share.get_share(
self.SHARE_ID)
self.SHARE_ID, self.SHARE_SNAPSHOT_ID
)
get_reverted_share = self.user_cloud.share.get_share(self.SHARE_ID)
self.user_cloud.share.wait_for_status(
get_reverted_share,
status='available',
failures=['error'],
interval=5,
wait=self._wait_for_timeout)
wait=self._wait_for_timeout,
)
self.assertIsNotNone(get_reverted_share.id)
def test_resize_share_larger(self):
larger_size = 3
self.user_cloud.share.resize_share(
self.SHARE_ID, larger_size)
self.user_cloud.share.resize_share(self.SHARE_ID, larger_size)
get_resized_share = self.user_cloud.share.get_share(
self.SHARE_ID)
get_resized_share = self.user_cloud.share.get_share(self.SHARE_ID)
self.user_cloud.share.wait_for_status(
get_resized_share,
status='available',
failures=['error'],
interval=5,
wait=self._wait_for_timeout)
wait=self._wait_for_timeout,
)
self.assertEqual(larger_size, get_resized_share.size)
def test_resize_share_smaller(self):
# Resize to 3 GiB
smaller_size = 1
self.user_cloud.share.resize_share(
self.SHARE_ID, smaller_size)
self.user_cloud.share.resize_share(self.SHARE_ID, smaller_size)
get_resized_share = self.user_cloud.share.get_share(
self.SHARE_ID)
get_resized_share = self.user_cloud.share.get_share(self.SHARE_ID)
self.user_cloud.share.wait_for_status(
get_resized_share,
status='available',
failures=['error'],
interval=5,
wait=self._wait_for_timeout)
wait=self._wait_for_timeout,
)
self.assertEqual(smaller_size, get_resized_share.size)
def test_resize_share_larger_no_extend(self):
larger_size = 3
self.user_cloud.share.resize_share(
self.SHARE_ID, larger_size, no_extend=True)
self.SHARE_ID, larger_size, no_extend=True
)
get_resized_share = self.user_cloud.share.get_share(
self.SHARE_ID)
get_resized_share = self.user_cloud.share.get_share(self.SHARE_ID)
self.user_cloud.share.wait_for_status(
get_resized_share,
status='available',
failures=['error'],
interval=5,
wait=self._wait_for_timeout)
wait=self._wait_for_timeout,
)
# Assert that no change was made.
self.assertEqual(self.SHARE_SIZE, get_resized_share.size)
@ -119,17 +120,18 @@ class ShareTest(base.BaseSharedFileSystemTest):
smaller_size = 1
self.user_cloud.share.resize_share(
self.SHARE_ID, smaller_size, no_shrink=True)
self.SHARE_ID, smaller_size, no_shrink=True
)
get_resized_share = self.user_cloud.share.get_share(
self.SHARE_ID)
get_resized_share = self.user_cloud.share.get_share(self.SHARE_ID)
self.user_cloud.share.wait_for_status(
get_resized_share,
status='available',
failures=['error'],
interval=5,
wait=self._wait_for_timeout)
wait=self._wait_for_timeout,
)
# Assert that no change was made.
self.assertEqual(self.SHARE_SIZE, get_resized_share.size)
@ -138,15 +140,16 @@ class ShareTest(base.BaseSharedFileSystemTest):
# Resize to 3 GiB
larger_size = 3
self.user_cloud.share.resize_share(
self.SHARE_ID, larger_size, force=True)
self.SHARE_ID, larger_size, force=True
)
get_resized_share = self.user_cloud.share.get_share(
self.SHARE_ID)
get_resized_share = self.user_cloud.share.get_share(self.SHARE_ID)
self.user_cloud.share.wait_for_status(
get_resized_share,
status='available',
failures=['error'],
interval=5,
wait=self._wait_for_timeout)
wait=self._wait_for_timeout,
)
self.assertEqual(larger_size, get_resized_share.size)

View File

@ -14,20 +14,24 @@ from openstack.tests.functional.shared_file_system import base
class ShareAccessRuleTest(base.BaseSharedFileSystemTest):
def setUp(self):
super(ShareAccessRuleTest, self).setUp()
self.SHARE_NAME = self.getUniqueString()
mys = self.create_share(
name=self.SHARE_NAME, size=2, share_type="dhss_false",
share_protocol='NFS', description=None)
name=self.SHARE_NAME,
size=2,
share_type="dhss_false",
share_protocol='NFS',
description=None,
)
self.user_cloud.shared_file_system.wait_for_status(
mys,
status='available',
failures=['error'],
interval=5,
wait=self._wait_for_timeout)
wait=self._wait_for_timeout,
)
self.assertIsNotNone(mys)
self.assertIsNotNone(mys.id)
self.SHARE_ID = mys.id
@ -36,16 +40,14 @@ class ShareAccessRuleTest(base.BaseSharedFileSystemTest):
self.SHARE_ID,
access_level="rw",
access_type="ip",
access_to="0.0.0.0/0"
access_to="0.0.0.0/0",
)
self.ACCESS_ID = access_rule.id
self.RESOURCE_KEY = access_rule.resource_key
def tearDown(self):
acr = self.user_cloud.share.delete_access_rule(
self.ACCESS_ID,
self.SHARE_ID,
ignore_missing=True
self.ACCESS_ID, self.SHARE_ID, ignore_missing=True
)
self.assertIsNone(acr)
@ -59,12 +61,19 @@ class ShareAccessRuleTest(base.BaseSharedFileSystemTest):
def test_list_access_rules(self):
rules = self.user_cloud.shared_file_system.access_rules(
self.SHARE,
details=True
self.SHARE, details=True
)
self.assertGreater(len(list(rules)), 0)
for rule in rules:
for attribute in ('id', 'created_at', 'updated_at',
'access_level', 'access_type', 'access_to',
'share_id', 'access_key', 'metadata'):
for attribute in (
'id',
'created_at',
'updated_at',
'access_level',
'access_type',
'access_to',
'share_id',
'access_key',
'metadata',
):
self.assertTrue(hasattr(rule, attribute))

View File

@ -25,8 +25,12 @@ class ShareInstanceTest(base.BaseSharedFileSystemTest):
self.SHARE_NAME = self.getUniqueString()
my_share = self.create_share(
name=self.SHARE_NAME, size=2, share_type="dhss_false",
share_protocol='NFS', description=None)
name=self.SHARE_NAME,
size=2,
share_type="dhss_false",
share_protocol='NFS',
description=None,
)
self.SHARE_ID = my_share.id
instances_list = self.operator_cloud.share.share_instances()
self.SHARE_INSTANCE_ID = None
@ -36,7 +40,8 @@ class ShareInstanceTest(base.BaseSharedFileSystemTest):
def test_get(self):
sot = self.operator_cloud.share.get_share_instance(
self.SHARE_INSTANCE_ID)
self.SHARE_INSTANCE_ID
)
assert isinstance(sot, _share_instance.ShareInstance)
self.assertEqual(self.SHARE_INSTANCE_ID, sot.id)
@ -44,25 +49,36 @@ class ShareInstanceTest(base.BaseSharedFileSystemTest):
share_instances = self.operator_cloud.share.share_instances()
self.assertGreater(len(list(share_instances)), 0)
for share_instance in share_instances:
for attribute in ('id', 'name', 'created_at',
'access_rules_status',
'availability_zone'):
for attribute in (
'id',
'name',
'created_at',
'access_rules_status',
'availability_zone',
):
self.assertTrue(hasattr(share_instance, attribute))
def test_reset(self):
res = self.operator_cloud.share.reset_share_instance_status(
self.SHARE_INSTANCE_ID, 'error')
self.SHARE_INSTANCE_ID, 'error'
)
self.assertIsNone(res)
sot = self.operator_cloud.share.get_share_instance(
self.SHARE_INSTANCE_ID)
self.SHARE_INSTANCE_ID
)
self.assertEqual('error', sot.status)
def test_delete(self):
sot = self.operator_cloud.share.get_share_instance(
self.SHARE_INSTANCE_ID)
self.SHARE_INSTANCE_ID
)
fdel = self.operator_cloud.share.delete_share_instance(
self.SHARE_INSTANCE_ID)
resource.wait_for_delete(self.operator_cloud.share, sot,
wait=self._wait_for_timeout,
interval=2)
self.SHARE_INSTANCE_ID
)
resource.wait_for_delete(
self.operator_cloud.share,
sot,
wait=self._wait_for_timeout,
interval=2,
)
self.assertIsNone(fdel)

View File

@ -15,27 +15,28 @@ from openstack.tests.functional.shared_file_system import base
class ShareNetworkTest(base.BaseSharedFileSystemTest):
def setUp(self):
super(ShareNetworkTest, self).setUp()
self.SHARE_NETWORK_NAME = self.getUniqueString()
snt = self.user_cloud.shared_file_system.create_share_network(
name=self.SHARE_NETWORK_NAME)
name=self.SHARE_NETWORK_NAME
)
self.assertIsNotNone(snt)
self.assertIsNotNone(snt.id)
self.SHARE_NETWORK_ID = snt.id
def tearDown(self):
sot = self.user_cloud.shared_file_system.delete_share_network(
self.SHARE_NETWORK_ID,
ignore_missing=True)
self.SHARE_NETWORK_ID, ignore_missing=True
)
self.assertIsNone(sot)
super(ShareNetworkTest, self).tearDown()
def test_get(self):
sot = self.user_cloud.shared_file_system.get_share_network(
self.SHARE_NETWORK_ID)
self.SHARE_NETWORK_ID
)
assert isinstance(sot, _share_network.ShareNetwork)
self.assertEqual(self.SHARE_NETWORK_ID, sot.id)
@ -50,12 +51,13 @@ class ShareNetworkTest(base.BaseSharedFileSystemTest):
def test_delete_share_network(self):
sot = self.user_cloud.shared_file_system.delete_share_network(
self.SHARE_NETWORK_ID)
self.SHARE_NETWORK_ID
)
self.assertIsNone(sot)
def test_update(self):
unt = self.user_cloud.shared_file_system.update_share_network(
self.SHARE_NETWORK_ID, description='updated share network')
get_unt = self.user_cloud.shared_file_system.get_share_network(
unt.id)
self.SHARE_NETWORK_ID, description='updated share network'
)
get_unt = self.user_cloud.shared_file_system.get_share_network(unt.id)
self.assertEqual('updated share network', get_unt.description)

View File

@ -11,65 +11,76 @@
# under the License.
from openstack.shared_file_system.v2 import (
share_network_subnet as _share_network_subnet
share_network_subnet as _share_network_subnet,
)
from openstack.tests.functional.shared_file_system import base
class ShareNetworkSubnetTest(base.BaseSharedFileSystemTest):
def setUp(self):
super().setUp()
zones = self.user_cloud.shared_file_system.\
availability_zones()
zones = self.user_cloud.shared_file_system.availability_zones()
first_zone = next(zones)
self.SHARE_NETWORK_NAME = self.getUniqueString()
snt = self.user_cloud.shared_file_system.create_share_network(
name=self.SHARE_NETWORK_NAME)
name=self.SHARE_NETWORK_NAME
)
self.assertIsNotNone(snt)
self.assertIsNotNone(snt.id)
self.SHARE_NETWORK_ID = snt.id
snsb = self.user_cloud.shared_file_system.\
create_share_network_subnet(self.SHARE_NETWORK_ID,
availability_zone=first_zone.name)
snsb = self.user_cloud.shared_file_system.create_share_network_subnet(
self.SHARE_NETWORK_ID, availability_zone=first_zone.name
)
self.assertIsNotNone(snsb)
self.assertIsNotNone(snsb.id)
self.SHARE_NETWORK_SUBNET_ID = snsb.id
def tearDown(self):
subnet = self.user_cloud.shared_file_system.\
get_share_network_subnet(self.SHARE_NETWORK_ID,
self.SHARE_NETWORK_SUBNET_ID)
fdel = self.user_cloud.shared_file_system.\
delete_share_network_subnet(self.SHARE_NETWORK_ID,
self.SHARE_NETWORK_SUBNET_ID,
ignore_missing=True)
subnet = self.user_cloud.shared_file_system.get_share_network_subnet(
self.SHARE_NETWORK_ID, self.SHARE_NETWORK_SUBNET_ID
)
fdel = self.user_cloud.shared_file_system.delete_share_network_subnet(
self.SHARE_NETWORK_ID,
self.SHARE_NETWORK_SUBNET_ID,
ignore_missing=True,
)
self.assertIsNone(fdel)
self.user_cloud.shared_file_system.\
wait_for_delete(subnet)
sot = self.user_cloud.shared_file_system.\
delete_share_network(self.SHARE_NETWORK_ID,
ignore_missing=True)
self.user_cloud.shared_file_system.wait_for_delete(subnet)
sot = self.user_cloud.shared_file_system.delete_share_network(
self.SHARE_NETWORK_ID, ignore_missing=True
)
self.assertIsNone(sot)
super().tearDown()
def test_get(self):
sub = self.user_cloud.shared_file_system.\
get_share_network_subnet(self.SHARE_NETWORK_ID,
self.SHARE_NETWORK_SUBNET_ID)
sub = self.user_cloud.shared_file_system.get_share_network_subnet(
self.SHARE_NETWORK_ID, self.SHARE_NETWORK_SUBNET_ID
)
assert isinstance(sub, _share_network_subnet.ShareNetworkSubnet)
def test_list(self):
subs = self.user_cloud.shared_file_system.share_network_subnets(
self.SHARE_NETWORK_ID)
self.SHARE_NETWORK_ID
)
self.assertGreater(len(list(subs)), 0)
for sub in subs:
for attribute in ('id', 'name', 'created_at', 'updated_at',
'share_network_id', 'availability_zone',
'cidr', 'gateway', 'ip_version', 'mtu',
'network_type', 'neutron_net_id',
'neutron_subnet_id', 'segmentation_id',