Add coe attribute to BayModel creation

Add coe as a required parameter to BayModel creation.

Partially implements: bp multiple-bay-templates

Change-Id: Iaa1d80d5573edd774fa923c0332d29cd914ec774
This commit is contained in:
Janek Lehr 2015-04-21 16:48:05 -05:00
parent 1f53ad4d95
commit 34c4b38c05
6 changed files with 27 additions and 6 deletions

2
.gitignore vendored
View File

@ -49,4 +49,4 @@ ChangeLog
# Editors
*~
.*.swp
.*.swp

View File

@ -196,6 +196,7 @@ class TestCommandLineArgument(utils.TestCase):
'--image-id test_image '
'--keypair-id test_keypair '
'--external-network-id test_net '
'--coe swarm '
'--dns-nameserver test_dns '
'--flavor-id test_flavor '
'--fixed-network public '
@ -207,6 +208,7 @@ class TestCommandLineArgument(utils.TestCase):
'--keypair-id test_keypair '
'--external-network-id test_net '
'--image-id test_image '
'--coe kubernetes '
'--name test ')
self.assertTrue(mock_create.called)
@ -218,6 +220,7 @@ class TestCommandLineArgument(utils.TestCase):
'--image-id test_image '
'--keypair-id test_keypair '
'--external-network-id test_net '
'--coe swarm '
'--dns-nameserver test_dns '
'--master-flavor-id test_flavor')
self.assertTrue(mock_create.called)
@ -229,6 +232,7 @@ class TestCommandLineArgument(utils.TestCase):
'--keypair-id test_keypair '
'--external-network-id test_net '
'--image-id test_image '
'--coe swarm'
)
self.assertTrue(mock_create.called)
@ -238,7 +242,8 @@ class TestCommandLineArgument(utils.TestCase):
'--name test --fixed-network private '
'--keypair-id test_keypair '
'--external-network-id test_net '
'--image-id test_image ')
'--image-id test_image '
'--coe swarm')
self.assertTrue(mock_create.called)
@mock.patch('magnumclient.v1.baymodels.BayModelManager.create')
@ -248,6 +253,7 @@ class TestCommandLineArgument(utils.TestCase):
'--keypair-id test_keypair '
'--external-network-id test_net '
'--image-id test_image '
'--coe swarm '
'--ssh-authorized-key test_key '
)
self.assertTrue(mock_create.called)
@ -271,6 +277,10 @@ class TestCommandLineArgument(utils.TestCase):
self._mandatory_arg_error)
self.assertFalse(mock_create.called)
self._test_arg_failure('baymodel-create '
'--coe test', self._mandatory_arg_error)
self.assertFalse(mock_create.called)
self._test_arg_failure('baymodel-create', self._mandatory_arg_error)
self.assertFalse(mock_create.called)

View File

@ -38,7 +38,8 @@ BAYMODEL1 = {'id': 123,
'YucqbeuM7nmJi+8Hb55y1xWoOZItvKJ+n4VKc'
'Ma71G5/4EOQxuQ/sgW965OOO2Hq027yHOwzcR'
'8vjlQUnTK0HijrbSTLxp/9kazWWraBS0AyXe6'
'v0Zio4VeFrfpytB8RtZBN digambar@magnum'
'v0Zio4VeFrfpytB8RtZBN digambar@magnum',
'coe': 'swarm',
}
BAYMODEL2 = {'id': 124,
'uuid': '66666666-7777-8888-9999-000000000002',
@ -57,7 +58,8 @@ BAYMODEL2 = {'id': 124,
'DYucqbeuM7nmJi+8Hb55y1xWoOZItvKJ+n4VKc'
'KMa71G5/4EOQxuQ/sgW965OOO2Hq027yHOwzcR'
'X8vjlQUnTK0HijrbSTLxp/9kazWWraBS0AyXe6'
'Jv0Zio4VeFrfpytB8RtZBN digambar@magnum'
'Jv0Zio4VeFrfpytB8RtZBN digambar@magnum',
'coe': 'kubernetes',
}
CREATE_BAYMODEL = copy.deepcopy(BAYMODEL1)
@ -141,6 +143,7 @@ class BayModelManagerTest(testtools.TestCase):
self.assertEqual(BAYMODEL1['fixed_network'], baymodel.fixed_network)
self.assertEqual(BAYMODEL1['ssh_authorized_key'],
baymodel.ssh_authorized_key)
self.assertEqual(BAYMODEL1['coe'], baymodel.coe)
def test_baymodel_show_by_name(self):
baymodel = self.mgr.get(BAYMODEL1['name'])
@ -155,6 +158,7 @@ class BayModelManagerTest(testtools.TestCase):
self.assertEqual(BAYMODEL1['fixed_network'], baymodel.fixed_network)
self.assertEqual(BAYMODEL1['ssh_authorized_key'],
baymodel.ssh_authorized_key)
self.assertEqual(BAYMODEL1['coe'], baymodel.coe)
def test_baymodel_create(self):
baymodel = self.mgr.create(**CREATE_BAYMODEL)

View File

@ -137,6 +137,8 @@ class ShellTest(base.TestCase):
args.fixed_network = fixed_network
ssh_authorized_key = "test_key"
args.ssh_authorized_key = ssh_authorized_key
coe = 'swarm'
args.coe = coe
shell.do_baymodel_create(client_mock, args)
client_mock.baymodels.create.assert_called_once_with(
@ -145,7 +147,7 @@ class ShellTest(base.TestCase):
external_network_id=external_network_id,
docker_volume_size=docker_volume_size,
fixed_network=fixed_network, dns_nameserver=dns_nameserver,
ssh_authorized_key=ssh_authorized_key)
ssh_authorized_key=ssh_authorized_key, coe=coe)
def test_do_baymodel_delete(self):
client_mock = mock.MagicMock()

View File

@ -18,7 +18,7 @@ from magnumclient import exceptions
CREATION_ATTRIBUTES = ['name', 'image_id', 'flavor_id', 'master_flavor_id',
'keypair_id', 'external_network_id', 'fixed_network',
'dns_nameserver', 'docker_volume_size',
'ssh_authorized_key']
'ssh_authorized_key', 'coe']
class BayModel(base.Resource):

View File

@ -152,6 +152,10 @@ def do_bay_update(cs, args):
metavar='<external_network_id>',
help='The external Neutron network ID to connect to this bay'
' model.')
@utils.arg('--coe',
required=True,
metavar='<coe>',
help='Specify the Container Orchestration Engine to use.')
@utils.arg('--fixed-network',
metavar='<fixed_network>',
help='The private Neutron network name to connect to this bay'
@ -187,6 +191,7 @@ def do_baymodel_create(cs, args):
opts['dns_nameserver'] = args.dns_nameserver
opts['docker_volume_size'] = args.docker_volume_size
opts['ssh_authorized_key'] = args.ssh_authorized_key
opts['coe'] = args.coe
baymodel = cs.baymodels.create(**opts)
_show_baymodel(baymodel)