Merge "modify multinode environment template" into dev/experimental

This commit is contained in:
Jenkins 2014-09-05 18:01:12 +00:00 committed by Gerrit Code Review
commit cb174227fc
17 changed files with 345 additions and 84 deletions

View File

@ -241,8 +241,14 @@ class ActionHelper(object):
for host_id in hosts_id_list:
info = cluster_db.get_cluster_host(user, cluster_id, host_id)
logging.debug("checking on info %r %r" % (host_id, info))
info[const.ROLES] = ActionHelper._get_role_names(info[const.ROLES])
# TODO(grace): Is following line necessary??
roles_info = info.setdefault(const.ROLES, [])
if not roles_info:
raise Exception("Host(id=%d) haven't set any roles!" % host_id)
config = cluster_db.get_cluster_host_config(user,
cluster_id,
host_id)

View File

@ -253,6 +253,17 @@ class BaseConfigManager(object):
def get_host_roles(self, host_id):
return self.__get_host_item(host_id, const.ROLES, [])
def get_all_hosts_roles(self, hosts_id_list=None):
roles = []
if hosts_id_list is None:
hosts_id_list = self.get_host_id_list()
for host_id in hosts_id_list:
host_roles = self.get_host_roles(host_id)
roles.extend([role for role in host_roles if role not in roles])
return roles
def get_host_roles_mapping(self, host_id):
roles_mapping = {}
deployed_pk_config = self.get_host_package_config(host_id)

View File

@ -58,6 +58,7 @@ class ChefInstaller(PKInstaller):
key, client = self.get_chef_credentials(installer_settings)
self.chef_api = self._get_chef_api(key, client)
self.all_chef_roles = self.get_all_roles()
logging.debug('%s instance created', self)
@classmethod
@ -88,6 +89,15 @@ class ChefInstaller(PKInstaller):
return chef_api
def get_all_roles(self):
import chef
if not self.chef_api:
logging.info("chefAPI is None! Cannot retrieve roles from server.")
return None
roles_objs = chef.Role.list(self.chef_api)
return [name for name, value in roles_objs.items()]
def get_env_name(self, dist_sys_name, cluster_name):
"""Generate environment name."""
return "-".join((dist_sys_name, cluster_name))
@ -173,6 +183,9 @@ class ChefInstaller(PKInstaller):
run_list = node.run_list
for role in roles:
if role not in self.all_chef_roles:
raise Exception("Cannot find role '%s' on chef server!")
node_role = 'role[%s]' % role
if node_role not in run_list:
node.run_list.append(node_role)
@ -371,6 +384,15 @@ class ChefInstaller(PKInstaller):
return cluster_vars_dict
def validate_roles(self, hosts_id_list):
hosts_roles = self.config_manager.get_all_hosts_roles(hosts_id_list)
for role in hosts_roles:
if role not in self.all_chef_roles:
logging.error("Role: %s cannot be found on chef server!",
role)
return False
return True
def deploy(self):
"""Start to deploy a distributed system. Return both cluster and hosts
deployed configs. The return format:
@ -395,6 +417,9 @@ class ChefInstaller(PKInstaller):
if not host_list:
return {}
if self.validate_roles(host_list) is False:
raise Exception("Some role cannot be found in chef server!")
adapter_name = self.config_manager.get_adapter_name()
cluster_name = self.config_manager.get_clustername()
env_name = self.get_env_name(adapter_name, cluster_name)

View File

@ -63,6 +63,10 @@ class TestChefInstaller(unittest2.TestCase):
ChefInstaller._get_chef_api = Mock()
ChefInstaller._get_chef_api.return_value = 'mock_server'
ChefInstaller.get_all_roles = Mock()
ChefInstaller.get_all_roles.return_value = []
ChefInstaller.validate_roles = Mock()
ChefInstaller.validate_roles.return_value = True
chef_installer = ChefInstaller(config_manager)
return chef_installer
@ -83,8 +87,9 @@ class TestChefInstaller(unittest2.TestCase):
}
}
}
output = self.test_chef._generate_node_attributes(['os-compute'],
vars_dict)
output = self.test_chef._generate_node_attributes(
['os-compute-worker'], vars_dict
)
self.maxDiff = None
self.assertDictEqual(expected_node_attr, output)
@ -97,8 +102,6 @@ class TestChefInstaller(unittest2.TestCase):
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
},
"override_attributes": {
"compute": {
"syslog": {
"use": False
@ -113,6 +116,11 @@ class TestChefInstaller(unittest2.TestCase):
"bind_interface": "eth0"
}
},
"network": {
"l3": {
"external_network_bridge_interface": "eth2"
}
},
"db": {
"bind_interface": "vnet0",
"compute": {
@ -231,7 +239,7 @@ class TestChefInstaller(unittest2.TestCase):
"subnet": "172.16.1.0/24"
}
},
"os_compute": {
"os_compute_worker": {
"management": {
"interface": "eth0",
"ip": "12.234.32.101",
@ -312,7 +320,7 @@ class TestChefInstaller(unittest2.TestCase):
2: {
"deployed_package_config": {
"roles_mapping": {
"os_compute": {
"os_compute_worker": {
"management": {
"interface": "eth0",
"ip": "12.234.32.101",
@ -368,7 +376,7 @@ class TestChefInstaller(unittest2.TestCase):
"subnet": "10.0.0.0/24"
}
},
"os_compute": {
"os_compute_worker": {
"management": {
"interface": "eth0",
"ip": "12.234.32.103",

View File

@ -81,7 +81,7 @@ class TestConfigManager(unittest2.TestCase):
"subnet": "172.16.1.0/24"
}
},
"os_compute": {
"os_compute_worker": {
"management": {
"interface": "eth0",
"ip": "12.234.32.101",
@ -130,6 +130,12 @@ class TestConfigManager(unittest2.TestCase):
output = self.test_config_manager.get_cluster_roles_mapping()
self.assertEqual(expected_output, output)
def test_get_all_hosts_roles(self):
expected_output = ['os-compute-worker', 'os-network', 'os-controller']
output = self.test_config_manager.get_all_hosts_roles()
self.assertEqual(len(expected_output), len(output))
self.assertEqual(sorted(expected_output), sorted(output))
def test_get_host_role_mapping(self):
expected_output = {
"os_network": {
@ -158,7 +164,7 @@ class TestConfigManager(unittest2.TestCase):
"subnet": "10.0.0.0/24"
}
},
"os_compute": {
"os_compute_worker": {
"management": {
"interface": "eth0",
"ip": "12.234.32.103",

View File

@ -287,7 +287,7 @@ hosts_test_config = {
"mac": "00:0c:29:3e:60:a1",
"name": "server02.test",
"hostname": "server02",
"roles": ["os-compute"],
"roles": ["os-compute-worker"],
"networks": {
"eth0": {
"ip": "12.234.32.101",
@ -326,7 +326,7 @@ hosts_test_config = {
"mac": "00:0c:29:3e:60:a2",
"name": "server03.test",
"hostname": "server03",
"roles": ["os-network", "os-compute"],
"roles": ["os-network", "os-compute-worker"],
"networks": {
"eth0": {
"ip": "12.234.32.103",

View File

@ -1,3 +1,47 @@
#set controller_role = $get_role('os_compute_controller', $getVar('os_controller', None))
## Contoller node management IP/interface
#set controller_ip = $controller_role.management.ip
#set controller_nic = $controller_role.management.interface
## Compute node management IP/interface
#set compute_role = $getVar('os_compute_worker', None)
#set compute_nic = $compute_role.management.interface
## Network server/worker node IP/interface
#set network = $getVar('os_network', None)
#set network_server_role = $get_role('os_network_server', [$network, $controller_role])
#set network_worker_role = $get_role('os_network_worker', [$network, $compute_role])
#set network_server_ip = $network_server_role.management.ip
#set network_server_nic = $network_server_role.management.interface
## Network worker node management IP/interface
#set network_worker_ip = $network_worker_role.management.ip
#set network_worker_nic = $network_worker_role.management.interface
#set network_worker_public_nic = $network_worker_role.public.interface
## Database node management IP
#set db_role = $get_role('os_ops_database', $controller_role)
#set db_ip = $db_role.management.ip
#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:
#if isinstance($default_roles, list)
#for $role in $default_roles
#if $role is not None:
#set target_role = $role
#break
#end if
#end for
#else
#set target_role = $default_roles
#end if
#end if
#return target_role
#end def
#set credentials = $getVar('service_credentials', {})
{
"name": "testing",
@ -7,29 +51,32 @@
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
},
"override_attributes": {
"compute": {
"syslog": {
"use": false
},
"libvirt": {
"bind_interface": "$os_compute.management.interface"
"bind_interface": "$compute_nic"
},
"novnc_proxy": {
"bind_interface": "$os_controller.management.interface"
"bind_interface": "$controller_nic"
},
"xvpvnc_proxy": {
"bind_interface": "eth0"
}
},
"network": {
"l3": {
"external_network_bridge_interface": "$network_worker_public_nic"
}
},
"db": {
"bind_interface": "$os_controller.management.interface",
"bind_interface": "$controller_nic",
"compute": {
"host": "$os_controller.management.ip"
"host": "$db_ip"
},
"identity": {
"host": "$os_controller.management.ip"
"host": "$db_ip"
}
},
"mq": {

View File

@ -3,7 +3,7 @@
"openstack": {
"endpoints": {
"compute-vnc-bind": {
"host":"$os_compute.management.ip"
"host":"$os_compute_worker.management.ip"
}
}
}

View File

@ -5,12 +5,21 @@ FLAVORS = [{
'template': 'allinone.tmpl',
'roles': ['allinone-compute']
}, {
'flavor': 'multinodes',
'display_name': 'Multi-node Cluster',
'flavor': 'single-contoller-multi-compute',
'display_name': 'Single controller multi-compute',
'template': 'multinodes.tmpl',
'roles': [
'os-compute-worker', 'os-network', 'os-block-storage-worker',
'os-image', 'os-compute-vncproxy', 'os-controller',
'os-ops-messaging', 'os-ops-database', 'ha-proxy'
'os-controller', 'os-compute-worker', 'os-network',
'os-block-storage-volume'
]
}, {
'flavor': 'multinodes',
'display_name': 'multi-nodes',
'template': 'multnodes.tmpl',
'roles': [
'os-compute-controller','os-compute-worker', 'os-network-server',
'os-network-worker', 'os-block-storage-volume',
'os-block-storage-controller', 'os-image', 'os-dashboard',
'os-identity', 'os-ops-messaging', 'os-ops-database', 'ha-proxy'
]
}]

View File

@ -6,5 +6,5 @@ SETTINGS = {
'chef_server_dns': '$chef_hostname',
'key_dir': '',
'client_name': '',
'databags': ['user_passwords', 'db_passwords', 'service_passwords', 'secrets']
'databags': []
}

View File

@ -6,11 +6,27 @@ ROLES = [{
}, {
'role': 'os-network',
'display_name': 'network node',
'description': 'network node'
'description': 'network node including network server'
}, {
'role': 'os-network-server',
'display_name': 'network server node',
'description': 'network server node'
}, {
'role': 'os-network-worker',
'display_name': 'network node',
'description': 'network node including network server'
}, {
'role': 'os-block-storage-controller',
'display_name': 'storage controller node',
'description': 'storage controller node'
},{
'role': 'os-block-storage-worker',
'display_name': 'storage node',
'description': 'storage node'
}, {
'role': 'os-block-storage-volume',
'display_name': 'storage node',
'description': 'storage node'
}, {
'role': 'os-image',
'display_name': 'image node',
@ -22,7 +38,11 @@ ROLES = [{
}, {
'role': 'os-controller',
'display_name': 'controller node',
'description': 'controller node'
'description': 'controller node including identity, dashboard, network server, and block stroage controller services'
}, {
'role': 'os-compute-controller',
'display_name': 'controller-only node',
'description': 'controller node for nova APIs'
}, {
'role': 'os-ops-messaging',
'display_name': 'message queue node',
@ -31,6 +51,14 @@ ROLES = [{
'role': 'os-ops-database',
'display_name': 'database node',
'description': 'database node'
}, {
'role': 'os-identity',
'display_name': 'keystone node',
'description': 'keystone node'
}, {
'role': 'os-dashboard',
'display_name': 'dashboard node',
'description': 'dashboard node'
}, {
'role': 'ha-proxy',
'display_name': 'ha proxy node',

View File

@ -1,11 +1,29 @@
{
"nova": {
"nova": "mypass"
"nova": "nova"
},
"horizon": {
"horizon": "horizon"
},
"keystone": {
"identity": "identity"
},
"glance": {
"glance": "glance"
},
"ceilometer": {
"ceilometer": "ceilometer"
},
"neutron": {
"neutron": "neutron"
},
"cinder": {
"cinder": "cinder"
},
"heat": {
"heat": "heat"
},
"dash": {
"dash": "dash"
}
}

View File

@ -0,0 +1,8 @@
{
"openstack_identity_bootstrap_token": {
"openstack_identity_bootstrap_token": "openstack_identity_bootstrap_token"
},
"neutron_metadata_secret": {
"neutron_metadata_secret": "neutron_metadata_secret"
}
}

View File

@ -0,0 +1,20 @@
{
"openstack-image": {
"openstack-image" : "openstack-image"
},
"openstack-compute": {
"openstack-compute": "openstack-compute"
},
"openstack-block-storage": {
"openstack-block-storage": "openstack-block-storage"
},
"openstack-orchestration": {
"openstack-orchestration": "openstack-orchestration"
},
"openstack-network": {
"openstack-network": "openstack-network"
},
"rbd": {
"rbd": "rbd"
}
}

View File

@ -0,0 +1,5 @@
{
"admin": {
"admin": "admin"
}
}

View File

@ -1,4 +1,6 @@
#set credentials = $service_credentials
## allinone compute management IP/interface
#set allinone_compute_mgmt_nic = $allinone_compute.management.interface
#set allinone_compute_mgmt_ip = $allinone_compute.management.ip
{
@ -275,18 +277,27 @@
"admin"
]
}
},
"demo": {
"password": "demo",
"default_tenant": "demo",
"roles": {
"member": [
"demo"
]
}
}
}
},
"image": {
"api": {
"bind_interface": "eth0"
"bind_interface": "$allinone_compute_mgmt_nic"
},
"debug": true,
"identity_service_chef_role": "os-identity",
"rabbit_server_chef_role": "os-ops-messaging",
"registry": {
"bind_interface": "eth0"
"bind_interface": "$allinone_compute_mgmt_nic"
},
"syslog": {
"use": false
@ -299,7 +310,7 @@
]
},
"memcached_servers": [
"$allinone_compute_mgmt_nic:11211"
"$allinone_compute_mgmt_ip:11211"
],
"mq": {
"user": "$credentials.rabbitmq.username",

View File

@ -1,4 +1,69 @@
#set controller_mgmt_ip = $os_controller.management.ip
#set controller_role = $get_role('os_compute_controller', $getVar('os_controller', None))
## Contoller node management IP/interface
#set controller_ip = $controller_role.management.ip
#set controller_nic = $controller_role.management.interface
## Compute node management IP/interface
#set compute_role = $getVar('os_compute_worker', None)
#set compute_nic = $compute_role.management.interface
## Network server/worker node IP/interface
#set network = $getVar('os_network', None)
#set network_server_role = $get_role('os_network_server', [$network, $controller_role])
#set network_worker_role = $get_role('os_network_worker', [$network, $compute_role])
#set network_server_ip = $network_server_role.management.ip
#set network_server_nic = $network_server_role.management.interface
## Network worker node management IP/interface
#set network_worker_ip = $network_worker_role.management.ip
#set network_worker_nic = $network_worker_role.management.interface
#set network_worker_public_nic = $network_worker_role.public.interface
## Database node management IP
#set db_role = $get_role('os_ops_database', $controller_role)
#set db_ip = $db_role.management.ip
## Message queue node management IP/interface
#set msg_queue_role = $get_role('os_ops_messaging', $controller_role)
#set msg_queue_ip = $msg_queue_role.management.ip
## Identity (keystone) node IP/interface
#set identity_role = $get_role('os_identity', $controller_role)
#set identity_ip = $identity_role.management.ip
#set identity_nic = $identity_role.management.interface
## Glance node management IP/interface
#set glance_role = $get_role('os_image', $controller_role)
#set glance_ip = $glance_role.management.ip
#set glance_nic = $glance_role.management.interface
## Cinder node management IP/interface
#set cinder_role = $get_role('os_block_storage_controller', $controller_role)
#set cinder_controller_ip = $cinder_role.management.ip
#set cinder_controller_nic = $cinder_role.management.interface
## Dashboard node management IP/interface
#set dash_role = $get_role('os_dashboard', $controller_role)
#set dash_ip = $dash_role.management.ip
#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
#if isinstance($default_roles, list)
#for $role in $default_roles
#if $role is not None
#set target_role = $role
#break
#end if
#end for
#else
#set target_role = $default_roles
#end if
#end if
#return $target_role
#end def
{
"name": "testing",
"description": "Environment used in testing the upstream cookbooks and reference Chef repository",
@ -31,18 +96,17 @@
"use_ssl": "false"
},
"compute": {
#set compute_mgmt_nic = $os_compute_worker.management.interface
"syslog": {
"use": false
},
"libvirt": {
"bind_interface": "$compute_mgmt_nic"
"bind_interface": "$compute_nic"
},
"novnc_proxy": {
"bind_interface": "$compute_mgmt_nic"
"bind_interface": "$compute_nic"
},
"xvpvnc_proxy": {
"bind_interface": "$compute_mgmt_nic"
"bind_interface": "$compute_nic"
},
"ratelimit": {
"api": {
@ -74,96 +138,81 @@
"tunnel_id_ranges": "1:1000"
},
"l3": {
"external_network_bridge_interface": "$os_compute_worker.public.interface"
"external_network_bridge_interface": "$network_worker_public_nic"
}
},
"db": {
"bind_interface": "$os_controller.management.interface",
#set db_role = $getVar('os_ops_database', None)
#set db_mgmt_ip = $os_controller.management.ip
#if db_role is not None:
#set db_mgmt_ip = $db_role.management.ip
#end if
"bind_interface": "$controller_ip",
"compute": {
"host": "$db_mgmt_ip"
"host": "$db_ip"
},
"identity": {
"host": "$db_mgmt_ip"
"host": "$db_ip"
},
"image": {
"host": "$db_mgmt_ip"
"host": "$db_ip"
},
"network": {
"host": "$db_mgmt_ip"
"host": "$db_ip"
},
"volume": {
"host": "$db_mgmt_ip"
"host": "$db_ip"
},
"dashboard": {
"host": "$db_mgmt_ip"
"host": "$db_ip"
},
"telemetry": {
"host": "$db_mgmt_ip"
"host": "$db_ip"
},
"orchestration": {
"host": "$db_mgmt_ip"
"host": "$db_ip"
}
},
"developer_mode": true,
"endpoints": {
"db": {
"host": "$db_mgmt_ip"
"host": "$db_ip"
},
"mq": {
#set msg_queue_ip = controller_mgmt_ip
#if $getVar('os_ops_messaging', None) is not None:
#set msg_queue_ip = $os_ops_messaging.management.ip
#end if
"host": "$msg_queue_ip"
},
"compute-api": {
"host": "$controller_mgmt_ip",
"host": "$controller_ip",
"scheme": "http",
"port": "8774",
"path": "/v2/%(tenant_id)s"
},
"compute-api-bind": {
"bind_interface": "$os_controller.management.interface"
"bind_interface": "$controller_nic"
},
"compute-ec2-admin": {
"host": "$controller_mgmt_ip",
"host": "$controller_ip",
"scheme": "http",
"port": "8773",
"path": "/services/Admin"
},
"compute-ec2-api": {
"host": "$controller_mgmt_ip",
"host": "$controller_ip",
"scheme": "http",
"port": "8773",
"path": "/services/Cloud"
},
"compute-novnc": {
"host": "$controller_mgmt_ip",
"host": "$controller_ip",
"scheme": "http",
"port": "6080",
"path": "/vnc_auto.html"
},
"compute-novnc-bind": {
"bind_interface": "$os_controller.management.interface"
"bind_interface": "$controller_nic"
},
"compute-vnc-bind": {
"bind_interface" : "$os_compute_worker.management.interface"
"bind_interface" : "$compute_nic"
},
"vnc_bind": {
"bind_interface": "$os_controller.management.interface"
"bind_interface": "$controller_nic"
},
"image-api": {
#set glance_ip = controller_mgmt_ip
#set glance_nic = $os_controller.management.interface
#if $getVar('os_image', None) is not None:
#set glance_ip = $os_image.management.ip
#set glance_nic = $os_image.management.interface
#end if
"host": "$glance_ip",
"scheme": "http",
"port": "9292",
@ -182,55 +231,55 @@
"bind_interface": "$glance_nic"
},
"identity-bind": {
"bind_interface": "$os_controller.management.interface"
"bind_interface": "$identity_nic"
},
"identity-api": {
"host": "$controller_mgmt_ip",
"host": "$identity_ip",
"scheme": "http",
"port": "5000",
"path": "/v2.0"
},
"identity-admin": {
"host": "$controller_mgmt_ip",
"host": "$identity_ip",
"scheme": "http",
"port": "35357",
"path": "/v2.0"
},
"block-storage-api": {
"host": "$controller_mgmt_ip",
"host": "$cinder_controller_ip",
"scheme": "http",
"port": "8776",
"path": "/v1/%(tenant_id)s"
},
"block-storage-api-bind": {
"bind_interface": "$os_controller.management.interface"
"bind_interface": "$cinder_controller_nic"
},
"telemetry-api": {
"host": "$controller_mgmt_ip",
"host": "$controller_ip",
"scheme": "http",
"port": "8777",
"path": "/v1"
},
"network-api": {
"host": "$controller_mgmt_ip",
"host": "$network_server_ip",
"scheme": "http",
"port": "9696",
"path": ""
},
"network-api-bind": {
"bind_interface": "$os_controller.management.interface"
"bind_interface": "$network_server_nic"
},
"network-openvswitch": {
"bind_interface": "$os_controller.management.interface"
"bind_interface": "$network_server_nic"
},
"orchestration-api": {
"host": "$controller_mgmt_ip",
"host": "$controller_ip",
"scheme": "http",
"port": "8004",
"path": "/v1/%(tenant_id)s"
},
"orchestration-api-cfn": {
"host": "$controller_mgmt_ip",
"host": "$controller_ip",
"scheme": "http",
"port": "8000",
"path": "/v1"
@ -238,7 +287,7 @@
},
"identity": {
"admin_user": "admin",
"bind_interface": "$os_controller.management.interface",
"bind_interface": "$identity_nic",
"catalog": {
"backend": "sql"
},
@ -252,7 +301,8 @@
},
"tenants": [
"admin",
"service"
"service",
"demo"
],
"token": {
"backend": "sql"
@ -266,6 +316,15 @@
"admin"
]
}
},
"demo": {
"password": "demo",
"default_tenant": "demo",
"roles": {
"member": [
"demo"
]
}
}
}
},
@ -288,7 +347,7 @@
]
},
"memcached_servers": [
"$controller_mgmt_ip:11211"
"$identity_ip:11211"
],
"mq": {
"user": "guest",