fixed bugs in deployment module

Change-Id: I0aff90f4abba485da5a654d5c85f50ef574dd09b
This commit is contained in:
grace.yu 2014-08-05 23:45:12 -07:00
parent 21cc07bed3
commit 9bf3baba34
16 changed files with 77 additions and 378 deletions

View File

@ -24,9 +24,6 @@ from compass.deployment.deploy_manager import DeployManager
from compass.deployment.utils import constants as const
import logging
def deploy(cluster_id, hosts_id_list, username=None):
"""Deploy clusters.
@ -47,11 +44,8 @@ def deploy(cluster_id, hosts_id_list, username=None):
adapter_info = ActionHelper.get_adapter_info(adapter_id, cluster_id,
user)
hosts_info = ActionHelper.get_hosts_info(hosts_id_list, user)
logging.debug('[action][deploy]: adapter_info is %s', adapter_info)
logging.debug('[action][deploy]: cluster_info is %s', cluster_info)
logging.debug('[action][deploy]: hosts_info is %s', hosts_info)
hosts_info = ActionHelper.get_hosts_info(cluster_id, hosts_id_list,
user)
deploy_manager = DeployManager(adapter_info, cluster_info, hosts_info)
#deploy_manager.prepare_for_deploy()
@ -230,7 +224,7 @@ class ActionHelper(object):
return hosts_info
@staticmethod
def save_deployed_config(self, deployed_config, user):
def save_deployed_config(deployed_config, user):
cluster_config = deployed_config[const.CLUSTER]
cluster_id = cluster_config[const.ID]
del cluster_config[const.ID]

View File

@ -66,7 +66,7 @@ class DeployManager(object):
# Package installer cleans previous installing progress.
if self.pk_installer:
self.package_installer.clean_progress()
self.pk_installer.clean_progress()
def prepare_for_deploy(self):
self.clean_progress()
@ -78,7 +78,7 @@ class DeployManager(object):
if self.pk_installer:
# generate target system config which will be installed by OS
# installer right after OS installation is completed.
pk_instl_confs = self.package_installer.generate_installer_config()
pk_instl_confs = self.pk_installer.generate_installer_config()
logging.debug('[DeployManager][deploy] pk_instl_confs is %s',
pk_instl_confs)
@ -100,7 +100,7 @@ class DeployManager(object):
logging.info('DeployManager][deploy]get package installer %s',
self.pk_installer)
pk_deploy_config = self.package_installer.deploy()
pk_deploy_config = self.pk_installer.deploy()
util.merge_dict(deploy_config, pk_deploy_config)
return deploy_config
@ -110,8 +110,8 @@ class DeployManager(object):
if self.os_installer:
self.os_installer.redeploy()
if self.package_installer:
self.package_installer.redeploy()
if self.pk_installer:
self.pk_installer.redeploy()
def remove_hosts(self):
"""Remove hosts from both OS and package installlers server side."""

View File

@ -368,7 +368,7 @@ class BaseConfigManager(object):
logging.info("Adapter Info is None!")
return None
return self.adapter_info.setdefault(const.DIST_SYS_NAME, None)
return self.adapter_info.setdefault(const.NAME, None)
def get_adapter_roles(self):
if not self.adapter_info:
@ -449,7 +449,7 @@ class BaseConfigManager(object):
interfaces = self.get_host_interfaces(host_id)
temp = {}
for key in network_mapping:
nic = network_mapping[key][const.NIC]
nic = network_mapping[key]
if nic in interfaces:
temp[key] = self.get_host_interface_config(host_id, nic)
temp[key][const.NIC] = nic

View File

@ -73,7 +73,7 @@ class CobblerInstaller(OSInstaller):
return os.path.join(compass_setting.TMPL_DIR, 'cobbler')
def __repr__(self):
return '%r[name=%r,remote=%r,token=%r' % (
return '%r[remote=%r,token=%r' % (
self.__class__.__name__, self.remote, self.token)
def _get_cobbler_server(self, cobbler_url):
@ -137,7 +137,7 @@ class CobblerInstaller(OSInstaller):
# set host deploy config
temp = {}
temp = self.config_manager.get_host_deploy_os_config(host_id)
temp = self.config_manager.get_host_deployed_os_config(host_id)
temp[const.TMPL_VARS_DICT] = vars_dict
host_config = {const.DEPLOYED_OS_CONFIG: temp}
hosts_deploy_config[host_id] = host_config
@ -193,10 +193,9 @@ class CobblerInstaller(OSInstaller):
"""Sync the updated config to cobbler and trigger installation."""
try:
self.remote.sync(self.token)
logging.debug('sync %s', self)
os.system('sudo service rsyslog restart')
except Exception as ex:
logging.debug("Failed to sync cobbler server! Error:", ex.message)
logging.debug("Failed to sync cobbler server! Error: %" % ex)
raise ex
def _get_system_config(self, host_id, vars_dict):

View File

@ -465,7 +465,7 @@ class ChefConfigManager(BaseConfigManager):
def get_chef_databag_names(self):
pk_installer_settings = self.get_pk_installer_settings()
if self.DATABAGS in pk_installer_settings:
if self.DATABAGS not in pk_installer_settings:
logging.info("No databags is set!")
return None

View File

@ -33,7 +33,7 @@ DIST_SYS_NAME = 'distributed_system_name'
INSTALLER_SETTINGS = 'settings'
METADATA = 'metadata'
OS_INSTALLER = 'os_installer'
PK_INSTALLER = 'pk_installer'
PK_INSTALLER = 'package_installer'
SUPPORT_OSES = 'supported_oses'

View File

@ -35,7 +35,7 @@ adapter_test_config = {
}
}
},
"pk_installer": {
"package_installer": {
"name": "chef_installer",
"settings": {
"chef_url": "https://127.0.0.1",
@ -205,15 +205,9 @@ cluster_test_config = {
}
},
"network_mapping": {
"management": {
"interface": "eth0"
},
"public": {
"interface": "eth2"
},
"tenant": {
"interface": "eth1"
}
"management": "eth0",
"public": "eth2",
"tenant": "eth1"
}
}
}
@ -258,12 +252,8 @@ hosts_test_config = {
},
"package_config": {
"network_mapping": {
"management": {
"interface": "vnet0"
},
"tenant": {
"interface": "vnet1"
}
"management": "vnet0",
"tenant": "vnet1"
},
"roles": ["os-controller"]
}

View File

@ -1,7 +1,7 @@
NAME = 'ceph(chef)'
DSPLAY_NAME = 'ceph(ceph)'
PARENT = 'ceph'
PACKAGE_INSTALLER = 'chef(icehouse)'
PACKAGE_INSTALLER = 'chef_installer'
OS_INSTALLER = 'cobbler'
SUPPORTED_OS_PATTERNS = ['(?i)centos.*', '(?i)ubuntu.*']
DEPLOYABLE = True

View File

@ -1,3 +1,3 @@
NAME = 'CentOS6.5'
NAME = 'CentOS-6.5-x86_64'
PARENT = 'CentOS'
DEPLOYABLE = True

View File

@ -1,3 +1,3 @@
NAME = 'Ubuntu12.04'
NAME = 'Ubuntu-12.04-x86_64'
PARENT = 'Ubuntu'
DEPLOYABLE = True

View File

@ -23,7 +23,7 @@ METADATA = {
'GMT 0:00', 'GMT +1:00', 'GMT +2:00', 'GMT +3:00',
'GMT +4:00', 'GMT +5:00', 'GMT +6:00', 'GMT +7:00',
'GMT +8:00', 'GMT +9:00', 'GMT +10:00', 'GMT +11:00',
'GMT +12:00', UTC
'GMT +12:00', 'UTC'
],
'mapping_to': 'timezone'
}

View File

@ -36,4 +36,9 @@ ROLES = [{
'display_name': 'ha proxy node',
'description': 'ha proxy node',
'optional': True
}, {
'role': 'allinone-compute',
'display_name': 'all in one compute',
'description': 'all in one compute',
'optional': True
}]

View File

@ -74,7 +74,7 @@
"verbose": "True",
"debug": "True",
"service_plugins": [
"router"
"neutron.services.l3_router.l3_router_plugin.L3RouterPlugin"
],
"ml2": {
"type_drivers": "local,flat,vlan,gre",

View File

@ -1,317 +0,0 @@
#set config = $cluster.deploy_package_config
#set mappings = $config.roles_mapping
#set credentials = $config.service_credentials
#set compute_mgmt_nic = $mappings.os_compute.management.interface
#set controller_mgmt_ip = $mappings.os_controller.management.ip
#set controller_mgmt_nic = $mappings.os_controller.management.interface
{
"name": "testing",
"description": "Environment used in testing the upstream cookbooks and reference Chef repository",
"cookbook_versions": {
},
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
},
"override_attributes": {
"mysql": {
"server_root_password": "test",
"server_debian_password": "root",
"server_repl_password": "root",
"allow_remote_root": true,
"root_network_acl": "%"
},
"openstack": {
"auth": {
"validate_certs": false
},
"block-storage": {
"syslog": {
"use": false
},
"api": {
"ratelimit": "False"
},
"debug": true,
"image_api_chef_role": "os-image",
"identity_service_chef_role": "os-identity",
"rabbit_server_chef_role": "os-ops-messaging"
},
"dashboard": {
"use_ssl": "false"
},
"compute": {
"syslog": {
"use": false
},
"libvirt": {
"bind_interface": "$compute_mgmt_nic"
},
"novnc_proxy": {
"bind_interface": "$controller_mgmt_nic"
},
"xvpvnc_proxy": {
"bind_interface": "$controller_mgmt_nic"
},
"image_api_chef_role": "os-image",
"identity_service_chef_role": "os-identity",
"nova_setup_chef_role": "os-compute-api",
"rabbit_server_chef_role": "os-ops-messaging",
"ratelimit": {
"api": {
"enabled": false
},
"volume": {
"enabled": false
}
},
"network": {
"service_type": "neutron",
"fixed_range": "10.0.0.0/8"
}
},
"network": {
"verbose": "True",
"debug": "True",
"service_plugins": [
"router"
],
"ml2": {
"type_drivers": "local,flat,vlan,gre",
"tenant_network_types": "vlan,gre",
"network_vlan_ranges": "physnet1:1000:2999",
"enable_security_group": "True"
},
"openvswitch": {
"tenant_network_type": "vlan",
"network_vlan_ranges": "physnet1:1000:2999",
"bridge_mappings": "physnet1:br-eth1",
"fw_driver": "neutron.agent.firewall.NoopFirewallDriver"
}
},
"db": {
"bind_interface": "$controller_mgmt_nic",
"compute": {
"host": "$controller_mgmt_ip"
},
"identity": {
"host": "$controller_mgmt_ip"
},
"image": {
"host": "$controller_mgmt_ip"
},
"network": {
"host": "$controller_mgmt_ip"
},
"volume": {
"host": "$controller_mgmt_ip"
},
"dashboard": {
"host": "$controller_mgmt_ip"
},
"telemetry": {
"host": "$controller_mgmt_ip"
},
"orchestration": {
"host": "$controller_mgmt_ip"
}
},
"developer_mode": true,
"endpoints": {
"db": {
"host": "$controller_mgmt_ip"
},
"mq": {
"host": "$controller_mgmt_ip"
},
"compute-api": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "8774",
"path": "/v2/%(tenant_id)s"
},
"compute-api-bind": {
"bind_interface": "$controller_mgmt_nic"
},
"compute-ec2-admin": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "8773",
"path": "/services/Admin"
},
"compute-ec2-api": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "8773",
"path": "/services/Cloud"
},
"compute-xvpvnc": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "6081",
"path": "/console"
},
"compute-novnc": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "6080",
"path": "/vnc_auto.html"
},
"compute-novnc-bind": {
"bind_interface": "$controller_mgmt_nic"
},
"vnc_bind": {
"bind_interface": "$controller_mgmt_nic"
},
"image-api": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "9292",
"path": "/v2"
},
"image-api-bind": {
"bind_interface": "$controller_mgmt_nic"
},
"image-registry": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "9191",
"path": "/v2"
},
"image-registry-bind": {
"bind_interface": "$controller_mgmt_nic"
},
"identity-bind": {
"bind_interface": "$controller_mgmt_nic"
},
"identity-api": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "5000",
"path": "/v2.0"
},
"identity-admin": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "35357",
"path": "/v2.0"
},
"block-storage-api": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "8776",
"path": "/v1/%(tenant_id)s"
},
"block-storage-api-bind": {
"bind_interface": "$controller_mgmt_nic"
},
"telemetry-api": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "8777",
"path": "/v1"
},
"network-api": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "9696",
"path": ""
},
"network-api-bind": {
"bind_interface": "$controller_mgmt_nic"
},
"network-openvswitch": {
"bind_interface": "$controller_mgmt_nic"
},
"orchestration-api": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "8004",
"path": "/v1/%(tenant_id)s"
},
"orchestration-api-cfn": {
"host": "$controller_mgmt_ip",
"scheme": "http",
"port": "8000",
"path": "/v1"
}
},
"identity": {
"admin_user": "admin",
"bind_interface": "$controller_mgmt_nic",
"catalog": {
"backend": "sql"
},
"debug": true,
"rabbit_server_chef_role": "os-ops-messaging",
"roles": [
"admin",
"keystone_admin",
"keystone_service_admin",
"member",
"netadmin",
"sysadmin"
],
"syslog": {
"use": false
},
"tenants": [
"admin",
"service",
"demo"
],
"token": {
"backend": "sql"
},
"users": {
"admin": {
"password": "admin",
"default_tenant": "admin",
"roles": {
"admin": [
"admin"
],
"keystone_admin": [
"admin"
],
"keystone_service_admin": [
"admin"
]
}
}
}
},
"image": {
"api": {
"bind_interface": "eth0"
},
"debug": true,
"identity_service_chef_role": "os-identity",
"rabbit_server_chef_role": "os-ops-messaging",
"registry": {
"bind_interface": "eth0"
},
"syslog": {
"use": false
},
"upload_image": {
"cirros": "http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img"
},
"upload_images": [
"cirros"
]
},
"memcached_servers": [
"$controller_mgmt_nic:11211"
],
"mq": {
"user": "$credentials.mq.username",
"password": "$credentials.mq.password",
"vhost": "/nova",
"network": {
"service_type": "rabbitmq"
}
}
}
}
}

View File

@ -48,6 +48,7 @@
#set partition_config = ';'.join((partition_config, $path))
#end for
#set partition_config = partition_config[1:]
#import crypt
#set $password = crypt.crypt($host.server_credentials.password, "az")
#set no_proxy = ','.join($host.no_proxy)
"username": "$host.server_credentials.username",

View File

@ -1,36 +1,63 @@
{
"name": "$host.fullname",
"name": "$host.name",
"hostname": "$host.hostname",
"profile": "$host.profile",
"gateway": "$host.gateway",
"name_servers": "$host.name_servers",
"name_servers_search": "$host.search_path",
#import simplejson as json
#set nameservers = json.dumps($host.nameservers, encoding='utf-8')
"name_servers": $nameservers,
#set search_path = ' '.join($host.search_path)
"name_servers_search": "$search_path",
"proxy": "$host.http_proxy",
"modify_interface":
#import simplejson
#set interfaces = $host.networks.interfaces
#set networks = $host.networks
#set rekeyed = {}
#for $nic, $val in $interfaces.iteritems():
#set $rekeyed = { "ipaddress-vnet0" : $val.ip, "netmask-vnet0": $val.netmask, "management-vnet0": $val.is_mgmt, "static-vnet0" : True }
#if $val.is_mgmt:
#set $rekeyed["macaddress-vnet0"] = $host.mac_address
#set $rekeyed["dnsname-vnet0"] = $host.dns
#set promicnic = ""
#for $nic, $val in $networks.iteritems():
#set ip_key = '-'.join(('ipaddress', $nic))
#set netmask_key = '-'.join(('netmask', $nic))
#set mgmt_key = '-'.join(('management', $nic))
#set static_key = '-'.join(('static', $nic))
#set $rekeyed[$ip_key] = $val.ip
#set $rekeyed[$netmask_key] = $val.netmask
#set $rekeyed[$mgmt_key] = $val.is_mgmt
#set $rekeyed[$static_key] = True
#if $val.is_promiscuous:
#set promicnic = $nic
#end if
#if $val.is_mgmt:
#set mac_key = '-'.join(('macaddress', $nic))
#set dns_key = '-'.join(('dns', $nic))
#set $rekeyed[$mac_key] = $host.mac
#set $rekeyed[$dns_key] = $host.dns
#end if
#end for
#set $str=simplejson.dumps($rekeyed, encoding='utf-8')
$str
#set nic_info = json.dumps($rekeyed, encoding='utf-8')
$nic_info
,
"ksmeta":{
"username": "$host.server_credentials.username",
#set partition_config = ''
#for k, v in $host.partition.iteritems():
#set path = ''
#if v['vol_percentage']:
#set $path = k + ' ' + str(v['vol_percentage']) + '%'
#else:
#set $path = k + ' ' + str(v['vol_size'])
#end if
#set partition_config = ';'.join((partition_config, $path))
#end for
#set partition_config = partition_config[1:]
#import crypt
#set $password = crypt.crypt($host.server_credentials.password, "az")
#set no_proxy = ','.join($host.no_proxy)
"username": "$host.server_credentials.username",
"password": "$password",
#set f=[(k + ' ' + v['vol_percentage'] or v['vol_size']) for k,v in $host.partition.iteritems()]
#set $partition_config = '; '.join($f)
"promisc_nics": "$promicnic",
"partition": "$partition_config",
"https_proxy": "$host.https_proxy",
"ignore_proxy": "$host.ignore_proxy",
"ntp_server": "$host.ntp_server"
"ntp_server": "$host.ntp_server",
"timezone": "$host.timezone",
"ignore_proxy": "$no_proxy"
}
}