summaryrefslogtreecommitdiffstats
path: root/deploy
diff options
context:
space:
mode:
Diffstat (limited to 'deploy')
-rwxr-xr-xdeploy/check_os_progress.sh7
-rw-r--r--deploy/config/network.py46
-rwxr-xr-xdeploy/post.sh48
-rw-r--r--deploy/post/execute.py46
-rw-r--r--deploy/tempest.py29
5 files changed, 145 insertions, 31 deletions
diff --git a/deploy/check_os_progress.sh b/deploy/check_os_progress.sh
index bb2b3340..e742467c 100755
--- a/deploy/check_os_progress.sh
+++ b/deploy/check_os_progress.sh
@@ -43,13 +43,6 @@ if [ $deploy_env == 0 ];then
echo "detail info of host $host_id:"
daisy host-detail $host_id
done
-else
- for host_id in $hosts_id;
- do
- echo "update host $host_id ipmi user and passwd"
- daisy host-update $host_id --ipmi-user zteroot --ipmi-passwd superuser
- done
- echo "update all hosts ipmi user and passwd ok!"
fi
echo "check os installing progress..."
diff --git a/deploy/config/network.py b/deploy/config/network.py
index 1b3277e7..9f03bc15 100644
--- a/deploy/config/network.py
+++ b/deploy/config/network.py
@@ -12,9 +12,24 @@ from deploy.common import query
class NetworkConfig(object):
+ type2name = {
+ 'EXTERNAL': 'ext',
+ 'MANAGEMENT': 'man',
+ 'STORAGE': 'stor',
+ 'PUBLICAPI': 'pub',
+ 'TENANT': 'tenant',
+ }
+
def __init__(self, network_file):
+ self._parsers = {
+ 'network-config-metadata': self._parse_metadata,
+ 'networks': self._parse_networks,
+ 'interfaces': self._parse_interfaces
+ }
+
self._file = network_file
self._get_config()
+ self._parse()
def _get_config(self):
self.config = yaml.safe_load(file(self._file))
@@ -23,6 +38,37 @@ class NetworkConfig(object):
return query.find(lambda item: item['name'] == name,
self.config['networks'])
+ def _parse(self):
+ for conf_k, conf_v in self.config.iteritems():
+ self._parsers.get(conf_k,
+ lambda x: setattr(self, conf_k, conf_v))(conf_v)
+
+ def _parse_metadata(self, metadatas):
+ for meta_k, meta_v in metadatas.iteritems():
+ setattr(self, meta_k, meta_v)
+
+ def _parse_networks(self, networks):
+ for network in networks:
+ name = network['name']
+ self._setattr(name, '', network)
+ for network_k, network_v in network.iteritems():
+ self._setattr(name, network_k, network_v)
+
+ def _parse_interfaces(self, interfaces):
+ for interface in interfaces:
+ self._setattr(interface['name'],
+ 'iterface',
+ interface['interface'])
+
+ def _setattr(self, network_type, field, value):
+ prefix = self.type2name[network_type]
+ name = '{}_{}'.format(prefix, field) if field else prefix
+ setattr(self, name, value)
+
@property
def external_network(self):
return self._get_network('EXTERNAL')
+
+ @property
+ def external_name(self):
+ return self.external_network['network_name']
diff --git a/deploy/post.sh b/deploy/post.sh
new file mode 100755
index 00000000..df3c280c
--- /dev/null
+++ b/deploy/post.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+SCRIPT_PATH=$(readlink -f $(dirname $0))
+
+export PYTHONPATH=$SCRIPT_PATH/..
+
+usage ()
+{
+cat << EOF
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+`basename $0`: post process after OpenStack is deployed
+
+usage: `basename $0` -n network_config_file
+
+OPTIONS:
+ -n network configuration path, necessary
+ -h Print this message and exit
+
+Description:
+ post process after OpenStack is deployed
+
+Examples:
+sudo `basename $0` -n /home/daisy/labs/zte/virtual1/daisy/config/network.yml
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+EOF
+}
+
+NETWORK=''
+
+while getopts "n:h" OPTION
+do
+ case $OPTION in
+ n)
+ NETWORK=${OPTARG}
+ ;;
+ h)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "${OPTION} is not a valid argument"
+ usage
+ exit 0
+ ;;
+ esac
+done
+
+python $PYTHONPATH/deploy/post/execute.py -nw $NETWORK
diff --git a/deploy/post/execute.py b/deploy/post/execute.py
index b9665e10..d310acbc 100644
--- a/deploy/post/execute.py
+++ b/deploy/post/execute.py
@@ -9,15 +9,17 @@
import os
import glance
+import argparse
+
import neutron
import nova
+from deploy.config.network import NetworkConfig
-def _config_admin_external_network():
- name = 'admin_external'
+def _config_external_network(ext_name):
body = {
'network': {
- 'name': name,
+ 'name': ext_name,
'admin_state_up': True,
'shared': False,
'provider:network_type': 'flat',
@@ -26,28 +28,34 @@ def _config_admin_external_network():
}
}
- return name, body
+ return body
-def _config_admin_external_subnet(nid):
+def _config_external_subnet(ext_id, network_conf):
return {
'subnets': [
{
- 'name': 'admin_external_subnet',
- 'cidr': '172.10.101.0/24',
+ 'name': '{}_subnet'.format(network_conf.ext_network_name),
+ 'cidr': network_conf.ext_cidr,
'ip_version': 4,
- 'network_id': nid,
- 'gateway_ip': '172.10.101.1',
- 'allocation_pools': [{
- 'start': '172.10.101.2',
- 'end': '172.10.101.12'
- }],
+ 'network_id': ext_id,
+ 'gateway_ip': network_conf.ext_gateway,
+ 'allocation_pools': network_conf.ext_ip_ranges,
'enable_dhcp': False
}
]
}
+def _create_external_network(network_file):
+ network_conf = NetworkConfig(network_file=network_file)
+ ext_name = network_conf.ext_network_name
+ neutronclient = neutron.Neutron()
+ ext_id = neutronclient.create_network(ext_name,
+ _config_external_network(ext_name))
+ neutronclient.create_subnet(_config_external_subnet(ext_id, network_conf))
+
+
def _create_flavor_m1_micro():
name = 'm1.micro'
novaclient = nova.Nova()
@@ -64,7 +72,7 @@ def _prepare_cirros():
url = 'http://download.cirros-cloud.net'
version = '0.3.5'
name = 'cirros-{}-x86_64-disk.img'.format(version)
- img = os.path.join(os.path.abspath(os.path.dirname(__file__)), name)
+ img = os.path.join("/var/lib/daisy/images", name)
if not os.path.isfile(img):
cmd = "wget %(url)s/%(version)s/%(name)s -O %(path)s" % {
'url': url,
@@ -96,9 +104,13 @@ def _create_image_TestVM():
def main():
- neutronclient = neutron.Neutron()
- nid = neutronclient.create_network(*(_config_admin_external_network()))
- neutronclient.create_subnet(_config_admin_external_subnet(nid))
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-nw', '--network-file',
+ type=str,
+ required=True,
+ help='network configuration file')
+ args = parser.parse_args()
+ _create_external_network(args.network_file)
_create_flavor_m1_micro()
_create_image_TestVM()
diff --git a/deploy/tempest.py b/deploy/tempest.py
index f01aa77b..6e626c71 100644
--- a/deploy/tempest.py
+++ b/deploy/tempest.py
@@ -31,7 +31,9 @@ _CLI_OPTS = [
help='Config cluster'),
cfg.StrOpt('host',
help='Config host'),
- cfg.IntOpt('env',
+ cfg.StrOpt('install',
+ help='install daisy'),
+ cfg.IntOpt('isbare',
help='deploy environment'),
]
@@ -86,10 +88,14 @@ def prepare_install():
cluster_id = cluster_info.id
add_hosts_interface(cluster_id, hosts_info, hosts_name,
host_interface_map, vip)
- if 'env' in conf and conf['env'] == 0:
- build_pxe_without_ipmi(cluster_id)
+ if 'isbare' in conf and conf['isbare'] == 0:
+ install_os_for_vm_step1(cluster_id)
else:
- build_pxe_with_ipmi(cluster_id)
+ print("daisy baremetal deploy start")
+ install_os_for_bm_oneshot(cluster_id)
+ elif conf['install'] and conf['install'] == 'yes':
+ install_os_for_vm_step2(cluster_id)
+
except Exception:
print("Deploy failed!!!.%s." % traceback.format_exc())
else:
@@ -102,15 +108,22 @@ def build_pxe_for_discover(cluster_id):
client.install.install(**cluster_meta)
-def build_pxe_without_ipmi(cluster_id):
+def install_os_for_vm_step1(cluster_id):
cluster_meta = {'cluster_id': cluster_id,
'pxe_only': "true"}
client.install.install(**cluster_meta)
-def build_pxe_with_ipmi(cluster_id):
+def install_os_for_bm_oneshot(cluster_id):
+ cluster_meta = {'cluster_id': cluster_id,
+ 'pxe_only': "false",
+ 'skip_pxe_ipmi': "false"}
+ client.install.install(**cluster_meta)
+
+
+def install_os_for_vm_step2(cluster_id):
cluster_meta = {'cluster_id': cluster_id,
- 'pxe_only': "false"}
+ 'skip_pxe_ipmi': "true"}
client.install.install(**cluster_meta)
@@ -159,6 +172,8 @@ def add_hosts_interface(cluster_id, hosts_info, hosts_name, host_interface_map,
for host_name, host in zip(hosts_name, hosts_info):
host = host.to_dict()
host['cluster'] = cluster_id
+ host['ipmi_user'] = 'zteroot'
+ host['ipmi_passwd'] = 'superuser'
for interface in host['interfaces']:
interface_name = interface['name']
if interface_name in host_interface_map: