Set default node_count to 1.
When user creates a bay without passing node-count, the default node-count is 1 which means one bay-master and one bay-node is created. But the bay-list shows node-count as 'None' which is wrong. So this patch sets default node_count to 1. Change-Id: I91a1903cec38fdae08a75d5b364640dab41a9e72 Closes-bug: #1465097
This commit is contained in:
parent
e1692ebd96
commit
c9e251cba4
|
@ -266,6 +266,10 @@ class BaysController(rest.RestController):
|
|||
auth_token = context.auth_token_info['token']
|
||||
bay_dict['project_id'] = auth_token['project']['id']
|
||||
bay_dict['user_id'] = auth_token['user']['id']
|
||||
# NOTE(suro-patz): Apply default node_count is 1, None -> 1
|
||||
if bay_dict.get('node_count', None) is None:
|
||||
bay_dict['node_count'] = 1
|
||||
|
||||
new_bay = objects.Bay(context, **bay_dict)
|
||||
if isinstance(bay.bay_create_timeout, wsme.types.UnsetType):
|
||||
bay.bay_create_timeout = 0
|
||||
|
|
|
@ -469,6 +469,14 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(400, response.status_int)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_create_bay_with_no_node_count(self):
|
||||
bdict = apiutils.bay_post_data()
|
||||
del bdict['node_count']
|
||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(201, response.status_int)
|
||||
self.assertEqual(1, response.json['node_count'])
|
||||
|
||||
def test_create_bay_with_invalid_long_name(self):
|
||||
bdict = apiutils.bay_post_data(name='x' * 256)
|
||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||
|
|
Loading…
Reference in New Issue