diff options
Diffstat (limited to 'deploy')
-rwxr-xr-x | deploy/check_openstack_progress.sh | 33 | ||||
-rwxr-xr-x | deploy/check_os_progress.sh | 5 | ||||
-rw-r--r-- | deploy/post/execute.py | 14 | ||||
-rw-r--r-- | deploy/post/nova.py | 25 | ||||
-rw-r--r-- | deploy/tempest.py | 12 |
5 files changed, 81 insertions, 8 deletions
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/post/execute.py b/deploy/post/execute.py index d5a0727b..9e029b11 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/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() |