Fix rabbitmq username/password hardcoded

Fix Rabbitmq/mysql username/password hardcoded. At the same time, more
fields in template will be dynamic filled such as neutron config according
to user input.

Change-Id: I8d69be0dd1289401fee7fc3f4ec1675b9109ed60
Closes-bug: #1393959
This commit is contained in:
grace.yu 2014-12-08 10:50:26 -08:00
parent 2fe3c81083
commit 15ffc5e1aa
3 changed files with 116 additions and 19 deletions

View File

@ -38,7 +38,8 @@ METADATA = {
'required_in_whole_config': True,
'key_extensions': {
'$console': ['admin', 'compute', 'dashboard', 'image', 'metering', 'network', 'object-store', 'volume']
}
},
'mapping_to': 'console_credentials'
},
'$console': {
'_self': {
@ -62,6 +63,26 @@ METADATA = {
}
}
},
'neutron_config': {
'_self': {
'mapping_to': 'neutron_config'
},
'openvswitch': {
'_self': {
'mapping_to': 'openvswitch',
'required_in_whole_config': True
},
'tenant_network_type': {
'_self': {
'mapping_to': 'tenant_network_type',
'is_required': True,
'field': 'general',
'options': ['gre', 'vlan'],
'default_value': 'gre'
}
}
}
},
'network_mapping': {
'_self': {
'required_in_whole_config': True,

View File

@ -91,6 +91,21 @@
#set dash_role = $get_role('os_dashboard', $controller)
#set dash_ip = $dash_role.management.ip
## Set services credentials
#set db_pass = $getDictValue('service_credentials/mysql/password', 'root')
#set mq_username = $getDictValue('service_credentials/rabbitmq/username', 'guest')
#set mq_pass = $getDictValue('service_credentials/rabbitmq/password', 'guest')
## Set Openstack neutron config
#set tenant_network_type = $getDictValue('neutron_config/openvswitch/tenant_network_type', 'gre')
#set enable_tunneling = True
#set bridge_mappings = 'physnet1:br-eth1'
#if $tenant_network_type != 'gre'
#set enable_tunneling = False
#set bridge_mappings = ''
#end if
## Utility functions definition
#def get_role($role_name, $default_roles=None)
#set target_role = $getVar($role_name, None)
#if $target_role is None and $default_roles is not None
@ -107,6 +122,26 @@
#end if
#return $target_role
#end def
#def getDictValue($path, $default_value="")
#set keys = str($path).split('/')
#set value = $getVar($keys[0], {})
#if not $value
#return $default_value
#else
#for $key in $keys[1:]
#try
#set value = $value[$key]
#except
#return $default_value
#end try
#end for
#end if
#return $value
#end def
{
"name": "ceph_base_tmpl",
"description": "Environment used in testing the upstream cookbooks and reference Chef repository",
@ -157,9 +192,9 @@
"osd_devices": $devices
},
"mysql": {
"server_root_password": "test",
"server_debian_password": "root",
"server_repl_password": "root",
"server_root_password": "$db_pass",
"server_debian_password": "$db_pass",
"server_repl_password": "$db_pass",
"allow_remote_root": true,
"root_network_acl": "%"
},
@ -234,15 +269,18 @@
"router"
],
"ml2": {
"type_drivers": "gre",
"tenant_network_types": "gre",
"type_drivers": "$tenant_network_type",
"tenant_network_types": "$tenant_network_type",
"network_vlan_ranges": "physnet1:2700:2999",
"tunnel_id_ranges": "1:1000",
"enable_security_group": "True"
},
"openvswitch": {
"tenant_network_type": "gre",
"enable_tunneling": "True",
"tenant_network_type": "$tenant_network_type",
"enable_tunneling": "$enable_tunneling",
"tunnel_id_ranges": "1:1000",
"network_vlan_ranges": "physnet1:2700:2999",
"bridge_mappings": "$bridge_mappings",
"bind_interface": "$network_worker_tenant_nic"
},
"l3": {
@ -452,8 +490,8 @@
]
},
"mq": {
"user": "guest",
"password": "test",
"user": "$mq_username",
"password": "$mq_pass",
"vhost": "/nova",
"network": {
"service_type": "rabbitmq"

View File

@ -50,6 +50,21 @@
#set dash = $get_role('os_dashboard', $controller)
#set dash_ip = $dash.management.ip
## Set services credentials
#set db_pass = $getDictValue('service_credentials/mysql/password', 'root')
#set mq_username = $getDictValue('service_credentials/rabbitmq/username', 'guest')
#set mq_pass = $getDictValue('service_credentials/rabbitmq/password', 'guest')
## Set Openstack neutron config
#set tenant_network_type = $getDictValue('neutron_config/openvswitch/tenant_network_type', 'gre')
#set enable_tunneling = True
#set bridge_mappings = 'physnet1:br-eth1'
#if $tenant_network_type != 'gre'
#set enable_tunneling = False
#set bridge_mappings = ''
#end if
## Utility functions definition
#def get_role($role_name, $default_roles=None)
#set target_role = $getVar($role_name, None)
#if $target_role is None and $default_roles is not None
@ -66,6 +81,26 @@
#end if
#return $target_role
#end def
#def getDictValue($path, $default_value="")
#set keys = str($path).split('/')
#set value = $getVar($keys[0], {})
#if not $value
#return $default_value
#else
#for $key in $keys[1:]
#try
#set value = $value[$key]
#except
#return $default_value
#end try
#end for
#end if
#return $value
#end def
{
"name": "base",
"description": "Environment used in testing the upstream cookbooks and reference Chef repository",
@ -81,9 +116,9 @@
"default_attributes": {
"local_repo": "",
"mysql": {
"server_root_password": "test",
"server_debian_password": "root",
"server_repl_password": "root",
"server_root_password": "$db_pass",
"server_debian_password": "$db_pass",
"server_repl_password": "$db_pass",
"allow_remote_root": true,
"root_network_acl": "%"
},
@ -146,15 +181,18 @@
"router"
],
"ml2": {
"type_drivers": "gre",
"tenant_network_types": "gre",
"type_drivers": "$tenant_network_type",
"tenant_network_types": "$tenant_network_type",
"tunnel_id_ranges": "1:1000",
"network_vlan_ranges": "physnet1:2700:2999",
"enable_security_group": "True"
},
"openvswitch": {
"tenant_network_type": "gre",
"enable_tunneling": "True",
"tenant_network_type": "$tenant_network_type",
"enable_tunneling": "$enable_tunneling",
"tunnel_id_ranges": "1:1000",
"network_vlan_ranges": "physnet1:2700:2999",
"bridge_mappings": "$bridge_mappings",
"bind_interface": "$network_worker_tenant_nic"
},
"l3": {
@ -364,8 +402,8 @@
]
},
"mq": {
"user": "guest",
"password": "test",
"user": "$mq_username",
"password": "$mq_pass",
"vhost": "/nova",
"network": {
"service_type": "rabbitmq"