fix bug about flavor in get_adapter_info of deploy action

Change-Id: Ib148cd5790bcff15f99ff047a9097d2573731788
This commit is contained in:
grace.yu 2014-08-20 11:41:56 -07:00
parent 0016de31b2
commit 14eab119b3
2 changed files with 29 additions and 24 deletions

View File

@ -124,11 +124,14 @@ class ActionHelper(object):
{
"id": 1,
"name": "xxx",
"flavor": {
"flavor_name": "xxx",
"roles": ['xxx', 'yyy', ...],
"template": "xxx.tmpl"
},
"flavors": [
{
"flavor_name": "xxx",
"roles": ['xxx', 'yyy', ...],
"template": "xxx.tmpl"
},
...
],
"metadata": {
"os_config": {
...
@ -153,9 +156,9 @@ class ActionHelper(object):
metadata = cluster_db.get_cluster_metadata(user, cluster_id)
adapter_info.update(metadata)
roles_info = adapter_info[const.FLAVOR][const.ROLES]
roles_list = [role[const.NAME] for role in roles_info]
adapter_info[const.FLAVOR][const.ROLES] = roles_list
for flavor_info in adapter_info[const.FLAVORS]:
roles = flavor_info[const.ROLES]
flavor_info[const.ROLES] = ActionHelper._get_role_names(roles)
return adapter_info

View File

@ -43,20 +43,22 @@ class TestDeployAction(unittest2.TestCase):
mock_get_adapter.return_value = {
"id": 1,
"name": "test_adapter",
"flavor": {
"flavor_name": "test_flavor",
"template": "test_tmpl.tmpl",
"roles": [
{
"name": "test-role-1",
"display_name": "test role 1"
},
{
"name": "test-role-2",
"display_name": "test role 2"
}
]
},
"flavors": [
{
"flavor_name": "test_flavor",
"template": "test_tmpl.tmpl",
"roles": [
{
"name": "test-role-1",
"display_name": "test role 1"
},
{
"name": "test-role-2",
"display_name": "test role 2"
}
]
}
],
"os_installer": {
"name": "test_os_installer",
"settings": {
@ -77,11 +79,11 @@ class TestDeployAction(unittest2.TestCase):
expected_output = {
"id": 1,
"name": "test_adapter",
"flavor": {
"flavors": [{
"flavor_name": "test_flavor",
"template": "test_tmpl.tmpl",
"roles": ["test-role-1", "test-role-2"]
},
}],
"os_installer": {
"name": "test_os_installer",
"settings": {