From 732e852130ed04e3118a876019d26fb030b47a98 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Tue, 14 Oct 2014 14:11:24 +0100 Subject: [PATCH] updates galore * update the icehouse heat templates to counter for all icehouse issues with no index and no name attribute * heat template to get torque to work * scripts to make sure that the demo user is able to spawn heat stacks * change come config files sot that some of the things work using crudini and sed Signed-off-by: Arif Ali --- heat_templates/icehouse/compute_node.yaml | 28 +++++++---- heat_templates/icehouse/hpc.yaml | 61 +++++++++++++---------- heat_templates/juno/compute_node.yaml | 4 +- heat_templates/juno/hpc.yaml | 14 +++--- scripts/gre-packstack.sh | 29 +++++++++-- scripts/vxlan-packstack.sh | 58 ++++++++++++++++++--- 6 files changed, 139 insertions(+), 55 deletions(-) diff --git a/heat_templates/icehouse/compute_node.yaml b/heat_templates/icehouse/compute_node.yaml index 149e0b6..69db7bf 100644 --- a/heat_templates/icehouse/compute_node.yaml +++ b/heat_templates/icehouse/compute_node.yaml @@ -6,6 +6,9 @@ description: > public network. parameters: + host_prefix: + type: string + description: The hostname will be prefixed by this string key_name: type: string description: Name of keypair to assign to servers @@ -54,7 +57,8 @@ resources: compute_node: type: OS::Nova::Server properties: - name: compute + name: + get_param: host_prefix image: get_param: image flavor: @@ -86,17 +90,24 @@ resources: echo $MASTER_NODE_IP > /var/spool/torque/server_name cat > /var/spool/torque/mom_priv/config << EOF - $logevent 0x1ff + \$logevent 0x1ff - $pbsserver $MASTER_NODE_IP + \$pbsserver $MASTER_NODE_IP EOF - service trquathd start - service pbs_mom start - myip=$(ip addr show eth0 | awk '$1 == "inet" {print $2}' | cut -f1 -d/) myip_last_octet=${myip##*.} + hostname $HOST_PREFIX${myip_last_octet} + + echo $myip $HOST_PREFIX${myip_last_octet} >> /etc/hosts + + service trquathd restart + service pbs_mom restart + + groupadd -g 4001 testuser + useradd -g 4001 -u 4001 -m testuser + cat > /tmp/wait-data << EOF { "Status" : "SUCCESS", @@ -111,6 +122,8 @@ resources: get_param: master_node_ip "$WAIT_HANDLE": get_resource: node_wait_handle + "$HOST_PREFIX": + get_param: host_prefix networks: - port: get_resource: compute_node_eth0 @@ -144,6 +157,3 @@ outputs: compute_node_external_ip: description: Floating IP address of compute node in public network value: { get_attr: [ compute_floating_ip, floating_ip_address ] } - compute_node_show: - description: Show all attributes - value: { get_attr: [ compute_node, show ] } diff --git a/heat_templates/icehouse/hpc.yaml b/heat_templates/icehouse/hpc.yaml index 202ef7e..5fef9a7 100644 --- a/heat_templates/icehouse/hpc.yaml +++ b/heat_templates/icehouse/hpc.yaml @@ -26,6 +26,11 @@ parameters: default: centos7 description: glance image used to boot the server + host_prefix: + type: string + default: compute + description: The prefix of the hostname of the compute node + flavor: type: string default: m1.small @@ -115,6 +120,9 @@ resources: - protocol: tcp port_range_min: 4001 port_range_max: 4001 + - protocol: tcp + port_range_min: 15000 + port_range_max: 15004 ###################################################################### # @@ -139,7 +147,7 @@ resources: user_data: str_replace: template: | - #!/bin/sh + #!/bin/bash yum -y upgrade @@ -158,43 +166,42 @@ resources: chkconfig pbs_sched on myip=$(ip addr show eth0 | awk '$1 == "inet" {print $2}' | cut -f1 -d/) + myip_last_octet=${myip##*.} + echo $myip `hostname` >> /etc/hosts mkdir -p /var/spool/torque/server_priv echo $myip > /var/spool/torque/server_name rm -rf /var/spool/torque/server_priv/nodes mkdir -p /var/spool/torque/checkpoint - echo ${COMP_NODE_ADDRESSES} - echo ${COMP_NODE_NAMES} - - array1=(${COMP_NODE_ADDRESSES// / }) - array2=(${COMP_NODE_NAMES// / }) - - length=${#array1[@]} - - for ((i=0;i<=$length;i++)); do - echo -e "${array1[$i]} ${array2[$i]}" - done >> /etc/hosts - - echo $myip `hostname` >> /etc/hosts - pbs_server -t create -f - - for node in $(echo ${COMP_NODE_NAMES}) - do - echo $node >> /var/spool/torque/server_priv/nodes - done - service trqauthd restart service pbs_server restart service pbs_sched restart + IFS="," read -a array1 <<< "$COMP_NODE_ADDRESSES" + IFS="," read -a array2 <<< "$COMP_NODE_NAMES" + + length=${#array1[@]} + + for ((i=0;i<$length;i++)); do + comp_ip=${array1[$i]} + comp_ip_last_octet=${comp_ip##*.} + comp_name=$HOST_PREFIX${comp_ip_last_octet} + echo -e "$comp_ip $comp_name" >> /etc/hosts + qmgr -c "c n $comp_name" + pbsnodes -c $comp_name + done + qmgr -c "c q testq" qmgr -c "s q testq queue_type=e" qmgr -c "s q testq enabled=t" qmgr -c "s q testq started=t" qmgr -c "s s scheduling=true" + groupadd -g 4001 testuser + useradd -g 4001 -u 4001 -m testuser + cat > /tmp/wait-data << EOF { "Status" : "SUCCESS", @@ -207,10 +214,14 @@ resources: params: # NB: For this to work you need a version of Heat that # includes https://review.openstack.org/#/c/121139/ - "$COMP_NODE_ADDRESSES": { "Fn::Join": [ " ", { get_attr: [compute_nodes, compute_node_ip] } ] } - "$COMP_NODE_NAMES": { "Fn::Join": [ " " , { get_attr: [compute_nodes, compute_node_name] } ] } + "$COMP_NODE_ADDRESSES": + "Fn::Join": [ ",", { get_attr: [compute_nodes, compute_node_ip] } ] + "$COMP_NODE_NAMES": + "Fn::Join": [ "," , { get_attr: [compute_nodes, compute_node_name] } ] "$WAIT_HANDLE": get_resource: master_wait_handle + "$HOST_PREFIX": + get_param: host_prefix master_node_eth0: type: "OS::Neutron::Port" @@ -243,6 +254,7 @@ resources: resource_def: type: compute_node.yaml properties: + host_prefix: {get_param: host_prefix} key_name: {get_param: key_name} image: {get_param: image} flavor: {get_param: flavor} @@ -264,6 +276,3 @@ outputs: compute_node_external: value: {get_attr: [compute_nodes, compute_node_external_ip]} - - compute_node_show: - value: {get_attr: [compute_nodes, compute_node_show]} diff --git a/heat_templates/juno/compute_node.yaml b/heat_templates/juno/compute_node.yaml index fdee50f..25ce958 100644 --- a/heat_templates/juno/compute_node.yaml +++ b/heat_templates/juno/compute_node.yaml @@ -1,7 +1,7 @@ heat_template_version: 2014-10-16 description: > - HOT template to deploy one compute node into an xisting neutron tenant network and + HOT template to deploy one compute node into an existing neutron tenant network and assign floating IP address to the server so they are routable from the public network. @@ -75,7 +75,7 @@ resources: cat > /etc/yum.repos.d/torque.repo << EOF [torque] name=torque - baseurl=http://192.168.33.200/install/post/otherpkgs/el7/torque + baseurl=http://192.168.95.200/install/post/otherpkgs/el7/torque enabled=1 gpgcheck=0 EOF diff --git a/heat_templates/juno/hpc.yaml b/heat_templates/juno/hpc.yaml index 0c5335b..6a943b7 100644 --- a/heat_templates/juno/hpc.yaml +++ b/heat_templates/juno/hpc.yaml @@ -1,9 +1,9 @@ heat_template_version: 2014-10-16 description: > - This template will boot a Kubernetes cluster with one or more - minions (as specified by the number_of_minions parameter, which - defaults to "2"). + This template will boot a HPC cluster with one or more compute + nodes (as specified by the number_of_compute_nodes parameter, which + defaults to "10"). parameters: @@ -142,7 +142,7 @@ resources: cat > /etc/yum.repos.d/torque.repo << EOF [torque] name=torque - baseurl=http://192.168.33.200/install/post/otherpkgs/el7/torque + baseurl=http://192.168.95.200/install/post/otherpkgs/el7/torque enabled=1 gpgcheck=0 EOF @@ -192,8 +192,10 @@ resources: EOF curl -T /tmp/wait-data '$WAIT_HANDLE' params: - "$COMP_NODE_ADDRESSES": {list_join: [" ", {get_attr: [compute_nodes, compute_node_ip]}]} - "$COMP_NODE_NAMES": {list_join: [" ", {get_attr: [compute_nodes, name]}]} + "$COMP_NODE_ADDRESSES": + list_join: [" ", {get_attr: [compute_nodes, compute_node_ip]}] + "$COMP_NODE_NAMES": + list_join: [" ", {get_attr: [compute_nodes, name]}] "$WAIT_HANDLE": get_resource: master_wait_handle networks: diff --git a/scripts/gre-packstack.sh b/scripts/gre-packstack.sh index 06468f5..4d8d7ea 100644 --- a/scripts/gre-packstack.sh +++ b/scripts/gre-packstack.sh @@ -1,14 +1,18 @@ #!/bin/bash +PRIMARY_PUBIP=192.168.95.1 +PRIMARY_PRIVIP=10.0.0.1 +NTP_SERVER=10.0.0.251 + packstack --gen-answer-file /root/packstack_answers.txt cat > /tmp/sed.script << EOF s/\(CONFIG_KEYSTONE_ADMIN_PW=\).*/\1openstack/g s/\(CONFIG_HEAT_INSTALL=\).*/\1y/g -s/\(CONFIG_NTP_SERVERS=\).*/\110.0.0.251/g +s/\(CONFIG_NTP_SERVERS=\).*/\1${NTP_SERVER}/g s/\(CONFIG_HEAT_CFN_INSTALL=\).*/\1y/g -s/\(CONFIG_COMPUTE_HOSTS=\).*/\110.0.0.1,10.0.0.2,10.0.0.3/g +s/\(CONFIG_COMPUTE_HOSTS=\).*/\110.0.0.4,10.0.0.5,10.0.0.6,10.0.0.7,10.0.0.8,10.0.0.9/g s/\(CONFIG_USE_EPEL=\).*/\1n/g s/\(CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=\).*/\1physnet_ex:br-ex/g @@ -26,12 +30,21 @@ sed -i -f /tmp/sed.script /root/packstack_answers.txt packstack --answer-file /root/packstack_answers.txt +cat > /tmp/sed.script << EOF +s/^\(heat_metadata_server_url=\).*/\1http:\/\/${PRIMARY_PUBIP}:8000/g +s/^\(heat_waitcondition_server_url=\).*/\1http:\/\/${PRIMARY_PUBIP}:8000\/v1\/waitcondition/g +EOF + +sed -i -f /tmp/sed.script /etc/heat/heat.conf + +openstack-service restart + . /root/keystonerc_admin neutron net-create ext_net --provider:network_type=flat --provider:physical_network=physnet_ex --router:external=True neutron subnet-create --name ext_subnet --disable-dhcp ext_net 192.168.80.0/20 \ --gateway 192.168.95.254 --allocation-pool start=192.168.81.1,end=192.168.94.255 -wget --no-check-certificate https://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img +wget http://${PRIMARY_PRIVIP}/install/data/openstack/images/cirros-0.3.3-x86_64-disk.img glance image-create --name cirros --is-public=True --disk-format=qcow2 \ --container-format=bare --disk-format=qcow2 --file /root/cirros-0.3.3-x86_64-disk.img @@ -44,13 +57,19 @@ neutron net-create stack_net_priv --provider:network_type=gre --tenant-id ${demo keystone user-create --name demo --pass demo keystone user-role-add --user demo --role _member_ --tenant demo keystone user-role-add --user demo --role heat_stack_owner --tenant demo -keystone user-role-add --user demo --role heat_stack_user --tenant demo + +tenant=$(keystone tenant-list | awk '/demo/ {print $2}') + +nova quota-update --instances 500 --cores 500 $tenant +neutron quota-update --floatingip 500 --security-group 500 --security-group-rule 500 --port 500 --router 50 --subnet 50 --net 50 --tenant-id=$tenant + +nova flavor-create hpc_node auto 2048 10 1 cat > /root/keystonerc_demo << EOF export OS_USERNAME=demo export OS_TENANT_NAME=demo export OS_PASSWORD=demo -export OS_AUTH_URL=http://10.0.0.1:5000/v2.0/ +export OS_AUTH_URL=http://${PRIMARY_PRIVIP}:5000/v2.0/ export PS1='[\u@\h \W(keystone_demo)]\$ ' EOF diff --git a/scripts/vxlan-packstack.sh b/scripts/vxlan-packstack.sh index 49cbb3e..afb86e9 100644 --- a/scripts/vxlan-packstack.sh +++ b/scripts/vxlan-packstack.sh @@ -1,18 +1,23 @@ #!/bin/bash +PRIMARY_PUBIP=192.168.95.1 +PRIMARY_PRIVIP=10.0.0.1 +MASTER=10.0.0.251 +NTP_SERVER=${MASTER} + packstack --gen-answer-file /root/packstack_answers.txt cat > /tmp/sed.script << EOF s/\(CONFIG_KEYSTONE_ADMIN_PW=\).*/\1openstack/g s/\(CONFIG_HEAT_INSTALL=\).*/\1y/g -s/\(CONFIG_NTP_SERVERS=\).*/\110.0.0.251/g +s/\(CONFIG_NTP_SERVERS=\).*/\1${NTP_SERVER}/g s/\(CONFIG_HEAT_CFN_INSTALL=\).*/\1y/g -s/\(CONFIG_COMPUTE_HOSTS=\).*/\110.0.0.1,10.0.0.2,10.0.0.3/g +s/\(CONFIG_COMPUTE_HOSTS=\).*/\110.0.0.4,10.0.0.5,10.0.0.6,10.0.0.7,10.0.0.8,10.0.0.9/g s/\(CONFIG_USE_EPEL=\).*/\1n/g -s/\(CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=\).*/\1physnet_ex:br-ex,physnet_mgmt:br-mgmt/g -s/\(CONFIG_NEUTRON_OVS_BRIDGE_IFACES=\).*/\1br-ex:enp2s1f1,br-mgmt:enp2s1f0/g +s/\(CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=\).*/\1physnet_mgmt:br-mgmt/g +s/\(CONFIG_NEUTRON_OVS_BRIDGE_IFACES=\).*/\1br-mgmt:enp2s1f0/g s/\(CONFIG_PROVISION_DEMO=\).*/\1n/g EOF @@ -20,12 +25,45 @@ sed -i -f /tmp/sed.script /root/packstack_answers.txt packstack --answer-file /root/packstack_answers.txt +crudini --set --existing /etc/heat/heat.conf DEFAULT heat_metadata_server_url http://${PRIMARY_PUBIP}:8000 +crudini --set --existing /etc/heat/heat.conf DEFAULT heat_waitcondition_server_url http://${PRIMARY_PUBIP}:8000/v1/waitcondition + +sed -i -e '/^osapi_compute_extension/d' /etc/nova/nova.conf +crudini --set /etc/nova/nova.conf DEFAULT osapi_compute_ext_list nova.api.openstack.compute.contrib.select_extensions +crudini --set /etc/nova/nova.conf DEFAULT osapi_compute_extension nova.api.openstack.compute.contrib.standard_extensions +sed -i -e 's/^\(osapi_compute_extension.*\)/\1\nosapi_compute_extension = nova.api.openstack.compute.contrib.extended_server_attributes/g' /etc/nova/nova.conf + +openstack-service restart + +# +# Begin -- Do this on xCAT MN +# +cat > /tmp/sed.script << EOF +/^osapi_compute_extension/d +EOF +xdcp nova /tmp/sed.script /tmp/ +xdsh nova sed -i -f /tmp/sed.script /etc/nova/nova.conf + +xdsh nova crudini --set /etc/nova/nova.conf DEFAULT osapi_compute_ext_list nova.api.openstack.compute.contrib.select_extensions +xdsh nova crudini --set /etc/nova/nova.conf DEFAULT osapi_compute_extension nova.api.openstack.compute.contrib.standard_extensions + +cat > /tmp/sed.script << EOF +s/^\(osapi_compute_extension.*\)/\1\nosapi_compute_extension = nova.api.openstack.compute.contrib.extended_server_attributes/g +EOF +xdcp nova /tmp/sed.script /tmp/ +xdsh nova sed -i -f /tmp/sed.script /etc/nova/nova.conf + +xdsh nova openstack-service restart +# +# End -- Do this on xCAT MN +# + . /root/keystonerc_admin neutron net-create ext_net --router:external=True neutron subnet-create --name ext_subnet --disable-dhcp ext_net 192.168.80.0/20 \ --gateway 192.168.95.254 --allocation-pool start=192.168.81.1,end=192.168.94.255 -wget --no-check-certificate https://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img +wget http://${MASTER}/install/data/openstack/images/cirros-0.3.3-x86_64-disk.img glance image-create --name cirros --is-public=True --disk-format=qcow2 \ --container-format=bare --disk-format=qcow2 --file /root/cirros-0.3.3-x86_64-disk.img @@ -34,13 +72,19 @@ keystone tenant-create --name demo keystone user-create --name demo --pass demo keystone user-role-add --user demo --role _member_ --tenant demo keystone user-role-add --user demo --role heat_stack_owner --tenant demo -keystone user-role-add --user demo --role heat_stack_user --tenant demo + +tenant=$(keystone tenant-list | awk '/demo/ {print $2}') + +nova quota-update --instances 500 --cores 500 $tenant +neutron quota-update --floatingip 500 --security-group 500 --security-group-rule 500 --port 500 --router 50 --subnet 50 --net 50 --tenant-id=$tenant + +nova flavor-create hpc_node auto 2048 10 1 cat > /root/keystonerc_demo << EOF export OS_USERNAME=demo export OS_TENANT_NAME=demo export OS_PASSWORD=demo -export OS_AUTH_URL=http://10.0.0.1:5000/v2.0/ +export OS_AUTH_URL=http://${PRIMARY_PRIVIP}:5000/v2.0/ export PS1='[\u@\h \W(keystone_demo)]\$ ' EOF