diff options
-rwxr-xr-x | ci/deploy/deploy.sh | 4 | ||||
-rwxr-xr-x | deploy/check_openstack_progress.sh | 33 | ||||
-rwxr-xr-x | deploy/check_os_progress.sh | 5 | ||||
-rw-r--r-- | deploy/common/__init__.py | 0 | ||||
-rw-r--r-- | deploy/common/query.py | 5 | ||||
-rw-r--r-- | deploy/config/__init__.py | 0 | ||||
-rw-r--r-- | deploy/config/network.py | 20 | ||||
-rw-r--r-- | deploy/config/vm_environment/zte-virtual1/network.yml | 21 | ||||
-rw-r--r-- | deploy/post/execute.py | 14 | ||||
-rw-r--r-- | deploy/post/nova.py | 25 | ||||
-rw-r--r-- | deploy/prepare.sh | 48 | ||||
-rw-r--r-- | deploy/prepare/__init__.py | 0 | ||||
-rw-r--r-- | deploy/prepare/execute.py | 32 | ||||
-rw-r--r-- | deploy/tempest.py | 12 |
14 files changed, 200 insertions, 19 deletions
diff --git a/ci/deploy/deploy.sh b/ci/deploy/deploy.sh index efae8387..0317d0ba 100755 --- a/ci/deploy/deploy.sh +++ b/ci/deploy/deploy.sh @@ -301,6 +301,8 @@ if [ $IS_BARE == 0 ];then echo "====== add relate config of kolla===========" ssh $SSH_PARAS $DAISY_IP "mkdir -p /etc/kolla/config/nova" ssh $SSH_PARAS $DAISY_IP "echo -e '[libvirt]\nvirt_type=qemu\ncpu_mode=none' >> /etc/kolla/config/nova/nova-compute.conf" + NETWORK_CONF="$REMOTE_SPACE/deploy/config/vm_environment/$LAB_NAME-$POD_NAME/network.yml" + ssh $SSH_PARAS $DAISY_IP "bash $REMOTE_SPACE/deploy/prepare.sh -n $NETWORK_CONF" fi echo "===prepare cluster and pxe===" @@ -337,7 +339,7 @@ sleep 10 if [ $IS_BARE == 0 ];then virsh reboot all_in_one fi -ssh $SSH_PARAS $DAISY_IP "${REMOTE_SPACE}/deploy/check_openstack_progress.sh" +ssh $SSH_PARAS $DAISY_IP "${REMOTE_SPACE}/deploy/check_openstack_progress.sh -n $TARGET_HOSTS_NUM" if [ $? -ne 0 ]; then exit 1; fi diff --git a/deploy/check_openstack_progress.sh b/deploy/check_openstack_progress.sh index f4baff1e..3512d6bc 100755 --- a/deploy/check_openstack_progress.sh +++ b/deploy/check_openstack_progress.sh @@ -1,4 +1,35 @@ #!/bin/bash +usage() +{ + cat << EOF +USAGE: `basename $0` [-n hosts_num] + +OPTIONS: + -n target node numbers + +EXAMPLE: + sudo `basename $0` -d 1 -n 5 +EOF +} + +while getopts "n:h" OPTION +do + case $OPTION in + n) + hosts_num=${OPTARG} + ;; + h) + usage + exit 0 + ;; + *) + echo "${OPTION} is not a valid argument" + usage + exit 0 + ;; + esac +done + source /root/daisyrc_admin echo "check openstack installing progress..." cluster_id=`daisy cluster-list | awk -F "|" '{print $2}' | sed -n '4p' | tr -d " "` @@ -15,7 +46,7 @@ while true; do openstack_install_active=`daisy host-list --cluster-id $cluster_id | awk -F "|" '{print $12}' | grep -c "active" ` openstack_install_failed=`daisy host-list --cluster-id $cluster_id | awk -F "|" '{print $12}' | grep -c "install-failed" ` - if [ $openstack_install_active -eq 1 ]; then + if [ $openstack_install_active -eq $hosts_num ]; then echo "openstack installing successful ..." break elif [ $openstack_install_failed -gt 0 ]; then diff --git a/deploy/check_os_progress.sh b/deploy/check_os_progress.sh index f76af9b6..bb2b3340 100755 --- a/deploy/check_os_progress.sh +++ b/deploy/check_os_progress.sh @@ -37,9 +37,7 @@ done source /root/daisyrc_admin cluster_id=`daisy cluster-list | awk -F "|" '{print $2}' | sed -n '4p' | tr -d " "` hosts_id=`daisy host-list | awk -F "|" '{print $2}'| grep -o "[^ ]\+\( \+[^ ]\+\)*"|tail -n +2` -skip=false if [ $deploy_env == 0 ];then - skip=true for host_id in $hosts_id do echo "detail info of host $host_id:" @@ -54,9 +52,6 @@ else echo "update all hosts ipmi user and passwd ok!" fi -echo "run daisy install command" -daisy install $cluster_id --skip-pxe-ipmi $skip - echo "check os installing progress..." maxcount=180 count=0 diff --git a/deploy/common/__init__.py b/deploy/common/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/deploy/common/__init__.py diff --git a/deploy/common/query.py b/deploy/common/query.py new file mode 100644 index 00000000..9b1adc2c --- /dev/null +++ b/deploy/common/query.py @@ -0,0 +1,5 @@ +def find(function, sequence, default=None): + for s in sequence: + if function(s): + return s + return default diff --git a/deploy/config/__init__.py b/deploy/config/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/deploy/config/__init__.py diff --git a/deploy/config/network.py b/deploy/config/network.py new file mode 100644 index 00000000..ed14f95b --- /dev/null +++ b/deploy/config/network.py @@ -0,0 +1,20 @@ +import yaml + +from deploy.common import query + + +class NetworkConfig(object): + def __init__(self, network_file): + self._file = network_file + self._get_config() + + def _get_config(self): + self.config = yaml.safe_load(file(self._file)) + + def _get_network(self, name): + return query.find(lambda item: item['name'] == name, + self.config['networks']) + + @property + def external_network(self): + return self._get_network('EXTERNAL') diff --git a/deploy/config/vm_environment/zte-virtual1/network.yml b/deploy/config/vm_environment/zte-virtual1/network.yml index 7d746be6..6c8a2824 100644 --- a/deploy/config/vm_environment/zte-virtual1/network.yml +++ b/deploy/config/vm_environment/zte-virtual1/network.yml @@ -17,8 +17,8 @@ networks: - cidr: '10.20.11.0/24'
gateway: '10.20.11.1'
ip_ranges:
- - 'start': '10.20.11.3'
- 'end': '10.20.11.10'
+ - start: '10.20.11.3'
+ end: '10.20.11.10'
name: 'MANAGEMENT'
- cidr: '10.20.11.0/24'
gateway: '10.20.11.1'
@@ -27,22 +27,23 @@ networks: end: '10.20.11.10'
name: 'STORAGE'
- cidr: '172.10.101.0/24'
- gateway: '172.10.101.0'
+ gateway: '172.10.101.1'
ip_ranges:
- - 'start': '172.10.101.1'
- 'end': '172.10.101.10'
- 'name': 'EXTERNAL'
+ - start: 172.10.101.2
+ end: 172.10.101.20
+ name: EXTERNAL
+ network_name: admin_external
- cidr: '10.20.11.0/24'
gateway: '10.20.11.1'
ip_ranges:
- - 'start': '10.20.11.3'
- 'end': '10.20.11.10'
+ - start: '10.20.11.3'
+ end: '10.20.11.10'
name: 'PUBLICAPI'
- cidr: '10.20.11.0/24'
gateway: '10.20.11.1'
ip_ranges:
- - 'start': '10.20.11.3'
- 'end': '10.20.11.10'
+ - start: '10.20.11.3'
+ end: '10.20.11.10'
name: 'TENANT'
interfaces:
- name: 'EXTERNAL'
diff --git a/deploy/post/execute.py b/deploy/post/execute.py index e4dec244..d54b2df5 100644 --- a/deploy/post/execute.py +++ b/deploy/post/execute.py @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## import neutron +import nova def _config_admin_external_network(): @@ -44,10 +45,23 @@ def _config_admin_external_subnet(nid): } +def _create_flavor_m1_micro(): + name = 'm1.micro' + novaclient = nova.Nova() + if not novaclient.get_flavor_by_name(name): + try: + return novaclient.create_flavor(name, ram=64, vcpus=1, disk=0) + except Exception as error: + print ('_create_flavor_m1_micro failed: {}'.format(str(error))) + else: + print ('Use existing m1.micro flavor') + + def main(): neutronclient = neutron.Neutron() nid = neutronclient.create_network(*(_config_admin_external_network())) neutronclient.create_subnet(_config_admin_external_subnet(nid)) + _create_flavor_m1_micro() if __name__ == '__main__': main() diff --git a/deploy/post/nova.py b/deploy/post/nova.py new file mode 100644 index 00000000..5c356a13 --- /dev/null +++ b/deploy/post/nova.py @@ -0,0 +1,25 @@ +import novaclient.client + +import keystoneauth + + +class Nova(keystoneauth.Keystoneauth): + def __init__(self, version='2', openrc=None): + super(Nova, self).__init__(openrc) + self.client = novaclient.client.Client(version, session=self.session) + self.flavors = self.client.flavors + + def create_flavor(self, name, ram, vcpus, disk, is_public=True): + flavor = self.flavors.create(name, ram, vcpus, disk, + is_public=is_public) + return flavor.id + + def get_flavor_by_name(self, name): + for flavor in self.list_flavors(): + if flavor.name == name: + return flavor.id + + return None + + def list_flavors(self): + return self.flavors.list(detailed=True) diff --git a/deploy/prepare.sh b/deploy/prepare.sh new file mode 100644 index 00000000..58d5a08f --- /dev/null +++ b/deploy/prepare.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +SCRIPT_PATH=$(readlink -f $(dirname $0)) + +export PYTHONPATH=$SCRIPT_PATH/.. + +usage () +{ +cat << EOF +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +`basename $0`: make preparation for daisy deployment + +usage: `basename $0` -n network_config_file + +OPTIONS: + -nw network configuration path, necessary + -h Print this message and exit + +Description: + prepare configuration + +Examples: +sudo `basename $0` -n /home/daisy/config/vm_environment/zte-virtual1/network.yml +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +EOF +} + +NETWORK_CONF='' + +while getopts "n:h" OPTION +do + case $OPTION in + n) + NETWORK_CONF=${OPTARG} + ;; + h) + usage + exit 0 + ;; + *) + echo "${OPTION} is not a valid argument" + usage + exit 0 + ;; + esac +done + +python $PYTHONPATH/deploy/prepare/execute.py -nw $NETWORK_CONF diff --git a/deploy/prepare/__init__.py b/deploy/prepare/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/deploy/prepare/__init__.py diff --git a/deploy/prepare/execute.py b/deploy/prepare/execute.py new file mode 100644 index 00000000..a50d9d9a --- /dev/null +++ b/deploy/prepare/execute.py @@ -0,0 +1,32 @@ +import argparse +import os + +from deploy.config.network import NetworkConfig + +NOVA_CONF_PATH = '/etc/kolla/config/nova' +NOVA_API_CONF = '{}/nova-api.conf'.format(NOVA_CONF_PATH) + + +def _config_nova_api(network_file): + xnet = NetworkConfig(network_file=network_file).external_network + if not os.path.isdir(NOVA_CONF_PATH): + os.makedirs(NOVA_CONF_PATH, mode=0644) + + with open(NOVA_API_CONF, 'w') as f: + f.write('[DEFAULT]\n' + 'default_floating_pool={}\n'.format(xnet['network_name'])) + f.close() + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('-nw', '--network-file', + type=str, + required=True, + help='network configuration file') + args = parser.parse_args() + _config_nova_api(args.network_file) + + +if __name__ == '__main__': + main() diff --git a/deploy/tempest.py b/deploy/tempest.py index 2b72cbc2..f01aa77b 100644 --- a/deploy/tempest.py +++ b/deploy/tempest.py @@ -87,7 +87,9 @@ def prepare_install(): add_hosts_interface(cluster_id, hosts_info, hosts_name, host_interface_map, vip) if 'env' in conf and conf['env'] == 0: - build_pxe_for_os(cluster_id) + build_pxe_without_ipmi(cluster_id) + else: + build_pxe_with_ipmi(cluster_id) except Exception: print("Deploy failed!!!.%s." % traceback.format_exc()) else: @@ -100,12 +102,18 @@ def build_pxe_for_discover(cluster_id): client.install.install(**cluster_meta) -def build_pxe_for_os(cluster_id): +def build_pxe_without_ipmi(cluster_id): cluster_meta = {'cluster_id': cluster_id, 'pxe_only': "true"} client.install.install(**cluster_meta) +def build_pxe_with_ipmi(cluster_id): + cluster_meta = {'cluster_id': cluster_id, + 'pxe_only': "false"} + client.install.install(**cluster_meta) + + def discover_host(hosts_name): while True: hosts_info = get_hosts() |