From c563f6aeb451d7725f723c359c1c6d7d257b3419 Mon Sep 17 00:00:00 2001 From: venkatamahesh Date: Wed, 7 Dec 2016 19:26:47 +0530 Subject: [PATCH] Use OpenStack CLI instead of individual CLI Co-Authored-By: gong yong sheng Co-Authored-By: venkatamahesh Change-Id: Ie4a41b6b5350555b5ebb57fb7b44ebcd89fab2a5 Closes-Bug: #1648086 --- devstack/lib/tacker | 32 ++++++++++++------- ...hanced_placement_awareness_usage_guide.rst | 6 ++-- doc/source/install/deploy_openwrt.rst | 20 ++---------- tacker/tests/contrib/post_test_hook_lib.sh | 18 +++++------ 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/devstack/lib/tacker b/devstack/lib/tacker index 4458c4e53..6ab24fc08 100644 --- a/devstack/lib/tacker +++ b/devstack/lib/tacker @@ -321,7 +321,7 @@ function tacker_check_and_download_cirros { local image_url image_fname image_url=http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img cirros_fname=`basename "$image_url"` - image_name=`glance image-list | grep "${cirros_fname%.*}" | awk '{print $4}'` + image_name=`openstack image list | grep "${cirros_fname%.*}" | awk '{print $4}'` if [[ $image_name == "" ]]; then if [[ ! -f $FILES/$image_fname || "$(stat -c "%s" $FILES/$image_fname)" = "0" ]]; then { @@ -338,7 +338,7 @@ function openstack_image_create { container_format=bare image_name=$2 openstack --os-cloud=devstack-admin image create $image_name --public --container-format=$container_format --disk-format $disk_format < <(zcat --force "${image}") - glance image-list | grep OpenWRT | awk {print$2} + openstack image show OpenWRT -f value -c id } function tacker_create_openwrt_image { @@ -365,19 +365,19 @@ function tacker_create_initial_network { echo "Deleting networks" for net in ${NET_MGMT} ${NET0} ${NET1} do - for i in $(neutron net-list | awk "/${net}/{print \$2}") + for i in $(openstack network list | awk "/${net}/{print \$2}") do - neutron net-delete $i + openstack network delete $i done done echo "Creating networks" - NET_MGMT_ID=$(neutron net-create --provider:network_type flat --provider:physical_network ${MGMT_PHYS_NET} --shared ${NET_MGMT} | awk '/ id /{print $4}') - SUBNET_MGMT_ID=$(neutron subnet-create --name ${SUBNET_MGMT} --ip-version 4 --gateway ${NETWORK_GATEWAY_MGMT} ${NET_MGMT_ID} ${FIXED_RANGE_MGMT} | awk '/ id /{print $4}') - NET0_ID=$(neutron net-create --shared ${NET0} | awk '/ id /{print $4}') - SUBNET0_ID=$(neutron subnet-create --name ${SUBNET0} --ip-version 4 --gateway ${NETWORK_GATEWAY0} ${NET0_ID} ${FIXED_RANGE0} | awk '/ id /{print $4}') - NET1_ID=$(neutron net-create --shared ${NET1} | awk '/ id /{print $4}') - SUBNET1_ID=$(neutron subnet-create --name ${SUBNET1} --ip-version 4 --gateway ${NETWORK_GATEWAY1} ${NET1_ID} ${FIXED_RANGE1} | awk '/ id /{print $4}') + NET_MGMT_ID=$(openstack network create --provider-network-type flat --provider-physical-network ${MGMT_PHYS_NET} --share ${NET_MGMT} | awk '/ id /{print $4}') + SUBNET_MGMT_ID=$(openstack subnet create ${SUBNET_MGMT} --ip-version 4 --gateway ${NETWORK_GATEWAY_MGMT} --network ${NET_MGMT_ID} --subnet-range ${FIXED_RANGE_MGMT} | awk '/ id /{print $4}') + NET0_ID=$(openstack network create --share ${NET0} | awk '/ id /{print $4}') + SUBNET0_ID=$(openstack subnet create ${SUBNET0} --ip-version 4 --gateway ${NETWORK_GATEWAY0} --network ${NET0_ID} --subnet-range ${FIXED_RANGE0} | awk '/ id /{print $4}') + NET1_ID=$(openstack network create --share ${NET1} | awk '/ id /{print $4}') + SUBNET1_ID=$(openstack subnet create ${SUBNET1} --ip-version 4 --gateway ${NETWORK_GATEWAY1} --network ${NET1_ID} --subnet-range ${FIXED_RANGE1} | awk '/ id /{print $4}') echo "Assign ip address to BR_MGMT" sudo ifconfig ${BR_MGMT} inet 0.0.0.0 @@ -385,20 +385,28 @@ function tacker_create_initial_network { } function tacker_register_default_vim { - local default_vim_id + # Note: These must be the same as in tacker/tests/etc/samples/local-vim.yaml + # and devstack/lib/tacker/vim_config.yaml DEFAULT_VIM_PROJECT_NAME="nfv" DEFAULT_VIM_USER="nfv_user" DEFAULT_VIM_PASSWORD="devstack" - DEFAULT_VIM_NAME="VIM0" + + echo "Create NFV VIM project $DEFAULT_VIM_PROJECT_NAME ..." get_or_create_project $DEFAULT_VIM_PROJECT_NAME + echo "Create NFV VIM user $DEFAULT_VIM_USER ..." get_or_create_user $DEFAULT_VIM_USER $DEFAULT_VIM_PASSWORD get_or_add_user_project_role "admin" $DEFAULT_VIM_USER $DEFAULT_VIM_PROJECT_NAME get_or_add_user_project_role "advsvc" $DEFAULT_VIM_USER $DEFAULT_VIM_PROJECT_NAME + echo "Register default VIM ..." mkdir -p $DATA_DIR/tacker cp $TACKER_DIR/devstack/vim_config.yaml $DATA_DIR/tacker VIM_CONFIG_FILE="$DATA_DIR/tacker/vim_config.yaml" sed -e "s|^auth_url:.*$|auth_url: \'${KEYSTONE_SERVICE_URI}\'|" -i $VIM_CONFIG_FILE + echo "The content of VIM config file $VIM_CONFIG_FILE :" + cat $VIM_CONFIG_FILE + local default_vim_id + DEFAULT_VIM_NAME="VIM0" default_vim_id=$(tacker vim-register --is-default --description "Default VIM" --config-file $VIM_CONFIG_FILE $DEFAULT_VIM_NAME -c id | grep id | awk '{print $4}') echo "Default VIM registration done as $default_vim_id at $KEYSTONE_SERVICE_URI." } diff --git a/doc/source/devref/enhanced_placement_awareness_usage_guide.rst b/doc/source/devref/enhanced_placement_awareness_usage_guide.rst index 9a01f2a9a..8e08c896c 100644 --- a/doc/source/devref/enhanced_placement_awareness_usage_guide.rst +++ b/doc/source/devref/enhanced_placement_awareness_usage_guide.rst @@ -112,11 +112,11 @@ availability zone and adding compute nodes. .. code-block:: console - nova aggregate-create NFV-AGG NFV-AZ + openstack aggregate create --zone NFV-AZ NFV-AGG - nova aggregate-add-host NFV-AGG + openstack aggregate add host NFV-AGG - nova aggregate-add-host NFV-AGG + openstack aggregate add host NFV-AGG **NOTE**: Consult http://docs.openstack.org/cli-reference/nova.html for latest supported commands. diff --git a/doc/source/install/deploy_openwrt.rst b/doc/source/install/deploy_openwrt.rst index ba07cee27..ca671816d 100644 --- a/doc/source/install/deploy_openwrt.rst +++ b/doc/source/install/deploy_openwrt.rst @@ -23,32 +23,18 @@ started with deploying OpenWRT as VNF. 1. Ensure Glance already contains OpenWRT image. Normally, Tacker tries to add OpenWRT image to Glance while installing via devstack. By running -**glance image-list** to check OpenWRT image if exists. If not, download +**openstack image list** to check OpenWRT image if exists. If not, download the image from `OpenWRT official site `_. -And upload this image into Glance by using either of the commands below: - -Using glance cli: - -.. code-block:: console - - glance image-create --name OpenWRT \ - --disk-format qcow2 \ - --container-format bare \ - --progress \ - --file /path_to_image/openwrt-x86-kvm_guest-combined-ext4.img \ - --visibility public -.. - -OR, using OpenStack cli: +And upload this image into Glance by using the command specified below: .. code-block:: console openstack image create OpenWRT --disk-format qcow2 \ --container-format bare \ --file /path_to_image/openwrt-x86-kvm_guest-combined-ext4.img \ - --visibility public + --public .. 2. Create a yaml template named tosca-vnfd-openwrt-with-firewall-rules.yaml diff --git a/tacker/tests/contrib/post_test_hook_lib.sh b/tacker/tests/contrib/post_test_hook_lib.sh index 442dae6ab..9b510908b 100644 --- a/tacker/tests/contrib/post_test_hook_lib.sh +++ b/tacker/tests/contrib/post_test_hook_lib.sh @@ -16,30 +16,28 @@ PRIVATE_KEY_FILE=${PRIVATE_KEY_FILE:-"keypair.priv"} function fixup_quota { echo "Disable nova compute instance & core quota" - nova quota-class-update --instances -1 --cores -1 --ram -1 default + openstack quota set --class --instances -1 --cores -1 --ram -1 default projectId=$(openstack project list | awk '/\ nfv\ / {print $2}') echo "Disable neutron port quota on project 'nfv' $projectId" - neutron quota-update --tenant-id $projectId --port -1 + openstack quota set --ports -1 $projectId } -# Adding nova keypair if not exist to support key_name (#1578785). function add_key_if_not_exist { echo "Adding nova key if not exist" - userId=$(openstack user list | awk '/\ nfv_user\ / {print $2}') - nova keypair-show userKey --user $userId >/dev/null + openstack keypair show userKey >/dev/null if [[ "$?" != "0" ]]; then - nova keypair-add userKey --user $userId > ${PRIVATE_KEY_FILE} + add_key else echo "Keypair userKey already exists" fi } -# Adding nova keypair to support key_name (#1578785). -# used by OpenStack CI since it will fail if $? is not 0 function add_key { echo "Adding nova key" userId=$(openstack user list | awk '/\ nfv_user\ / {print $2}') + # TODO: openstack cli does not support to add key to a specific user nova keypair-add userKey --user $userId > ${PRIVATE_KEY_FILE} + echo "Keypair userKey is added" } # Adding nova security groups (#1591372). @@ -60,8 +58,7 @@ function add_secgrp_if_not_exist { echo "Adding nova security group" openstack security group show test_secgrp if [[ "$?" != "0" ]]; then - _create_secgrps - _check_secgrps + add_secgrp else echo "Nova security group already exists" fi @@ -72,4 +69,5 @@ function add_secgrp { echo "Adding nova security group" _create_secgrps _check_secgrps + echo "nova security group is added" }