Add share-network activate and deactivate commands
Partially implements bp: share-network-activation-api Change-Id: I6d8d97a57c05758794e8fa53aa55198f2b8670e5
This commit is contained in:
@@ -84,6 +84,30 @@ class ShareNetworkManager(base.Manager):
|
||||
body,
|
||||
RESOURCE_NAME)
|
||||
|
||||
def activate(self, share_network):
|
||||
"""Activate share network
|
||||
|
||||
:param share_network: share network to be activated
|
||||
:rtype: :class:`ShareNetwork`
|
||||
"""
|
||||
body = {'activate': {}}
|
||||
|
||||
self._create(RESOURCE_PATH % share_network + '/action',
|
||||
body,
|
||||
RESOURCE_NAME)
|
||||
|
||||
def deactivate(self, share_network):
|
||||
"""Deactivate share network
|
||||
|
||||
:param share_network: share network to be deactivated
|
||||
:rtype: :class:`ShareNetwork`
|
||||
"""
|
||||
body = {'deactivate': {}}
|
||||
|
||||
self._create(RESOURCE_PATH % share_network + '/action',
|
||||
body,
|
||||
RESOURCE_NAME)
|
||||
|
||||
def get(self, share_network):
|
||||
"""Get a share network.
|
||||
|
||||
|
||||
@@ -796,6 +796,26 @@ def do_share_network_security_service_remove(cs, args):
|
||||
args.security_service)
|
||||
|
||||
|
||||
@utils.arg(
|
||||
'share_network',
|
||||
metavar='<share-network>',
|
||||
help='Share network to be activated. Should be associated with all'
|
||||
' necessary security services. Should be in other than "ACTIVE"'
|
||||
' state.')
|
||||
def do_share_network_activate(cs, args):
|
||||
"""Activate share network"""
|
||||
cs.share_networks.activate(args.share_network)
|
||||
|
||||
|
||||
@utils.arg(
|
||||
'share_network',
|
||||
metavar='<share-network>',
|
||||
help='Share network to be deactivated. Should be in "ACTIVE" state.')
|
||||
def do_share_network_deactivate(cs, args):
|
||||
"""Deactivate share network"""
|
||||
cs.share_networks.deactivate(args.share_network)
|
||||
|
||||
|
||||
@utils.arg(
|
||||
'share_network',
|
||||
metavar='<share-network>',
|
||||
|
||||
@@ -132,3 +132,29 @@ class ShareNetworkTest(unittest.TestCase):
|
||||
expected_path,
|
||||
expected_body,
|
||||
share_networks.RESOURCE_NAME)
|
||||
|
||||
def test_activate(self):
|
||||
share_nw = 'fake share nw'
|
||||
expected_path = (share_networks.RESOURCE_PATH + '/action') % share_nw
|
||||
expected_body = {'activate': {}}
|
||||
|
||||
with mock.patch.object(self.manager, '_create', mock.Mock()):
|
||||
self.manager.activate(share_nw)
|
||||
|
||||
self.manager._create.assert_called_once_with(
|
||||
expected_path,
|
||||
expected_body,
|
||||
share_networks.RESOURCE_NAME)
|
||||
|
||||
def test_deactivate(self):
|
||||
share_nw = 'fake share nw'
|
||||
expected_path = (share_networks.RESOURCE_PATH + '/action') % share_nw
|
||||
expected_body = {'deactivate': {}}
|
||||
|
||||
with mock.patch.object(self.manager, '_create', mock.Mock()):
|
||||
self.manager.deactivate(share_nw)
|
||||
|
||||
self.manager._create.assert_called_once_with(
|
||||
expected_path,
|
||||
expected_body,
|
||||
share_networks.RESOURCE_NAME)
|
||||
|
||||
Reference in New Issue
Block a user