Merge "Allow bay name when replication controller is created"
This commit is contained in:
@@ -119,7 +119,7 @@ class ShellTest(utils.TestCase):
|
||||
'.*--json',
|
||||
'.*help',
|
||||
'.*bay-show',
|
||||
'.*--bay-id']
|
||||
'.*--bay']
|
||||
for r in required:
|
||||
self.assertThat((stdout + stderr),
|
||||
matchers.MatchesRegex(r, re.DOTALL | re.MULTILINE))
|
||||
|
||||
@@ -403,18 +403,20 @@ class TestCommandLineArgument(utils.TestCase):
|
||||
self._unrecognized_arg_error)
|
||||
self.assertFalse(mock_list.called)
|
||||
|
||||
@mock.patch('magnumclient.v1.bays.BayManager.get')
|
||||
@mock.patch('magnumclient.v1.replicationcontrollers.'
|
||||
'ReplicationControllerManager.create')
|
||||
def test_rc_create_success(self, mock_create):
|
||||
def test_rc_create_success(self, mock_create, mock_get):
|
||||
self._test_arg_success('rc-create '
|
||||
'--bay-id xxx '
|
||||
'--bay xxx '
|
||||
'--manifest test '
|
||||
'--manifest-url test_url')
|
||||
self.assertTrue(mock_create.called)
|
||||
|
||||
@mock.patch('magnumclient.v1.bays.BayManager.get')
|
||||
@mock.patch('magnumclient.v1.replicationcontrollers.'
|
||||
'ReplicationControllerManager.create')
|
||||
def test_rc_create_failure_few_arg(self, mock_create):
|
||||
def test_rc_create_failure_few_arg(self, mock_create, mock_get):
|
||||
self._test_arg_failure('rc-create '
|
||||
'--manifest test '
|
||||
'--manifest-url test_url',
|
||||
@@ -422,7 +424,7 @@ class TestCommandLineArgument(utils.TestCase):
|
||||
self.assertFalse(mock_create.called)
|
||||
|
||||
self._test_arg_failure('rc-create '
|
||||
'bay-id xxx '
|
||||
'bay xxx '
|
||||
'--manifest-url test_url',
|
||||
self._mandatory_arg_error)
|
||||
self.assertFalse(mock_create.called)
|
||||
|
||||
@@ -203,17 +203,21 @@ class ShellTest(base.TestCase):
|
||||
|
||||
def test_do_rc_create(self):
|
||||
client_mock = mock.MagicMock()
|
||||
bay = mock.MagicMock()
|
||||
bay.uuid = 'uuid'
|
||||
client_mock.bays.get.return_value = bay
|
||||
|
||||
args = mock.MagicMock()
|
||||
manifest_url = "test_url"
|
||||
args.manifest_url = manifest_url
|
||||
bay_id = "xxx"
|
||||
args.bay_id = bay_id
|
||||
bay_id_or_name = "xxx"
|
||||
args.bay_id = bay_id_or_name
|
||||
manifest = "test_manifest"
|
||||
args.manifest = manifest
|
||||
|
||||
shell.do_rc_create(client_mock, args)
|
||||
client_mock.rcs.create.assert_called_once_with(
|
||||
manifest_url=manifest_url, bay_uuid=bay_id)
|
||||
manifest_url=manifest_url, bay_uuid=bay.uuid)
|
||||
|
||||
def test_do_rc_delete(self):
|
||||
client_mock = mock.MagicMock()
|
||||
|
||||
@@ -318,15 +318,17 @@ def do_rc_list(cs, args):
|
||||
metavar='<manifest>',
|
||||
help='File path of the replication controller file to use for '
|
||||
'creating replication controllers.')
|
||||
@utils.arg('--bay-id',
|
||||
@utils.arg('--bay',
|
||||
required=True,
|
||||
metavar='<bay_id>',
|
||||
help='The bay ID.')
|
||||
metavar='<bay>',
|
||||
help='ID or name of the bay.')
|
||||
def do_rc_create(cs, args):
|
||||
"""Create a replication controller."""
|
||||
bay = cs.bays.get(args.bay)
|
||||
|
||||
opts = {}
|
||||
opts['manifest_url'] = args.manifest_url
|
||||
opts['bay_uuid'] = args.bay_id
|
||||
opts['bay_uuid'] = bay.uuid
|
||||
|
||||
if args.manifest is not None and os.path.isfile(args.manifest):
|
||||
with open(args.manifest, 'r') as f:
|
||||
|
||||
Reference in New Issue
Block a user