diff --git a/endpoints/base b/endpoints/base index 21a4c062..9400e3c3 100755 --- a/endpoints/base +++ b/endpoints/base @@ -52,6 +52,20 @@ declare -A numaNode numaNode[default]=-1 profiler_count=0 +function get_var() { + local ref1; typeset -n ref1=$1; shift # The associative array that you need a var from + local engine_label=$1; shift # ex: client-1, server-2 + local ref2; typeset -n ref2=$1; shift # What var to store the val in + + set +u + if [ ! -z "${ref1[$engine_label]}" ]; then + ref2=${ref1[$engine_label]} + elif [ ! -z "${ref1[default]}" ]; then + ref2=${ref1[default]} + fi + set -u +} + function store_var() { # stores a value (or content of file named in $value) into 1 or more elements in an array # array name = second arg diff --git a/endpoints/osp/osp b/endpoints/osp/osp index df9f862c..8af8551c 100755 --- a/endpoints/osp/osp +++ b/endpoints/osp/osp @@ -30,17 +30,17 @@ instance_prefix="rickshaw" base_osruntime_bootstrap="$endpoint_base_dir/osruntime-bootstrap" vm_image="centos9" vm_user="root" -#network="management" -network="public" profiler_count=0 declare -A flavor declare -A availability_zone declare -A ips declare -A active_compute_nodes declare -A engine_hypervisor +declare -A networks osruntime[default]="podman" availability_zone[default]="nova" flavor[default]="m1.small" +networks[default]="management" function endpoint_osp_engine_init() { @@ -160,10 +160,10 @@ function process_osp_opts() { # flavor:default:ospdev # availability-zone:client-1-6+10-16:nova flavor) - store_vars $val flavor + store_var $val flavor ;; availability-zone) - store_vars $val availability_zone + store_var $val availability_zone ;; @@ -173,12 +173,16 @@ function process_osp_opts() { ospconfig) ospconfig=$val ;; - network) - network=$val - this_key=$(get_opt_field "${val}" "key") - this_value=$(get_opt_field "${val}" "value") - label=`echo $this_key | awk -F- '{print $1}'` - range=`echo $this_key | sed -e s/$label-//` + network|networks) + # networks:: + # scope= default + # client|server-a-b+c-d, where a/b/c/d = numbers + # ex: client-1-4+10-24 + # server-20-24+30-36+39-41 + # network-names= network1+network2[+networkN] + # ex: management+provider1+provider2 + # management+provider3+provider4+provider5 + store_var $val networks ;; client|server|clients|servers) addto_clients_servers "$arg" "$val" @@ -198,7 +202,7 @@ function process_osp_opts() { vm-user) vm_user=$val ;; - vm-image) + vm-image|vm-images) vm_image=$val ;; userenv) @@ -235,10 +239,10 @@ function create_servers() { do_ssh ${user}@${host} "mkdir -p $vm_ssh_key_dir" echo "checking for existence of ssh key" do_ssh ${user}@${host} "$osp_pre_cmd openstack keypair list --quote minimal -f csv | grep -v Name,Fingerprint" >${endpoint_run_dir}/openstack-keys.txt - existing_key=`cat ${endpoint_run_dir}/openstack-keys.txt | awk -F, '{print $1}' | grep -v \"Name\" | grep $vm_ssh_key_name` + existing_key=`cat ${endpoint_run_dir}/openstack-keys.txt | awk -F, '{print $1}' | grep -v \"Name\" | grep $vm_ssh_key_name` if [ "[$existing_key]" == "[$vm_ssh_key_name]" ]; then echo "deleting existing ssh key [$vm_ssh_key_name]" - do_ssh ${user}@${host} "$osp_pre_cmd openstack keypair delete $vm_ssh_key_name" + do_ssh ${user}@${host} "$osp_pre_cmd openstack keypair delete $vm_ssh_key_name" echo "remaining keypairs" do_ssh ${user}@${host} "$osp_pre_cmd openstack keypair list --quote minimal -f csv" fi @@ -251,24 +255,18 @@ function create_servers() { do_ssh ${user}@${host} "$osp_pre_cmd openstack image list -f value -c Name" >${endpoint_run_dir}/openstack-images.txt do_ssh ${user}@${host} "$osp_pre_cmd openstack network list -f value -c Name" >${endpoint_run_dir}/openstack-networks.txt - if grep -q $network ${endpoint_run_dir}/openstack-networks.txt; then - echo "Confirmed network [$network] is available" - else - abort_error "Network [$network] does not exist" endpoint-deploy-begin - fi - if [ "$clear_all_servers" == "1" ]; then # Clear all rickshaw servers, even from other run ids do_ssh ${user}@${host} "$osp_pre_cmd openstack server list -f value -c Name" >${endpoint_run_dir}/openstack-existing-servers.txt existing_servers=`cat ${endpoint_run_dir}/openstack-existing-servers.txt | grep rickshaw` if [ ! -z "$existing_servers" ]; then echo "deleting existing servers [$existing_servers]" - do_ssh ${user}@${host} "$osp_pre_cmd openstack server delete $existing_servers" + do_ssh ${user}@${host} "$osp_pre_cmd openstack server delete $existing_servers" fi do_ssh ${user}@${host} "$osp_pre_cmd openstack port list -f value -c Name" >${endpoint_run_dir}/openstack-existing-ports.txt existing_ports=`cat ${endpoint_run_dir}/openstack-existing-ports.txt | grep rickshaw` if [ ! -z "$existing_ports" ]; then echo "deleting existing ports [$existing_ports]" - do_ssh ${user}@${host} "$osp_pre_cmd openstack port delete $existing_ports" + do_ssh ${user}@${host} "$osp_pre_cmd openstack port delete $existing_ports" fi fi @@ -381,9 +379,17 @@ function create_server() { echo "images: $image_list" local vm_name="rickshaw-$run_id-$cs_label" - local mgmt_port_name="mgmt-$vm_name" local this_osruntime_bootstrap="$vm_name-osruntime-bootstrap" local this_availability_zone="" + get_var networks $cs_label these_networks + + for this_network in `echo $these_networks | sed -e 's/+/ /g'`; do + if grep -q $this_network ${endpoint_run_dir}/openstack-networks.txt; then + echo "Confirmed network [$this_network] is available" + else + abort_error "Network [$this_network] does not exist" endpoint-deploy-begin + fi + done set +u if [ ! -z "${availability_zone[$cs_label]}" ]; then @@ -416,17 +422,22 @@ function create_server() { existing_servers=`cat ${endpoint_run_dir}/openstack-existing-servers.txt | grep $vm_name` if [ ! -z "$existing_servers" ]; then echo "deleting existing server [$existing_servers]" - do_ssh ${user}@${host} "$osp_pre_cmd openstack server delete $existing_servers" + do_ssh ${user}@${host} "$osp_pre_cmd openstack server delete $existing_servers" fi existing_ports=`cat ${endpoint_run_dir}/openstack-existing-ports.txt | grep $vm_name` if [ ! -z "$existing_ports" ]; then echo "deleting existing ports [$existing_ports]" - do_ssh ${user}@${host} "$osp_pre_cmd openstack port delete $existing_ports" + do_ssh ${user}@${host} "$osp_pre_cmd openstack port delete $existing_ports" fi fi - echo "creating openstack mgmt port for server $vm_name" - do_ssh ${user}@${host} "$osp_pre_cmd openstack port create --network $network --no-security-group --disable-port-security $mgmt_port_name" + echo "creating openstack network port(s) for server $vm_name" + these_network_port_options="" + for this_network in `echo $these_networks | sed -e 's/+/ /g'`; do + this_network_port=$vm_name-$this_network + these_network_port_options+=" --nic port-id=$this_network_port" + do_ssh ${user}@${host} "$osp_pre_cmd openstack port create --network $this_network --no-security-group --disable-port-security $this_network_port" + done set_osruntime_numanode_cpupart $cs_label echo "cpu_partitioning: [$cpu_partitioning]" @@ -456,7 +467,7 @@ function create_server() { # Server is created with --user-data , and the server will run this script right after boot. echo "creating openstack server $vm_name" - server_create_cmd="$osp_pre_cmd openstack server create --flavor $this_flavor --nic port-id=$mgmt_port_name --image $vm_image --availability-zone $this_availability_zone --key-name $vm_ssh_key_name --user-data $this_osruntime_bootstrap --key-name $vm_ssh_key_name $vm_name" + server_create_cmd="$osp_pre_cmd openstack server create --flavor $this_flavor $these_network_port_options --image $vm_image --availability-zone $this_availability_zone --key-name $vm_ssh_key_name --user-data $this_osruntime_bootstrap $vm_name" echo "Going to run via ssh: $server_create_cmd" do_ssh ${user}@${host} $server_create_cmd >${endpoint_run_dir}/openstack-create-$vm_name.txt 2>&1 rc=$? @@ -468,9 +479,10 @@ function create_server() { # The following is necessary to get engine logs echo "getting openstack port information for $vm_name" - do_ssh ${user}@${host} "$osp_pre_cmd openstack port show $mgmt_port_name -f json" >${endpoint_run_dir}/openstack-port-$mgmt_port_name.json + first_network=`echo $these_networks | awk -F+ '{print $1}'` + do_ssh ${user}@${host} "$osp_pre_cmd openstack port show $first_network -f json" >${endpoint_run_dir}/openstack-port-$first_network.json echo "finding server IP" - this_server_ip=`jq -r .fixed_ips[0].ip_address ${endpoint_run_dir}/openstack-port-$mgmt_port_name.json` + this_server_ip=`jq -r .fixed_ips[0].ip_address ${endpoint_run_dir}/openstack-port-$first_network.json` echo "this_server_ip: [$this_server_ip]" do_ssh ${user}@${host} "$osp_pre_cmd ssh-keygen -R $this_server_ip" osp_servers+=" $cs_label" @@ -500,17 +512,22 @@ function create_server() { function cleanup_osruntime() { local this_cs_label local vm_names="" - local mgmt_port_names="" local this_osruntime_bootstrap + local these_networks + local this_network_port echo "Going to delete VMs for these clients and servers: ${clients[@]} ${servers[@]}" for this_cs_label in ${clients[@]} ${servers[@]}; do vm_names+=" rickshaw-$run_id-$this_cs_label" - mgmt_port_names+=" mgmt-rickshaw-$run_id-$this_cs_label" done echo "deletintg VM [$vm_names]" do_ssh ${user}@${host} "$osp_pre_cmd openstack server delete $vm_names" >${endpoint_run_dir}/openstack-server-delete-vms.txt - echo "deletintg network port [$mgmt_port_names]" - do_ssh ${user}@${host} "$osp_pre_cmd openstack port delete $mgmt_port_names" >${endpoint_run_dir}/openstack-port-delete-mgmt-ports.txt + echo "deleting openstack network port(s) for server $vm_name" + get_var networks $cs_label these_networks + for this_network in `echo $these_networks | sed -e 's/+/ /g'`; do + this_network_port=$vm_name-$this_network + echo "deletintg network port [$this_network]" + do_ssh ${user}@${host} "$osp_pre_cmd openstack port delete $this_network" + done echo "deletintg keypair [$vm_ssh_key_name]" do_ssh ${user}@${host} "$osp_pre_cmd openstack keypair delete $vm_ssh_key_name" >${endpoint_run_dir}/openstack-keypair-delete-$vm_ssh_key_name.txt echo "deletintg keyfile [$vm_ssh_key_name]"