Transform share and share servers statuses to lowercase
We have several entities in Manila that do have statuses: - Shares - Snapshots - Share Servers - Share Access Rules But some share and all share server statuses use uppercase for it. Make all of them consistent and transform them to lowercase. Add migrations for it. Also, remove two unused statuses and reuse all statuses from common place. Change-Id: I53e6a768c98977d3d94e761349b7446a9dfb4936 Closes-Bug: #1459598
This commit is contained in:
parent
df6ca7ee5f
commit
0a7f44ad07
@ -125,7 +125,7 @@ class ManageNFSShareTest(base.BaseSharesAdminTest):
|
||||
def test_manage_retry(self):
|
||||
# Manage share with invalid parameters
|
||||
share = None
|
||||
parameters = [(self.st_invalid['share_type']['id'], 'MANAGE_ERROR'),
|
||||
parameters = [(self.st_invalid['share_type']['id'], 'manage_error'),
|
||||
(self.st['share_type']['id'], 'available')]
|
||||
|
||||
for share_type_id, status in parameters:
|
||||
|
@ -18,6 +18,7 @@ from webob import exc
|
||||
|
||||
from manila.api import extensions
|
||||
from manila.api.openstack import wsgi
|
||||
from manila.common import constants
|
||||
from manila import db
|
||||
from manila import exception
|
||||
from manila import share
|
||||
@ -31,11 +32,11 @@ class AdminController(wsgi.Controller):
|
||||
collection = None
|
||||
|
||||
valid_status = set([
|
||||
'creating',
|
||||
'available',
|
||||
'deleting',
|
||||
'error',
|
||||
'error_deleting',
|
||||
constants.STATUS_CREATING,
|
||||
constants.STATUS_AVAILABLE,
|
||||
constants.STATUS_DELETING,
|
||||
constants.STATUS_ERROR,
|
||||
constants.STATUS_ERROR_DELETING,
|
||||
])
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -85,7 +86,7 @@ class AdminController(wsgi.Controller):
|
||||
|
||||
@wsgi.action('os-force_delete')
|
||||
def _force_delete(self, req, id, body):
|
||||
"""Delete a resource, bypassing the check that it must be available."""
|
||||
"""Delete a resource, bypassing the check for status."""
|
||||
context = req.environ['manila.context']
|
||||
self.authorize(context, 'force_delete')
|
||||
try:
|
||||
|
@ -50,9 +50,7 @@ class ShareUnmanageController(wsgi.Controller):
|
||||
"that are created on top of share servers "
|
||||
"(created with share-networks).")
|
||||
raise exc.HTTPForbidden(explanation=msg)
|
||||
# NOTE(vponomaryov): use 'upper' translation because share
|
||||
# statuses not always used from common place yet.
|
||||
elif share['status'].upper() in constants.TRANSITIONAL_STATUSES:
|
||||
elif share['status'] in constants.TRANSITIONAL_STATUSES:
|
||||
msg = _("Share with transitional state can not be unmanaged. "
|
||||
"Share '%(s_id)s' is in '%(state)s' state.") % dict(
|
||||
state=share['status'], s_id=share['id'])
|
||||
|
@ -13,28 +13,25 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
STATUS_NEW = 'NEW'
|
||||
STATUS_CREATING = 'CREATING'
|
||||
STATUS_DELETING = 'DELETING'
|
||||
STATUS_DELETED = 'DELETED'
|
||||
STATUS_ERROR = 'ERROR'
|
||||
STATUS_ERROR_DELETING = 'ERROR_DELETING'
|
||||
STATUS_AVAILABLE = 'AVAILABLE'
|
||||
STATUS_ACTIVE = 'ACTIVE'
|
||||
STATUS_INACTIVE = 'INACTIVE'
|
||||
STATUS_ACTIVATING = 'ACTIVATING'
|
||||
STATUS_DEACTIVATING = 'DEACTIVATING'
|
||||
STATUS_MANAGING = 'MANAGE_STARTING'
|
||||
STATUS_MANAGE_ERROR = 'MANAGE_ERROR'
|
||||
STATUS_UNMANAGING = 'UNMANAGE_STARTING'
|
||||
STATUS_UNMANAGE_ERROR = 'UNMANAGE_ERROR'
|
||||
STATUS_UNMANAGED = 'UNMANAGED'
|
||||
STATUS_EXTENDING = 'EXTENDING'
|
||||
STATUS_EXTENDING_ERROR = 'EXTENDING_ERROR'
|
||||
STATUS_NEW = 'new'
|
||||
STATUS_CREATING = 'creating'
|
||||
STATUS_DELETING = 'deleting'
|
||||
STATUS_DELETED = 'deleted'
|
||||
STATUS_ERROR = 'error'
|
||||
STATUS_ERROR_DELETING = 'error_deleting'
|
||||
STATUS_AVAILABLE = 'available'
|
||||
STATUS_ACTIVE = 'active'
|
||||
STATUS_INACTIVE = 'inactive'
|
||||
STATUS_MANAGING = 'manage_starting'
|
||||
STATUS_MANAGE_ERROR = 'manage_error'
|
||||
STATUS_UNMANAGING = 'unmanage_starting'
|
||||
STATUS_UNMANAGE_ERROR = 'unmanage_error'
|
||||
STATUS_UNMANAGED = 'unmanaged'
|
||||
STATUS_EXTENDING = 'extending'
|
||||
STATUS_EXTENDING_ERROR = 'extending_error'
|
||||
|
||||
TRANSITIONAL_STATUSES = (
|
||||
STATUS_CREATING, STATUS_DELETING,
|
||||
STATUS_ACTIVATING, STATUS_DEACTIVATING,
|
||||
STATUS_MANAGING, STATUS_UNMANAGING,
|
||||
STATUS_EXTENDING,
|
||||
)
|
||||
|
@ -0,0 +1,53 @@
|
||||
# Copyright 2015 Mirantis Inc.
|
||||
# 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.
|
||||
|
||||
"""Transform statuses to lowercase
|
||||
|
||||
Revision ID: 3db9992c30f3
|
||||
Revises: 533646c7af38
|
||||
Create Date: 2015-05-28 19:30:35.645773
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3db9992c30f3'
|
||||
down_revision = '533646c7af38'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from manila.db.sqlalchemy import models
|
||||
|
||||
|
||||
def upgrade():
|
||||
# NOTE(vponomaryov): shares has some statuses as uppercase, so
|
||||
# transform them in addition to statuses of share servers.
|
||||
for model in (models.Share, models.ShareServer):
|
||||
_transform_case(model, make_upper=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
# NOTE(vponomaryov): transform share server statuses to uppercase and
|
||||
# leave share statuses as is.
|
||||
_transform_case(models.ShareServer, make_upper=True)
|
||||
|
||||
|
||||
def _transform_case(model, make_upper):
|
||||
connection = op.get_bind()
|
||||
session = sa.orm.Session(bind=connection.connect())
|
||||
case = sa.func.upper if make_upper else sa.func.lower
|
||||
session.query(model).update(
|
||||
{model.status: case(model.status)}, synchronize_session='fetch')
|
||||
session.commit()
|
@ -284,11 +284,11 @@ class ShareMetadata(BASE, ManilaBase):
|
||||
|
||||
class ShareAccessMapping(BASE, ManilaBase):
|
||||
"""Represents access to NFS."""
|
||||
STATE_NEW = 'new'
|
||||
STATE_ACTIVE = 'active'
|
||||
STATE_DELETING = 'deleting'
|
||||
STATE_DELETED = 'deleted'
|
||||
STATE_ERROR = 'error'
|
||||
STATE_NEW = constants.STATUS_NEW
|
||||
STATE_ACTIVE = constants.STATUS_ACTIVE
|
||||
STATE_DELETING = constants.STATUS_DELETING
|
||||
STATE_DELETED = constants.STATUS_DELETED
|
||||
STATE_ERROR = constants.STATUS_ERROR
|
||||
|
||||
__tablename__ = 'share_access_map'
|
||||
id = Column(String(36), primary_key=True)
|
||||
|
@ -73,8 +73,8 @@ class API(base.Base):
|
||||
self._check_metadata_properties(context, metadata)
|
||||
|
||||
if snapshot is not None:
|
||||
if snapshot['status'] != 'available':
|
||||
msg = _("status must be 'available'")
|
||||
if snapshot['status'] != constants.STATUS_AVAILABLE:
|
||||
msg = _("status must be '%s'") % constants.STATUS_AVAILABLE
|
||||
raise exception.InvalidShareSnapshot(reason=msg)
|
||||
if not size:
|
||||
size = snapshot['size']
|
||||
@ -175,7 +175,7 @@ class API(base.Base):
|
||||
'share_network_id': share_network_id,
|
||||
'availability_zone': availability_zone,
|
||||
'metadata': metadata,
|
||||
'status': "creating",
|
||||
'status': constants.STATUS_CREATING,
|
||||
'scheduled_at': timeutils.utcnow(),
|
||||
'display_name': name,
|
||||
'display_description': description,
|
||||
@ -306,8 +306,10 @@ class API(base.Base):
|
||||
QUOTAS.commit(context, reservations, project_id=project_id)
|
||||
return
|
||||
|
||||
if not (force or share['status'] in ["available", "error"]):
|
||||
msg = _("Share status must be available or error")
|
||||
statuses = (constants.STATUS_AVAILABLE, constants.STATUS_ERROR)
|
||||
if not (force or share['status'] in statuses):
|
||||
msg = _("Share status must be one of %(statuses)s") % {
|
||||
"statuses": statuses}
|
||||
raise exception.InvalidShare(reason=msg)
|
||||
|
||||
snapshots = self.db.share_snapshot_get_all_for_share(context, share_id)
|
||||
@ -316,7 +318,8 @@ class API(base.Base):
|
||||
raise exception.InvalidShare(reason=msg)
|
||||
|
||||
now = timeutils.utcnow()
|
||||
share = self.db.share_update(context, share_id, {'status': 'deleting',
|
||||
share = self.db.share_update(
|
||||
context, share_id, {'status': constants.STATUS_DELETING,
|
||||
'terminated_at': now})
|
||||
|
||||
self.share_rpcapi.delete_share(context, share)
|
||||
@ -350,8 +353,9 @@ class API(base.Base):
|
||||
force=False):
|
||||
policy.check_policy(context, 'share', 'create_snapshot', share)
|
||||
|
||||
if ((not force) and (share['status'] != "available")):
|
||||
msg = _("must be available")
|
||||
if ((not force) and (share['status'] != constants.STATUS_AVAILABLE)):
|
||||
msg = _("Source share status must be "
|
||||
"%s") % constants.STATUS_AVAILABLE
|
||||
raise exception.InvalidShare(reason=msg)
|
||||
|
||||
size = share['size']
|
||||
@ -388,7 +392,7 @@ class API(base.Base):
|
||||
'size': share['size'],
|
||||
'user_id': context.user_id,
|
||||
'project_id': context.project_id,
|
||||
'status': "creating",
|
||||
'status': constants.STATUS_CREATING,
|
||||
'progress': '0%',
|
||||
'share_size': share['size'],
|
||||
'display_name': name,
|
||||
@ -410,12 +414,14 @@ class API(base.Base):
|
||||
|
||||
@policy.wrap_check_policy('share')
|
||||
def delete_snapshot(self, context, snapshot, force=False):
|
||||
if not (force or snapshot['status'] in ["available", "error"]):
|
||||
msg = _("Share Snapshot status must be 'available' or 'error'.")
|
||||
statuses = (constants.STATUS_AVAILABLE, constants.STATUS_ERROR)
|
||||
if not (force or snapshot['status'] in statuses):
|
||||
msg = _("Share Snapshot status must be one of %(statuses)s.") % {
|
||||
"statuses": statuses}
|
||||
raise exception.InvalidShareSnapshot(reason=msg)
|
||||
|
||||
self.db.share_snapshot_update(context, snapshot['id'],
|
||||
{'status': 'deleting'})
|
||||
{'status': constants.STATUS_DELETING})
|
||||
share = self.db.share_get(context, snapshot['share_id'])
|
||||
self.share_rpcapi.delete_snapshot(context, snapshot, share['host'])
|
||||
|
||||
@ -557,8 +563,8 @@ class API(base.Base):
|
||||
if not share['host']:
|
||||
msg = _("Share host is None")
|
||||
raise exception.InvalidShare(reason=msg)
|
||||
if share['status'] not in ["available"]:
|
||||
msg = _("Share status must be available")
|
||||
if share['status'] != constants.STATUS_AVAILABLE:
|
||||
msg = _("Share status must be %s") % constants.STATUS_AVAILABLE
|
||||
raise exception.InvalidShare(reason=msg)
|
||||
policy.check_policy(ctx, 'share', 'allow_access')
|
||||
values = {
|
||||
@ -567,9 +573,9 @@ class API(base.Base):
|
||||
'access_to': access_to,
|
||||
'access_level': access_level,
|
||||
}
|
||||
access = [a for a in self.db.share_access_get_all_by_type_and_access(
|
||||
ctx, share['id'], access_type, access_to) if a['state'] != 'error']
|
||||
if access:
|
||||
for access in self.db.share_access_get_all_by_type_and_access(
|
||||
ctx, share['id'], access_type, access_to):
|
||||
if access['state'] != constants.STATUS_ERROR:
|
||||
raise exception.ShareAccessExists(access_type=access_type,
|
||||
access=access_to)
|
||||
if access_level not in constants.ACCESS_LEVELS + (None, ):
|
||||
@ -586,8 +592,8 @@ class API(base.Base):
|
||||
if not share['host']:
|
||||
msg = _("Share host is None")
|
||||
raise exception.InvalidShare(reason=msg)
|
||||
if share['status'] not in ["available"]:
|
||||
msg = _("Share status must be available")
|
||||
if share['status'] != constants.STATUS_AVAILABLE:
|
||||
msg = _("Share status must be %s") % constants.STATUS_AVAILABLE
|
||||
raise exception.InvalidShare(reason=msg)
|
||||
|
||||
# Then check state of the access rule
|
||||
@ -598,7 +604,9 @@ class API(base.Base):
|
||||
{'state': access.STATE_DELETING})
|
||||
self.share_rpcapi.deny_access(ctx, share, access)
|
||||
else:
|
||||
msg = _("Access policy should be active or in error state")
|
||||
msg = _("Access policy should be %(active)s or in %(error)s "
|
||||
"state") % {"active": constants.STATUS_ACTIVE,
|
||||
"error": constants.STATUS_ERROR}
|
||||
raise exception.InvalidShareAccess(reason=msg)
|
||||
# update share state and send message to manager
|
||||
|
||||
@ -679,13 +687,11 @@ class API(base.Base):
|
||||
def extend(self, context, share, new_size):
|
||||
policy.check_policy(context, 'share', 'extend')
|
||||
|
||||
status = six.text_type(share['status']).upper()
|
||||
|
||||
if status != constants.STATUS_AVAILABLE:
|
||||
if share['status'] != constants.STATUS_AVAILABLE:
|
||||
msg_params = {
|
||||
'valid_status': constants.STATUS_AVAILABLE,
|
||||
'share_id': share['id'],
|
||||
'status': status,
|
||||
'status': share['status'],
|
||||
}
|
||||
msg = _("Share %(share_id)s status must be '%(valid_status)s' "
|
||||
"to extend, but current status is: "
|
||||
|
@ -439,7 +439,8 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
||||
t = time.time()
|
||||
while time.time() - t < self.configuration.max_time_to_attach:
|
||||
volume = self.volume_api.get(context, volume['id'])
|
||||
if volume['status'] in ('available', 'error'):
|
||||
if volume['status'] in (const.STATUS_AVAILABLE,
|
||||
const.STATUS_ERROR):
|
||||
break
|
||||
time.sleep(1)
|
||||
else:
|
||||
@ -467,9 +468,9 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
||||
|
||||
t = time.time()
|
||||
while time.time() - t < self.configuration.max_time_to_create_volume:
|
||||
if volume['status'] == 'available':
|
||||
if volume['status'] == const.STATUS_AVAILABLE:
|
||||
break
|
||||
if volume['status'] == 'error':
|
||||
if volume['status'] == const.STATUS_ERROR:
|
||||
raise exception.ManilaException(_('Failed to create volume'))
|
||||
time.sleep(1)
|
||||
volume = self.volume_api.get(context, volume['id'])
|
||||
@ -562,9 +563,9 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
||||
self.admin_context, volume['id'], volume_snapshot_name, '')
|
||||
t = time.time()
|
||||
while time.time() - t < self.configuration.max_time_to_create_volume:
|
||||
if volume_snapshot['status'] == 'available':
|
||||
if volume_snapshot['status'] == const.STATUS_AVAILABLE:
|
||||
break
|
||||
if volume_snapshot['status'] == 'error':
|
||||
if volume_snapshot['status'] == const.STATUS_ERROR:
|
||||
raise exception.ManilaException(_('Failed to create volume '
|
||||
'snapshot'))
|
||||
time.sleep(1)
|
||||
|
@ -155,7 +155,7 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
shares = self.db.share_get_all_by_host(ctxt, self.host)
|
||||
LOG.debug("Re-exporting %s shares", len(shares))
|
||||
for share in shares:
|
||||
if share['status'] != 'available':
|
||||
if share['status'] != constants.STATUS_AVAILABLE:
|
||||
LOG.info(
|
||||
_LI("Share %(name)s: skipping export, because it has "
|
||||
"'%(status)s' status."),
|
||||
@ -279,7 +279,8 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
share_network_id = share_ref.get('share_network_id', None)
|
||||
|
||||
if share_network_id and not self.driver.driver_handles_share_servers:
|
||||
self.db.share_update(context, share_id, {'status': 'error'})
|
||||
self.db.share_update(
|
||||
context, share_id, {'status': constants.STATUS_ERROR})
|
||||
raise exception.ManilaException(
|
||||
"Driver does not expect share-network to be provided "
|
||||
"with current configuration.")
|
||||
@ -304,7 +305,7 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
LOG.error(_LE("Share server %s does not exist."),
|
||||
parent_share_server_id)
|
||||
self.db.share_update(context, share_id,
|
||||
{'status': 'error'})
|
||||
{'status': constants.STATUS_ERROR})
|
||||
elif share_network_id:
|
||||
try:
|
||||
share_server, share_ref = self._provide_share_server_for_share(
|
||||
@ -314,7 +315,7 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
LOG.error(_LE("Failed to get share server"
|
||||
" for share creation."))
|
||||
self.db.share_update(context, share_id,
|
||||
{'status': 'error'})
|
||||
{'status': constants.STATUS_ERROR})
|
||||
else:
|
||||
share_server = None
|
||||
|
||||
@ -351,11 +352,12 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
'can not be written to db because it '
|
||||
'contains %s and it is not a dictionary.'),
|
||||
detail_data)
|
||||
self.db.share_update(context, share_id, {'status': 'error'})
|
||||
self.db.share_update(
|
||||
context, share_id, {'status': constants.STATUS_ERROR})
|
||||
else:
|
||||
LOG.info(_LI("Share created successfully."))
|
||||
self.db.share_update(context, share_id,
|
||||
{'status': 'available',
|
||||
{'status': constants.STATUS_AVAILABLE,
|
||||
'launched_at': timeutils.utcnow()})
|
||||
|
||||
def manage_share(self, context, share_id, driver_options):
|
||||
@ -382,7 +384,7 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
})
|
||||
|
||||
share_update.update({
|
||||
'status': 'available',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'launched_at': timeutils.utcnow(),
|
||||
})
|
||||
|
||||
@ -490,8 +492,10 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
share_server=share_server)
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
self.db.share_update(context, share_id,
|
||||
{'status': 'error_deleting'})
|
||||
self.db.share_update(
|
||||
context,
|
||||
share_id,
|
||||
{'status': constants.STATUS_ERROR_DELETING})
|
||||
try:
|
||||
reservations = QUOTAS.reserve(context,
|
||||
project_id=project_id,
|
||||
@ -552,13 +556,14 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
self.db.share_snapshot_update(context,
|
||||
self.db.share_snapshot_update(
|
||||
context,
|
||||
snapshot_ref['id'],
|
||||
{'status': 'error'})
|
||||
{'status': constants.STATUS_ERROR})
|
||||
|
||||
self.db.share_snapshot_update(context,
|
||||
snapshot_ref['id'],
|
||||
{'status': 'available',
|
||||
{'status': constants.STATUS_AVAILABLE,
|
||||
'progress': '100%'})
|
||||
return snapshot_id
|
||||
|
||||
@ -579,12 +584,16 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
self.driver.delete_snapshot(context, snapshot_ref,
|
||||
share_server=share_server)
|
||||
except exception.ShareSnapshotIsBusy:
|
||||
self.db.share_snapshot_update(context, snapshot_ref['id'],
|
||||
{'status': 'available'})
|
||||
self.db.share_snapshot_update(
|
||||
context,
|
||||
snapshot_ref['id'],
|
||||
{'status': constants.STATUS_AVAILABLE})
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
self.db.share_snapshot_update(context, snapshot_ref['id'],
|
||||
{'status': 'error_deleting'})
|
||||
self.db.share_snapshot_update(
|
||||
context,
|
||||
snapshot_ref['id'],
|
||||
{'status': constants.STATUS_ERROR_DELETING})
|
||||
else:
|
||||
self.db.share_snapshot_destroy(context, snapshot_id)
|
||||
try:
|
||||
|
@ -17,6 +17,7 @@ from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
import webob
|
||||
|
||||
from manila.common import constants
|
||||
from manila import context
|
||||
from manila import db
|
||||
from manila import exception
|
||||
@ -47,12 +48,14 @@ class AdminActionsTest(test.TestCase):
|
||||
|
||||
def test_reset_status_as_admin(self):
|
||||
# current status is available
|
||||
share = db.share_create(self.admin_context, {'status': 'available'})
|
||||
share = db.share_create(
|
||||
self.admin_context, {'status': constants.STATUS_AVAILABLE})
|
||||
req = webob.Request.blank('/v1/fake/shares/%s/action' % share['id'])
|
||||
req.method = 'POST'
|
||||
req.headers['content-type'] = 'application/json'
|
||||
# request status of 'error'
|
||||
req.body = jsonutils.dumps({'os-reset_status': {'status': 'error'}})
|
||||
req.body = jsonutils.dumps(
|
||||
{'os-reset_status': {'status': constants.STATUS_ERROR}})
|
||||
# attach admin context to request
|
||||
req.environ['manila.context'] = self.admin_context
|
||||
resp = req.get_response(app())
|
||||
@ -60,18 +63,18 @@ class AdminActionsTest(test.TestCase):
|
||||
self.assertEqual(resp.status_int, 202)
|
||||
share = db.share_get(self.admin_context, share['id'])
|
||||
# status changed to 'error'
|
||||
self.assertEqual(share['status'], 'error')
|
||||
self.assertEqual(share['status'], constants.STATUS_ERROR)
|
||||
|
||||
def test_reset_status_as_non_admin(self):
|
||||
# current status is 'error'
|
||||
share = db.share_create(context.get_admin_context(),
|
||||
{'status': 'error'})
|
||||
{'status': constants.STATUS_ERROR})
|
||||
req = webob.Request.blank('/v1/fake/shares/%s/action' % share['id'])
|
||||
req.method = 'POST'
|
||||
req.headers['content-type'] = 'application/json'
|
||||
# request changing status to available
|
||||
req.body = jsonutils.dumps({'os-reset_status': {'status':
|
||||
'available'}})
|
||||
req.body = jsonutils.dumps(
|
||||
{'os-reset_status': {'status': constants.STATUS_AVAILABLE}})
|
||||
# non-admin context
|
||||
req.environ['manila.context'] = self.member_context
|
||||
resp = req.get_response(app())
|
||||
@ -79,11 +82,12 @@ class AdminActionsTest(test.TestCase):
|
||||
self.assertEqual(resp.status_int, 403)
|
||||
share = db.share_get(context.get_admin_context(), share['id'])
|
||||
# status is still 'error'
|
||||
self.assertEqual(share['status'], 'error')
|
||||
self.assertEqual(share['status'], constants.STATUS_ERROR)
|
||||
|
||||
def test_malformed_reset_status_body(self):
|
||||
# current status is available
|
||||
share = db.share_create(self.admin_context, {'status': 'available'})
|
||||
share = db.share_create(
|
||||
self.admin_context, {'status': constants.STATUS_AVAILABLE})
|
||||
req = webob.Request.blank('/v1/fake/shares/%s/action' % share['id'])
|
||||
req.method = 'POST'
|
||||
req.headers['content-type'] = 'application/json'
|
||||
@ -96,11 +100,12 @@ class AdminActionsTest(test.TestCase):
|
||||
self.assertEqual(resp.status_int, 400)
|
||||
share = db.share_get(self.admin_context, share['id'])
|
||||
# status is still 'available'
|
||||
self.assertEqual(share['status'], 'available')
|
||||
self.assertEqual(share['status'], constants.STATUS_AVAILABLE)
|
||||
|
||||
def test_invalid_status_for_share(self):
|
||||
# current status is available
|
||||
share = db.share_create(self.admin_context, {'status': 'available'})
|
||||
share = db.share_create(
|
||||
self.admin_context, {'status': constants.STATUS_AVAILABLE})
|
||||
req = webob.Request.blank('/v1/fake/shares/%s/action' % share['id'])
|
||||
req.method = 'POST'
|
||||
req.headers['content-type'] = 'application/json'
|
||||
@ -113,7 +118,7 @@ class AdminActionsTest(test.TestCase):
|
||||
self.assertEqual(resp.status_int, 400)
|
||||
share = db.share_get(self.admin_context, share['id'])
|
||||
# status is still 'available'
|
||||
self.assertEqual(share['status'], 'available')
|
||||
self.assertEqual(share['status'], constants.STATUS_AVAILABLE)
|
||||
|
||||
def test_reset_status_for_missing_share(self):
|
||||
# missing-share-id
|
||||
@ -122,8 +127,8 @@ class AdminActionsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.headers['content-type'] = 'application/json'
|
||||
# malformed request body
|
||||
req.body = jsonutils.dumps({'os-reset_status': {'status':
|
||||
'available'}})
|
||||
req.body = jsonutils.dumps(
|
||||
{'os-reset_status': {'status': constants.STATUS_AVAILABLE}})
|
||||
# attach admin context to request
|
||||
req.environ['manila.context'] = self.admin_context
|
||||
resp = req.get_response(app())
|
||||
@ -137,17 +142,17 @@ class AdminActionsTest(test.TestCase):
|
||||
def test_snapshot_reset_status(self):
|
||||
# snapshot in 'error_deleting'
|
||||
share = db.share_create(self.admin_context, {})
|
||||
snapshot = db.share_snapshot_create(self.admin_context,
|
||||
{
|
||||
'status': 'error_deleting',
|
||||
'share_id': share['id']
|
||||
})
|
||||
snapshot = db.share_snapshot_create(
|
||||
self.admin_context,
|
||||
{'status': constants.STATUS_ERROR_DELETING,
|
||||
'share_id': share['id']})
|
||||
req = webob.Request.blank('/v1/fake/snapshots/%s/action' %
|
||||
snapshot['id'])
|
||||
req.method = 'POST'
|
||||
req.headers['content-type'] = 'application/json'
|
||||
# request status of 'error'
|
||||
req.body = jsonutils.dumps({'os-reset_status': {'status': 'error'}})
|
||||
req.body = jsonutils.dumps(
|
||||
{'os-reset_status': {'status': constants.STATUS_ERROR}})
|
||||
# attach admin context to request
|
||||
req.environ['manila.context'] = self.admin_context
|
||||
resp = req.get_response(app())
|
||||
@ -155,16 +160,14 @@ class AdminActionsTest(test.TestCase):
|
||||
self.assertEqual(resp.status_int, 202)
|
||||
snapshot = db.share_snapshot_get(self.admin_context, snapshot['id'])
|
||||
# status changed to 'error'
|
||||
self.assertEqual(snapshot['status'], 'error')
|
||||
self.assertEqual(snapshot['status'], constants.STATUS_ERROR)
|
||||
|
||||
def test_invalid_status_for_snapshot(self):
|
||||
# snapshot in 'available'
|
||||
share = db.share_create(self.admin_context, {})
|
||||
snapshot = db.share_snapshot_create(self.admin_context,
|
||||
{
|
||||
'status': 'available',
|
||||
'share_id': share['id']
|
||||
})
|
||||
snapshot = db.share_snapshot_create(
|
||||
self.admin_context,
|
||||
{'status': constants.STATUS_AVAILABLE, 'share_id': share['id']})
|
||||
req = webob.Request.blank('/v1/fake/snapshots/%s/action' %
|
||||
snapshot['id'])
|
||||
req.method = 'POST'
|
||||
@ -179,7 +182,7 @@ class AdminActionsTest(test.TestCase):
|
||||
self.assertEqual(resp.status_int, 400)
|
||||
snapshot = db.share_snapshot_get(self.admin_context, snapshot['id'])
|
||||
# status is still 'available'
|
||||
self.assertEqual(snapshot['status'], 'available')
|
||||
self.assertEqual(snapshot['status'], constants.STATUS_AVAILABLE)
|
||||
|
||||
def test_admin_force_delete_share(self):
|
||||
share = db.share_create(self.admin_context, {'size': 1})
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import datetime
|
||||
|
||||
from manila.common import constants
|
||||
from manila import exception as exc
|
||||
|
||||
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
@ -106,7 +107,7 @@ def stub_volume_get_all_by_project(self, context, search_opts=None):
|
||||
def stub_snapshot(id, **kwargs):
|
||||
snapshot = {'id': id,
|
||||
'volume_id': 12,
|
||||
'status': 'available',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'volume_size': 100,
|
||||
'created_at': None,
|
||||
'display_name': 'Default name',
|
||||
|
@ -22,6 +22,7 @@ import webob
|
||||
|
||||
from manila.api import common
|
||||
from manila.api.v1 import shares
|
||||
from manila.common import constants
|
||||
from manila import context
|
||||
from manila import exception
|
||||
from manila.share import api as share_api
|
||||
@ -368,7 +369,7 @@ class ShareApiTest(test.TestCase):
|
||||
def _share_list_summary_with_search_opts(self, use_admin_context):
|
||||
search_opts = {
|
||||
'name': 'fake_name',
|
||||
'status': 'available',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'share_server_id': 'fake_share_server_id',
|
||||
'share_type_id': 'fake_share_type_id',
|
||||
'snapshot_id': 'fake_snapshot_id',
|
||||
@ -457,7 +458,7 @@ class ShareApiTest(test.TestCase):
|
||||
def _share_list_detail_with_search_opts(self, use_admin_context):
|
||||
search_opts = {
|
||||
'name': 'fake_name',
|
||||
'status': 'available',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'share_server_id': 'fake_share_server_id',
|
||||
'share_type_id': 'fake_share_type_id',
|
||||
'snapshot_id': 'fake_snapshot_id',
|
||||
@ -482,7 +483,7 @@ class ShareApiTest(test.TestCase):
|
||||
{
|
||||
'id': 'id2',
|
||||
'display_name': 'n2',
|
||||
'status': 'available',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'snapshot_id': 'fake_snapshot_id',
|
||||
'share_type_id': 'fake_share_type_id',
|
||||
'host': 'fake_host',
|
||||
|
@ -26,6 +26,7 @@ import ddt
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
|
||||
from manila.common import constants
|
||||
from manila import context
|
||||
from manila import exception
|
||||
from manila.share import configuration as config
|
||||
@ -83,10 +84,10 @@ class GlusterfsNativeShareDriverTestCase(test.TestCase):
|
||||
self.glusterfs_server2_volumes = 'manila-share-2-2G\nshare2'
|
||||
self.share1 = new_share(
|
||||
export_location=self.glusterfs_target1,
|
||||
status="available")
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
self.share2 = new_share(
|
||||
export_location=self.glusterfs_target2,
|
||||
status="available")
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
gmgr = glusterfs.GlusterManager
|
||||
self.gmgr1 = gmgr(self.glusterfs_server1, self._execute, None, None,
|
||||
has_volume=False)
|
||||
|
@ -109,25 +109,25 @@ def fake_access(id, **kwargs):
|
||||
_FAKE_LIST_OF_ALL_SHARES = [
|
||||
{
|
||||
'name': 'foo',
|
||||
'status': 'active',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'project_id': 'fake_pid_1',
|
||||
'share_server_id': 'fake_server_1',
|
||||
},
|
||||
{
|
||||
'name': 'bar',
|
||||
'status': 'error',
|
||||
'status': constants.STATUS_ERROR,
|
||||
'project_id': 'fake_pid_2',
|
||||
'share_server_id': 'fake_server_2',
|
||||
},
|
||||
{
|
||||
'name': 'foo',
|
||||
'status': 'active',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'project_id': 'fake_pid_2',
|
||||
'share_server_id': 'fake_server_3',
|
||||
},
|
||||
{
|
||||
'name': 'bar',
|
||||
'status': 'error',
|
||||
'status': constants.STATUS_ERROR,
|
||||
'project_id': 'fake_pid_2',
|
||||
'share_server_id': 'fake_server_3',
|
||||
},
|
||||
@ -137,25 +137,25 @@ _FAKE_LIST_OF_ALL_SHARES = [
|
||||
_FAKE_LIST_OF_ALL_SNAPSHOTS = [
|
||||
{
|
||||
'name': 'foo',
|
||||
'status': 'available',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'project_id': 'fake_pid_1',
|
||||
'share_id': 'fake_server_1',
|
||||
},
|
||||
{
|
||||
'name': 'bar',
|
||||
'status': 'error',
|
||||
'status': constants.STATUS_ERROR,
|
||||
'project_id': 'fake_pid_2',
|
||||
'share_id': 'fake_server_2',
|
||||
},
|
||||
{
|
||||
'name': 'foo',
|
||||
'status': 'available',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'project_id': 'fake_pid_2',
|
||||
'share_id': 'fake_share_id_3',
|
||||
},
|
||||
{
|
||||
'name': 'bar',
|
||||
'status': 'error',
|
||||
'status': constants.STATUS_ERROR,
|
||||
'project_id': 'fake_pid_2',
|
||||
'share_id': 'fake_share_id_3',
|
||||
},
|
||||
@ -276,7 +276,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
ctx = context.RequestContext('fake_uid', 'fake_pid_2', is_admin=True)
|
||||
self.mock_object(db_driver, 'share_get_all_by_project',
|
||||
mock.Mock(return_value=_FAKE_LIST_OF_ALL_SHARES[1:]))
|
||||
shares = self.api.get_all(ctx, {'status': 'active'})
|
||||
shares = self.api.get_all(ctx, {'status': constants.STATUS_AVAILABLE})
|
||||
share_api.policy.check_policy.assert_has_calls([
|
||||
mock.call(ctx, 'share', 'get_all'),
|
||||
])
|
||||
@ -290,7 +290,8 @@ class ShareAPITestCase(test.TestCase):
|
||||
ctx = context.RequestContext('fake_uid', 'fake_pid_2', is_admin=True)
|
||||
self.mock_object(db_driver, 'share_get_all',
|
||||
mock.Mock(return_value=_FAKE_LIST_OF_ALL_SHARES))
|
||||
shares = self.api.get_all(ctx, {'status': 'error', 'all_tenants': 1})
|
||||
shares = self.api.get_all(
|
||||
ctx, {'status': constants.STATUS_ERROR, 'all_tenants': 1})
|
||||
share_api.policy.check_policy.assert_has_calls([
|
||||
mock.call(ctx, 'share', 'get_all'),
|
||||
])
|
||||
@ -317,7 +318,8 @@ class ShareAPITestCase(test.TestCase):
|
||||
ctx = context.RequestContext('fake_uid', 'fake_pid_2', is_admin=False)
|
||||
self.mock_object(db_driver, 'share_get_all_by_project',
|
||||
mock.Mock(return_value=_FAKE_LIST_OF_ALL_SHARES[1:]))
|
||||
shares = self.api.get_all(ctx, {'name': 'bar', 'status': 'error'})
|
||||
shares = self.api.get_all(
|
||||
ctx, {'name': 'bar', 'status': constants.STATUS_ERROR})
|
||||
share_api.policy.check_policy.assert_has_calls([
|
||||
mock.call(ctx, 'share', 'get_all'),
|
||||
])
|
||||
@ -330,7 +332,8 @@ class ShareAPITestCase(test.TestCase):
|
||||
self.assertEqual(shares, _FAKE_LIST_OF_ALL_SHARES[1::2])
|
||||
|
||||
# one item expected, two filtered
|
||||
shares = self.api.get_all(ctx, {'name': 'foo', 'status': 'active'})
|
||||
shares = self.api.get_all(
|
||||
ctx, {'name': 'foo', 'status': constants.STATUS_AVAILABLE})
|
||||
self.assertEqual(shares, _FAKE_LIST_OF_ALL_SHARES[2::4])
|
||||
share_api.policy.check_policy.assert_has_calls([
|
||||
mock.call(ctx, 'share', 'get_all'),
|
||||
@ -466,7 +469,8 @@ class ShareAPITestCase(test.TestCase):
|
||||
share = fake_share('fakeid',
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
status='creating', is_public=is_public)
|
||||
status=constants.STATUS_CREATING,
|
||||
is_public=is_public)
|
||||
options = share.copy()
|
||||
for name in ('id', 'export_location', 'host', 'launched_at',
|
||||
'terminated_at'):
|
||||
@ -491,7 +495,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
share = fake_share('fakeid',
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
status='creating')
|
||||
status=constants.STATUS_CREATING)
|
||||
options = share.copy()
|
||||
for name in ('id', 'export_location', 'host', 'launched_at',
|
||||
'terminated_at'):
|
||||
@ -515,8 +519,10 @@ class ShareAPITestCase(test.TestCase):
|
||||
None, '', 'fake', 'nfsfake', 'cifsfake', 'glusterfsfake', 'hdfsfake')
|
||||
def test_create_share_invalid_protocol(self, proto):
|
||||
options = fake_share(
|
||||
'fakeid', user_id=self.context.user_id,
|
||||
project_id=self.context.project_id, status='creating')
|
||||
'fakeid',
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
status=constants.STATUS_CREATING)
|
||||
for name in ('id', 'export_location', 'host', 'launched_at',
|
||||
'terminated_at'):
|
||||
options.pop(name, None)
|
||||
@ -542,7 +548,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
share = fake_share('fakeid',
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
status='creating')
|
||||
status=constants.STATUS_CREATING)
|
||||
self.mock_object(db_driver, 'share_create',
|
||||
mock.Mock(return_value=share))
|
||||
self.mock_object(db_driver, 'share_export_locations_update')
|
||||
@ -619,7 +625,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
'id': 'fakeid',
|
||||
'host': 'fake',
|
||||
'size': '1',
|
||||
'status': 'available',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'user_id': self.context.user_id,
|
||||
'project_id': self.context.project_id,
|
||||
}
|
||||
@ -638,17 +644,17 @@ class ShareAPITestCase(test.TestCase):
|
||||
def test_create_snapshot(self):
|
||||
date = datetime.datetime(1, 1, 1, 1, 1, 1)
|
||||
timeutils.utcnow.return_value = date
|
||||
share = fake_share('fakeid', status='available')
|
||||
share = fake_share('fakeid', status=constants.STATUS_AVAILABLE)
|
||||
snapshot = fake_snapshot('fakesnapshotid',
|
||||
share_id=share['id'],
|
||||
status='creating')
|
||||
status=constants.STATUS_CREATING)
|
||||
fake_name = 'fakename'
|
||||
fake_desc = 'fakedesc'
|
||||
options = {
|
||||
'share_id': share['id'],
|
||||
'user_id': self.context.user_id,
|
||||
'project_id': self.context.project_id,
|
||||
'status': "creating",
|
||||
'status': constants.STATUS_CREATING,
|
||||
'progress': '0%',
|
||||
'share_size': share['size'],
|
||||
'size': 1,
|
||||
@ -702,7 +708,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
share = fake_share('fakeid')
|
||||
snapshot = fake_snapshot('fakesnapshotid',
|
||||
share_id=share['id'],
|
||||
status='available')
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
with mock.patch.object(db_driver, 'share_get',
|
||||
mock.Mock(return_value=share)):
|
||||
self.api.delete_snapshot(self.context, snapshot)
|
||||
@ -711,14 +717,16 @@ class ShareAPITestCase(test.TestCase):
|
||||
share_api.policy.check_policy.assert_called_once_with(
|
||||
self.context, 'share', 'delete_snapshot', snapshot)
|
||||
db_driver.share_snapshot_update.assert_called_once_with(
|
||||
self.context, snapshot['id'], {'status': 'deleting'})
|
||||
self.context,
|
||||
snapshot['id'],
|
||||
{'status': constants.STATUS_DELETING})
|
||||
db_driver.share_get.assert_called_once_with(
|
||||
self.context, snapshot['share_id'])
|
||||
|
||||
def test_delete_snapshot_wrong_status(self):
|
||||
snapshot = fake_snapshot('fakesnapshotid',
|
||||
share_id='fakeshareid',
|
||||
status='creating')
|
||||
status=constants.STATUS_CREATING)
|
||||
self.assertRaises(exception.InvalidShareSnapshot,
|
||||
self.api.delete_snapshot,
|
||||
self.context,
|
||||
@ -727,7 +735,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
self.context, 'share', 'delete_snapshot', snapshot)
|
||||
|
||||
def test_create_snapshot_if_share_not_available(self):
|
||||
share = fake_share('fakeid', status='error')
|
||||
share = fake_share('fakeid', status=constants.STATUS_ERROR)
|
||||
self.assertRaises(exception.InvalidShare,
|
||||
self.api.create_snapshot,
|
||||
self.context,
|
||||
@ -747,15 +755,15 @@ class ShareAPITestCase(test.TestCase):
|
||||
original_share = fake_share('fake_original_id',
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
status='available')
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
snapshot = fake_snapshot('fakesnapshotid',
|
||||
share_id=original_share['id'],
|
||||
status='available')
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
share = fake_share('fakeid',
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
snapshot_id=snapshot['id'],
|
||||
status='creating')
|
||||
status=constants.STATUS_CREATING)
|
||||
options = share.copy()
|
||||
for name in ('id', 'export_location', 'host', 'launched_at',
|
||||
'terminated_at'):
|
||||
@ -804,15 +812,15 @@ class ShareAPITestCase(test.TestCase):
|
||||
original_share = fake_share('fake_original_id',
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
status='available')
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
snapshot = fake_snapshot('fakesnapshotid',
|
||||
share_id=original_share['id'],
|
||||
status='available')
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
share = fake_share('fakeid',
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
snapshot_id=snapshot['id'],
|
||||
status='creating')
|
||||
status=constants.STATUS_CREATING)
|
||||
options = share.copy()
|
||||
for name in ('id', 'export_location', 'host', 'launched_at',
|
||||
'terminated_at'):
|
||||
@ -862,11 +870,12 @@ class ShareAPITestCase(test.TestCase):
|
||||
share_id = 'fake_share_id'
|
||||
snapshot = fake_snapshot('fakesnapshotid',
|
||||
share_id=share_id,
|
||||
status='available')
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
share_type = {'id': 'fake_share_type'}
|
||||
share = fake_share(share_id, user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
snapshot_id=snapshot['id'], status='creating',
|
||||
snapshot_id=snapshot['id'],
|
||||
status=constants.STATUS_CREATING,
|
||||
share_type_id=share_type['id'])
|
||||
options = share.copy()
|
||||
for name in ('id', 'export_location', 'host', 'launched_at',
|
||||
@ -919,11 +928,12 @@ class ShareAPITestCase(test.TestCase):
|
||||
share_id = 'fake_share_id'
|
||||
snapshot = fake_snapshot('fakesnapshotid',
|
||||
share_id=share_id,
|
||||
status='available')
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
share_type = {'id': 'fake_share_type'}
|
||||
share = fake_share(share_id, user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
snapshot_id=snapshot['id'], status='creating',
|
||||
snapshot_id=snapshot['id'],
|
||||
status=constants.STATUS_CREATING,
|
||||
share_type_id=share_type['id'][1:])
|
||||
options = share.copy()
|
||||
for name in ('id', 'export_location', 'host', 'launched_at',
|
||||
@ -963,14 +973,15 @@ class ShareAPITestCase(test.TestCase):
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
share_type_id='fake_share_type_id',
|
||||
status='available')
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
share_id = 'fake_share_id'
|
||||
snapshot = fake_snapshot('fakesnapshotid',
|
||||
share_id=original_share['id'],
|
||||
status='available')
|
||||
status=constants.STATUS_AVAILABLE)
|
||||
share = fake_share(share_id, user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
snapshot_id=snapshot['id'], status='creating',
|
||||
snapshot_id=snapshot['id'],
|
||||
status=constants.STATUS_CREATING,
|
||||
share_type_id=original_share['share_type_id'])
|
||||
options = share.copy()
|
||||
for name in ('id', 'export_location', 'host', 'launched_at',
|
||||
@ -1030,14 +1041,15 @@ class ShareAPITestCase(test.TestCase):
|
||||
def test_create_from_snapshot_not_available(self):
|
||||
snapshot = fake_snapshot('fakesnapshotid',
|
||||
share_id='fakeshare_id',
|
||||
status='error')
|
||||
status=constants.STATUS_ERROR)
|
||||
self.assertRaises(exception.InvalidShareSnapshot, self.api.create,
|
||||
self.context, 'nfs', '1', 'fakename',
|
||||
'fakedesc', snapshot=snapshot,
|
||||
availability_zone='fakeaz')
|
||||
|
||||
def test_create_from_snapshot_larger_size(self):
|
||||
snapshot = fake_snapshot(1, size=100, status='available')
|
||||
snapshot = fake_snapshot(
|
||||
1, size=100, status=constants.STATUS_AVAILABLE)
|
||||
self.assertRaises(exception.InvalidInput, self.api.create,
|
||||
self.context, 'nfs', 1, 'fakename', 'fakedesc',
|
||||
availability_zone='fakeaz', snapshot=snapshot)
|
||||
@ -1057,7 +1069,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
timeutils.utcnow.return_value = date
|
||||
share = fake_share('fakeid', status=status,
|
||||
share_server_id=share_server_id)
|
||||
options = {'status': 'deleting', 'terminated_at': date}
|
||||
options = {'status': constants.STATUS_DELETING, 'terminated_at': date}
|
||||
deleting_share = share.copy()
|
||||
deleting_share.update(options)
|
||||
self.mock_object(db_driver, 'share_update',
|
||||
@ -1066,7 +1078,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
|
||||
return share, deleting_share, options
|
||||
|
||||
@ddt.data('available', 'error')
|
||||
@ddt.data(constants.STATUS_AVAILABLE, constants.STATUS_ERROR)
|
||||
def test_delete(self, status):
|
||||
share_server_id = 'fake-ss-id'
|
||||
share, deleting_share, options = self._setup_delete_mocks(
|
||||
@ -1083,7 +1095,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
|
||||
def test_delete_share_without_share_server(self):
|
||||
share, deleting_share, options = self._setup_delete_mocks(
|
||||
'available', share_server_id=None)
|
||||
constants.STATUS_AVAILABLE, share_server_id=None)
|
||||
|
||||
self.api.delete(self.context, share)
|
||||
|
||||
@ -1207,7 +1219,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
|
||||
@ddt.data(None, 'rw', 'ro')
|
||||
def test_allow_access(self, level):
|
||||
share = fake_share('fakeid', status='available')
|
||||
share = fake_share('fakeid', status=constants.STATUS_AVAILABLE)
|
||||
values = {
|
||||
'share_id': share['id'],
|
||||
'access_type': 'fakeacctype',
|
||||
@ -1228,13 +1240,13 @@ class ShareAPITestCase(test.TestCase):
|
||||
self.context, 'share', 'allow_access')
|
||||
|
||||
def test_allow_access_invalid_access_level(self):
|
||||
share = fake_share('fakeid', status='available')
|
||||
share = fake_share('fakeid', status=constants.STATUS_AVAILABLE)
|
||||
self.assertRaises(exception.InvalidShareAccess, self.api.allow_access,
|
||||
self.context, share, 'fakeacctype', 'fakeaccto',
|
||||
'ab')
|
||||
|
||||
def test_allow_access_status_not_available(self):
|
||||
share = fake_share('fakeid', status='error')
|
||||
share = fake_share('fakeid', status=constants.STATUS_ERROR)
|
||||
self.assertRaises(exception.InvalidShare, self.api.allow_access,
|
||||
self.context, share, 'fakeacctype', 'fakeaccto')
|
||||
|
||||
@ -1245,7 +1257,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
|
||||
@mock.patch.object(db_driver, 'share_access_delete', mock.Mock())
|
||||
def test_deny_access_error(self):
|
||||
share = fake_share('fakeid', status='available')
|
||||
share = fake_share('fakeid', status=constants.STATUS_AVAILABLE)
|
||||
access = fake_access('fakaccid', state='fakeerror')
|
||||
self.api.deny_access(self.context, share, access)
|
||||
share_api.policy.check_policy.assert_called_once_with(
|
||||
@ -1255,7 +1267,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
|
||||
@mock.patch.object(db_driver, 'share_access_update', mock.Mock())
|
||||
def test_deny_access_active(self):
|
||||
share = fake_share('fakeid', status='available')
|
||||
share = fake_share('fakeid', status=constants.STATUS_AVAILABLE)
|
||||
access = fake_access('fakaccid', state='fakeactive')
|
||||
self.api.deny_access(self.context, share, access)
|
||||
db_driver.share_access_update.assert_called_once_with(
|
||||
@ -1266,7 +1278,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
self.context, share, access)
|
||||
|
||||
def test_deny_access_not_active_not_error(self):
|
||||
share = fake_share('fakeid', status='available')
|
||||
share = fake_share('fakeid', status=constants.STATUS_AVAILABLE)
|
||||
access = fake_access('fakaccid', state='fakenew')
|
||||
self.assertRaises(exception.InvalidShareAccess, self.api.deny_access,
|
||||
self.context, share, access)
|
||||
@ -1274,7 +1286,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
self.context, 'share', 'deny_access')
|
||||
|
||||
def test_deny_access_status_not_available(self):
|
||||
share = fake_share('fakeid', status='error')
|
||||
share = fake_share('fakeid', status=constants.STATUS_ERROR)
|
||||
self.assertRaises(exception.InvalidShare, self.api.deny_access,
|
||||
self.context, share, 'fakeacc')
|
||||
share_api.policy.check_policy.assert_called_once_with(
|
||||
|
@ -38,9 +38,9 @@ from manila import utils
|
||||
class FakeAccessRule(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.STATE_ACTIVE = 'active'
|
||||
self.STATE_NEW = 'new'
|
||||
self.STATE_ERROR = 'error'
|
||||
self.STATE_ACTIVE = constants.STATUS_ACTIVE
|
||||
self.STATE_NEW = constants.STATUS_NEW
|
||||
self.STATE_ERROR = constants.STATUS_ERROR
|
||||
self.access_type = 'fake_type'
|
||||
self.id = 'fake_id'
|
||||
for k, v in kwargs.items():
|
||||
@ -105,13 +105,13 @@ class ShareManagerTestCase(test.TestCase):
|
||||
return db.share_access_create(context.get_admin_context(), access)
|
||||
|
||||
@staticmethod
|
||||
def _create_share_server(state='ACTIVE', share_network_id=None, host=None,
|
||||
def _create_share_server(state=None, share_network_id=None, host=None,
|
||||
backend_details=None):
|
||||
"""Create a share server object."""
|
||||
srv = {}
|
||||
srv['host'] = host
|
||||
srv['share_network_id'] = share_network_id
|
||||
srv['status'] = state
|
||||
srv['status'] = state or constants.STATUS_ACTIVE
|
||||
share_srv = db.share_server_create(context.get_admin_context(), srv)
|
||||
if backend_details:
|
||||
db.share_server_backend_details_set(
|
||||
@ -180,13 +180,15 @@ class ShareManagerTestCase(test.TestCase):
|
||||
access_type='fake_access_type', access='fake_access')
|
||||
|
||||
shares = [
|
||||
{'id': 'fake_id_1', 'status': 'available', },
|
||||
{'id': 'fake_id_2', 'status': 'error', 'name': 'fake_name_2'},
|
||||
{'id': 'fake_id_3', 'status': 'in-use', 'name': 'fake_name_3'},
|
||||
{'id': 'fake_id_1', 'status': constants.STATUS_AVAILABLE},
|
||||
{'id': 'fake_id_2',
|
||||
'status': constants.STATUS_ERROR,
|
||||
'name': 'fake_name_2'},
|
||||
{'id': 'fake_id_3', 'status': 'fake', 'name': 'fake_name_3'},
|
||||
]
|
||||
rules = [
|
||||
FakeAccessRule(state='active'),
|
||||
FakeAccessRule(state='error'),
|
||||
FakeAccessRule(state=constants.STATUS_ACTIVE),
|
||||
FakeAccessRule(state=constants.STATUS_ERROR),
|
||||
]
|
||||
fake_export_locations = ['fake/path/1', 'fake/path']
|
||||
share_server = 'fake_share_server_type_does_not_matter'
|
||||
@ -244,9 +246,15 @@ class ShareManagerTestCase(test.TestCase):
|
||||
raise exception.ManilaException(message="Fake raise")
|
||||
|
||||
shares = [
|
||||
{'id': 'fake_id_1', 'status': 'available', 'name': 'fake_name_1'},
|
||||
{'id': 'fake_id_2', 'status': 'error', 'name': 'fake_name_2'},
|
||||
{'id': 'fake_id_3', 'status': 'available', 'name': 'fake_name_3'},
|
||||
{'id': 'fake_id_1',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'name': 'fake_name_1'},
|
||||
{'id': 'fake_id_2',
|
||||
'status': constants.STATUS_ERROR,
|
||||
'name': 'fake_name_2'},
|
||||
{'id': 'fake_id_3',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'name': 'fake_name_3'},
|
||||
]
|
||||
share_server = 'fake_share_server_type_does_not_matter'
|
||||
self.mock_object(self.share_manager.db,
|
||||
@ -297,13 +305,19 @@ class ShareManagerTestCase(test.TestCase):
|
||||
raise exception.ManilaException(message="Fake raise")
|
||||
|
||||
shares = [
|
||||
{'id': 'fake_id_1', 'status': 'available', 'name': 'fake_name_1'},
|
||||
{'id': 'fake_id_2', 'status': 'error', 'name': 'fake_name_2'},
|
||||
{'id': 'fake_id_3', 'status': 'available', 'name': 'fake_name_3'},
|
||||
{'id': 'fake_id_1',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'name': 'fake_name_1'},
|
||||
{'id': 'fake_id_2',
|
||||
'status': constants.STATUS_ERROR,
|
||||
'name': 'fake_name_2'},
|
||||
{'id': 'fake_id_3',
|
||||
'status': constants.STATUS_AVAILABLE,
|
||||
'name': 'fake_name_3'},
|
||||
]
|
||||
rules = [
|
||||
FakeAccessRule(state='active'),
|
||||
FakeAccessRule(state='error'),
|
||||
FakeAccessRule(state=constants.STATUS_ACTIVE),
|
||||
FakeAccessRule(state=constants.STATUS_ERROR),
|
||||
]
|
||||
share_server = 'fake_share_server_type_does_not_matter'
|
||||
self.mock_object(self.share_manager.db,
|
||||
@ -383,7 +397,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
share_id).id)
|
||||
|
||||
shr = db.share_get(self.context, share_id)
|
||||
self.assertEqual(shr['status'], 'available')
|
||||
self.assertEqual(shr['status'], constants.STATUS_AVAILABLE)
|
||||
self.assertEqual(shr['share_server_id'], server['id'])
|
||||
|
||||
def test_create_share_from_snapshot_with_server_not_found(self):
|
||||
@ -403,7 +417,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
)
|
||||
|
||||
shr = db.share_get(self.context, share_id)
|
||||
self.assertEqual(shr['status'], 'error')
|
||||
self.assertEqual(shr['status'], constants.STATUS_ERROR)
|
||||
|
||||
def test_create_share_from_snapshot(self):
|
||||
"""Test share can be created from snapshot."""
|
||||
@ -418,7 +432,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
share_id).id)
|
||||
|
||||
shr = db.share_get(self.context, share_id)
|
||||
self.assertEqual(shr['status'], 'available')
|
||||
self.assertEqual(shr['status'], constants.STATUS_AVAILABLE)
|
||||
self.assertTrue(len(shr['export_location']) > 0)
|
||||
self.assertEqual(2, len(shr['export_locations']))
|
||||
|
||||
@ -444,7 +458,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
snapshot_id).share_id)
|
||||
|
||||
snap = db.share_snapshot_get(self.context, snapshot_id)
|
||||
self.assertEqual(snap['status'], 'available')
|
||||
self.assertEqual(snap['status'], constants.STATUS_AVAILABLE)
|
||||
|
||||
self.share_manager.delete_snapshot(self.context, snapshot_id)
|
||||
self.assertRaises(exception.NotFound,
|
||||
@ -473,14 +487,15 @@ class ShareManagerTestCase(test.TestCase):
|
||||
self.context, share_id, snapshot_id)
|
||||
|
||||
snap = db.share_snapshot_get(self.context, snapshot_id)
|
||||
self.assertEqual(snap['status'], 'error')
|
||||
self.assertEqual(snap['status'], constants.STATUS_ERROR)
|
||||
|
||||
self.assertRaises(exception.NotFound,
|
||||
self.share_manager.delete_snapshot,
|
||||
self.context, snapshot_id)
|
||||
|
||||
self.assertEqual('error_deleting', db.share_snapshot_get(
|
||||
self.context, snapshot_id).status)
|
||||
self.assertEqual(
|
||||
constants.STATUS_ERROR_DELETING,
|
||||
db.share_snapshot_get(self.context, snapshot_id).status)
|
||||
self.share_manager.driver.create_snapshot.assert_called_once_with(
|
||||
self.context, utils.IsAMatcher(models.ShareSnapshot),
|
||||
share_server=None)
|
||||
@ -497,14 +512,14 @@ class ShareManagerTestCase(test.TestCase):
|
||||
|
||||
self.mock_object(self.share_manager.driver, "delete_snapshot",
|
||||
mock.Mock(side_effect=_raise_share_snapshot_is_busy))
|
||||
share = self._create_share(status='ACTIVE')
|
||||
share = self._create_share(status=constants.STATUS_ACTIVE)
|
||||
snapshot = self._create_snapshot(share_id=share['id'])
|
||||
snapshot_id = snapshot['id']
|
||||
|
||||
self.share_manager.delete_snapshot(self.context, snapshot_id)
|
||||
|
||||
snap = db.share_snapshot_get(self.context, snapshot_id)
|
||||
self.assertEqual(snap['status'], 'available')
|
||||
self.assertEqual(snap['status'], constants.STATUS_AVAILABLE)
|
||||
self.share_manager.driver.delete_snapshot.assert_called_once_with(
|
||||
utils.IsAMatcher(context.RequestContext),
|
||||
utils.IsAMatcher(models.ShareSnapshot),
|
||||
@ -531,7 +546,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
utils.IsAMatcher(context.RequestContext), share_id)
|
||||
self.share_manager.db.share_update.assert_called_once_with(
|
||||
utils.IsAMatcher(context.RequestContext), share_id,
|
||||
{'status': 'error'})
|
||||
{'status': constants.STATUS_ERROR})
|
||||
|
||||
def test_create_share_with_share_network_server_not_exists(self):
|
||||
"""Test share can be created without share server."""
|
||||
@ -598,7 +613,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
mock.call(
|
||||
utils.IsAMatcher(context.RequestContext),
|
||||
fake_share['id'],
|
||||
{'status': 'error'},
|
||||
{'status': constants.STATUS_ERROR},
|
||||
)
|
||||
])
|
||||
self.share_manager._setup_server.assert_called_once_with(
|
||||
@ -616,7 +631,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
share_id
|
||||
)
|
||||
shr = db.share_get(self.context, share_id)
|
||||
self.assertEqual(shr['status'], 'error')
|
||||
self.assertEqual(shr['status'], constants.STATUS_ERROR)
|
||||
|
||||
def test_create_share_with_share_network_server_exists(self):
|
||||
"""Test share can be created with existing share server."""
|
||||
@ -635,7 +650,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
share_id).id)
|
||||
|
||||
shr = db.share_get(self.context, share_id)
|
||||
self.assertEqual(shr['status'], 'available')
|
||||
self.assertEqual(shr['status'], constants.STATUS_AVAILABLE)
|
||||
self.assertEqual(shr['share_server_id'], share_srv['id'])
|
||||
self.assertTrue(len(shr['export_location']) > 0)
|
||||
self.assertEqual(1, len(shr['export_locations']))
|
||||
@ -665,7 +680,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
share = self._create_share(share_network_id=share_net['id'])
|
||||
self._create_share_server(
|
||||
share_network_id=share_net['id'], host=self.share_manager.host,
|
||||
state='ERROR')
|
||||
state=constants.STATUS_ERROR)
|
||||
share_id = share['id']
|
||||
fake_server = {'id': 'fake_srv_id'}
|
||||
self.mock_object(db, 'share_server_create',
|
||||
@ -678,7 +693,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
self.assertEqual(share_id, db.share_get(context.get_admin_context(),
|
||||
share_id).id)
|
||||
shr = db.share_get(self.context, share_id)
|
||||
self.assertEqual(shr['status'], 'available')
|
||||
self.assertEqual(shr['status'], constants.STATUS_AVAILABLE)
|
||||
self.assertEqual(shr['share_server_id'], 'fake_srv_id')
|
||||
db.share_server_create.assert_called_once_with(
|
||||
utils.IsAMatcher(context.RequestContext), mock.ANY)
|
||||
@ -704,14 +719,14 @@ class ShareManagerTestCase(test.TestCase):
|
||||
share_id)
|
||||
|
||||
shr = db.share_get(self.context, share_id)
|
||||
self.assertEqual(shr['status'], 'error')
|
||||
self.assertEqual(shr['status'], constants.STATUS_ERROR)
|
||||
self.assertRaises(exception.NotFound,
|
||||
self.share_manager.delete_share,
|
||||
self.context,
|
||||
share_id)
|
||||
|
||||
shr = db.share_get(self.context, share_id)
|
||||
self.assertEqual(shr['status'], 'error_deleting')
|
||||
self.assertEqual(shr['status'], constants.STATUS_ERROR_DELETING)
|
||||
self.share_manager.driver.create_share.assert_called_once_with(
|
||||
utils.IsAMatcher(context.RequestContext),
|
||||
utils.IsAMatcher(models.Share),
|
||||
@ -844,7 +859,8 @@ class ShareManagerTestCase(test.TestCase):
|
||||
else:
|
||||
self.assertFalse(
|
||||
self.share_manager.db.share_export_locations_update.called)
|
||||
valid_share_data = {'status': 'available', 'launched_at': mock.ANY}
|
||||
valid_share_data = {
|
||||
'status': constants.STATUS_AVAILABLE, 'launched_at': mock.ANY}
|
||||
valid_share_data.update(driver_data)
|
||||
self.share_manager.db.share_update.assert_called_once_with(
|
||||
utils.IsAMatcher(context.RequestContext),
|
||||
@ -1138,7 +1154,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
access_id)
|
||||
|
||||
acs = db.share_access_get(self.context, access_id)
|
||||
self.assertEqual(acs['state'], 'error')
|
||||
self.assertEqual(acs['state'], constants.STATUS_ERROR)
|
||||
|
||||
self.assertRaises(exception.NotFound,
|
||||
self.share_manager.deny_access,
|
||||
@ -1146,7 +1162,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
access_id)
|
||||
|
||||
acs = db.share_access_get(self.context, access_id)
|
||||
self.assertEqual(acs['state'], 'error')
|
||||
self.assertEqual(acs['state'], constants.STATUS_ERROR)
|
||||
|
||||
def test_setup_server(self):
|
||||
# Setup required test data
|
||||
@ -1373,13 +1389,16 @@ class ShareManagerTestCase(test.TestCase):
|
||||
for k, v in details.items()]
|
||||
self.assertEqual(expected, details_mock.call_args_list)
|
||||
self.share_manager.db.share_server_update.assert_called_once_with(
|
||||
self.context, share_server['id'], {'status': 'ERROR'})
|
||||
self.context,
|
||||
share_server['id'],
|
||||
{'status': constants.STATUS_ERROR})
|
||||
self.share_manager.driver.deallocate_network.assert_called_once_with(
|
||||
self.context, share_server['id']
|
||||
)
|
||||
|
||||
def test_ensure_share_has_pool_with_only_host(self):
|
||||
fake_share = {'status': 'available', 'host': 'host1', 'id': 1}
|
||||
fake_share = {
|
||||
'status': constants.STATUS_AVAILABLE, 'host': 'host1', 'id': 1}
|
||||
host = self.share_manager._ensure_share_has_pool(context.
|
||||
get_admin_context(),
|
||||
fake_share)
|
||||
@ -1387,7 +1406,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
|
||||
def test_ensure_share_has_pool_with_full_pool_name(self):
|
||||
fake_share = {'host': 'host1#pool0', 'id': 1,
|
||||
'status': 'available'}
|
||||
'status': constants.STATUS_AVAILABLE}
|
||||
fake_share_expected_value = 'pool0'
|
||||
host = self.share_manager._ensure_share_has_pool(context.
|
||||
get_admin_context(),
|
||||
@ -1396,7 +1415,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
|
||||
def test_ensure_share_has_pool_unable_to_fetch_share(self):
|
||||
fake_share = {'host': 'host@backend', 'id': 1,
|
||||
'status': 'available'}
|
||||
'status': constants.STATUS_AVAILABLE}
|
||||
with mock.patch.object(self.share_manager.driver, 'get_pool',
|
||||
side_effect=Exception):
|
||||
with mock.patch.object(manager, 'LOG') as mock_LOG:
|
||||
|
@ -22,6 +22,7 @@ from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from manila.common import constants
|
||||
from manila import context
|
||||
from manila import db
|
||||
from manila.share import rpcapi as share_rpcapi
|
||||
@ -38,7 +39,7 @@ class ShareRpcAPITestCase(test.TestCase):
|
||||
shr = {}
|
||||
shr['host'] = 'fake_host'
|
||||
shr['availability_zone'] = CONF.storage_availability_zone
|
||||
shr['status'] = "available"
|
||||
shr['status'] = constants.STATUS_AVAILABLE
|
||||
share = db.share_create(self.context, shr)
|
||||
acs = {}
|
||||
acs['access_type'] = "ip"
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from manila.common import constants
|
||||
from manila import context
|
||||
from manila import db
|
||||
from manila import exception
|
||||
@ -36,7 +37,7 @@ class ShareServerTableTestCase(test.TestCase):
|
||||
values = {
|
||||
'share_network_id': uuidutils.generate_uuid(),
|
||||
'host': 'host1',
|
||||
'status': 'ACTIVE'
|
||||
'status': constants.STATUS_ACTIVE,
|
||||
}
|
||||
return db.share_server_create(self.ctxt, values)
|
||||
|
||||
@ -44,7 +45,7 @@ class ShareServerTableTestCase(test.TestCase):
|
||||
values = {
|
||||
'share_network_id': 'fake-share-net-id',
|
||||
'host': 'hostname',
|
||||
'status': 'ACTIVE'
|
||||
'status': constants.STATUS_ACTIVE
|
||||
}
|
||||
expected = self._create_share_server(values)
|
||||
server = db.share_server_get(self.ctxt, expected['id'])
|
||||
@ -62,7 +63,7 @@ class ShareServerTableTestCase(test.TestCase):
|
||||
values = {
|
||||
'share_network_id': 'fake-share-net-id',
|
||||
'host': 'hostname',
|
||||
'status': 'ACTIVE'
|
||||
'status': constants.STATUS_ACTIVE,
|
||||
}
|
||||
server = self._create_share_server(values)
|
||||
self.assertTrue(server['id'])
|
||||
@ -87,7 +88,7 @@ class ShareServerTableTestCase(test.TestCase):
|
||||
update = {
|
||||
'share_network_id': 'update_net',
|
||||
'host': 'update_host',
|
||||
'status': 'ACTIVE'
|
||||
'status': constants.STATUS_ACTIVE,
|
||||
}
|
||||
server = self._create_share_server()
|
||||
updated_server = db.share_server_update(self.ctxt, server['id'],
|
||||
@ -108,17 +109,17 @@ class ShareServerTableTestCase(test.TestCase):
|
||||
valid = {
|
||||
'share_network_id': '1',
|
||||
'host': 'host1',
|
||||
'status': 'ACTIVE'
|
||||
'status': constants.STATUS_ACTIVE,
|
||||
}
|
||||
invalid = {
|
||||
'share_network_id': '1',
|
||||
'host': 'host1',
|
||||
'status': 'ERROR'
|
||||
'status': constants.STATUS_ERROR,
|
||||
}
|
||||
other = {
|
||||
'share_network_id': '2',
|
||||
'host': 'host2',
|
||||
'status': 'ACTIVE'
|
||||
'status': constants.STATUS_ACTIVE,
|
||||
}
|
||||
valid = self._create_share_server(valid)
|
||||
self._create_share_server(invalid)
|
||||
@ -139,17 +140,17 @@ class ShareServerTableTestCase(test.TestCase):
|
||||
srv1 = {
|
||||
'share_network_id': '1',
|
||||
'host': 'host1',
|
||||
'status': 'ACTIVE'
|
||||
'status': constants.STATUS_ACTIVE,
|
||||
}
|
||||
srv2 = {
|
||||
'share_network_id': '1',
|
||||
'host': 'host1',
|
||||
'status': 'ERROR'
|
||||
'status': constants.STATUS_ERROR,
|
||||
}
|
||||
srv3 = {
|
||||
'share_network_id': '2',
|
||||
'host': 'host2',
|
||||
'status': 'ACTIVE'
|
||||
'status': constants.STATUS_ACTIVE,
|
||||
}
|
||||
servers = db.share_server_get_all(self.ctxt)
|
||||
self.assertEqual(len(servers), 0)
|
||||
@ -188,7 +189,7 @@ class ShareServerTableTestCase(test.TestCase):
|
||||
values = {
|
||||
'share_network_id': 'fake-share-net-id',
|
||||
'host': 'hostname',
|
||||
'status': 'ACTIVE'
|
||||
'status': constants.STATUS_ACTIVE,
|
||||
}
|
||||
details = {
|
||||
'value1': '1',
|
||||
|
@ -21,6 +21,7 @@ from oslo_config import cfg
|
||||
from oslo_utils import timeutils
|
||||
import testtools
|
||||
|
||||
from manila.common import constants
|
||||
from manila import context
|
||||
from manila import db
|
||||
from manila.db.sqlalchemy import api as sqa_api
|
||||
@ -51,7 +52,7 @@ class QuotaIntegrationTestCase(test.TestCase):
|
||||
share['user_id'] = self.user_id
|
||||
share['project_id'] = self.project_id
|
||||
share['size'] = size
|
||||
share['status'] = 'available'
|
||||
share['status'] = constants.STATUS_AVAILABLE
|
||||
share['host'] = 'fake_host'
|
||||
return db.share_create(self.context, share)
|
||||
|
||||
@ -62,7 +63,7 @@ class QuotaIntegrationTestCase(test.TestCase):
|
||||
snapshot['share_id'] = share['id']
|
||||
snapshot['share_size'] = share['size']
|
||||
snapshot['host'] = share['host']
|
||||
snapshot['status'] = 'available'
|
||||
snapshot['status'] = constants.STATUS_AVAILABLE
|
||||
return db.share_snapshot_create(self.context, snapshot)
|
||||
|
||||
@testtools.skip("SQLAlchemy sqlite insert bug")
|
||||
|
Loading…
Reference in New Issue
Block a user