summaryrefslogtreecommitdiffstats
path: root/foreman/ci
diff options
context:
space:
mode:
Diffstat (limited to 'foreman/ci')
-rw-r--r--foreman/ci/Vagrantfile4
-rwxr-xr-xforeman/ci/deploy.sh402
-rw-r--r--foreman/ci/opnfv_ksgen_settings.yml30
-rw-r--r--foreman/ci/opnfv_ksgen_settings_no_HA.yml16
-rwxr-xr-xforeman/ci/resize_lvm.sh37
-rwxr-xr-xforeman/ci/resize_partition.sh33
-rwxr-xr-xforeman/ci/vm_nodes_provision.sh11
7 files changed, 424 insertions, 109 deletions
diff --git a/foreman/ci/Vagrantfile b/foreman/ci/Vagrantfile
index 5550976..c7dfc03 100644
--- a/foreman/ci/Vagrantfile
+++ b/foreman/ci/Vagrantfile
@@ -80,10 +80,11 @@ Vagrant.configure(2) do |config|
# sudo apt-get update
# sudo apt-get install -y apache2
# SHELL
-
+
config.ssh.username = 'root'
config.ssh.password = 'vagrant'
config.ssh.insert_key = 'true'
+ config.vm.provision :shell, path: "resize_partition.sh"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "reload_playbook.yml"
end
@@ -97,4 +98,5 @@ Vagrant.configure(2) do |config|
config.vm.provision :shell, :inline => "systemctl stop dhcpd"
config.vm.provision :shell, :inline => "systemctl disable dhcpd"
end
+ config.vm.provision :shell, path: "resize_lvm.sh"
end
diff --git a/foreman/ci/deploy.sh b/foreman/ci/deploy.sh
index 29ad83c..6bf8f12 100755
--- a/foreman/ci/deploy.sh
+++ b/foreman/ci/deploy.sh
@@ -29,6 +29,8 @@ declare -A controllers_ip_arr
declare -A admin_ip_arr
declare -A public_ip_arr
+vagrant_box_dir=~/.vagrant.d/boxes/opnfv-VAGRANTSLASH-centos-7.0/1.0.0/virtualbox/
+vagrant_box_vmdk=box-disk1.vmdk
vm_dir=/var/opt/opnfv
script=`realpath $0`
##END VARS
@@ -53,6 +55,8 @@ Not applicable with -virtual. Example: -private_nic em2"
Can also be used with -virtual. Example: -public_nic em3"
echo -e "\n -storage_nic : Baremetal NIC for the storage network. Optional. Not applicable with -virtual. \
Private NIC will be used for storage if not specified. Example: -storage_nic em4"
+ echo -e "\n -single_baremetal_nic : Baremetal NIC for the all in one network. Optional. Not applicable with -virtual. \
+Example: -single_baremetal_nic em1"
}
##verify vm dir exists
@@ -298,6 +302,10 @@ parse_cmdline() {
shift 2
nic_arg_flag=1
;;
+ -single_baremetal_nic)
+ single_baremetal_nic=$2
+ shift 2
+ ;;
*)
display_usage
exit 1
@@ -326,6 +334,11 @@ parse_cmdline() {
##Validate nic args
if [[ $nic_arg_flag -eq 1 ]]; then
+ if [ ! -z "$single_baremetal_nic" ]; then
+ echo "${red}Please do not specify other nic types along with single_baremetal_nic!${reset}"
+ exit 1
+ fi
+
if [ -z "$virtual" ]; then
for nic_type in admin_nic private_nic public_nic; do
eval "nic_value=\$$nic_type"
@@ -341,7 +354,7 @@ parse_cmdline() {
done
else
##if virtual only public_nic should be specified
- for nic_type in admin_nic private_nic storage_nic; do
+ for nic_type in admin_nic private_nic storage_nic single_baremetal_nic; do
eval "nic_value=\$$nic_type"
if [ ! -z "$nic_value" ]; then
echo "${red}$nic_type is not a valid argument using -virtual. Please only specify public_nic!${reset}"
@@ -355,6 +368,12 @@ parse_cmdline() {
exit 1
fi
fi
+ elif [ ! -z "$single_baremetal_nic" ]; then
+ interface_ip=$(find_ip $single_baremetal_nic)
+ if [ ! "$interface_ip" ]; then
+ echo "${red}Single Baremetal NIC: $single_baremetal_nic does not have an IP address! Exiting... ${reset}"
+ exit 1
+ fi
fi
}
@@ -505,11 +524,14 @@ configure_network() {
fi
nic_array=( $nic_list )
output=$nic_list
+ elif [ ! -z "$single_baremetal_nic" ]; then
+ output=$single_baremetal_nic
else
echo "${blue}Detecting network configuration...${reset}"
##detect host 1 or 3 interface configuration
#output=`ip link show | grep -E "^[0-9]" | grep -Ev ": lo|tun|virbr|vboxnet" | awk '{print $2}' | sed 's/://'`
- output=`/bin/ls -l /sys/class/net | tail -n +2 | grep -v virtual | cut -d " " -f10`
+ #output=`/bin/ls -l /sys/class/net | tail -n +2 | grep -v virtual | cut -d " " -f10`
+ output=`/bin/ls -l /sys/class/net | tail -n +2 | grep -v virtual | awk {'print $9'}`
fi
if [ ! "$output" ]; then
@@ -570,62 +592,100 @@ configure_network() {
sed -i 's/^.*eth_replace2.*$/ config.vm.network "public_network", ip: '\""$new_ip"\"', bridge: '\'"$interface"\'', netmask: '\""$subnet_mask"\"'/' Vagrantfile
if_counter=1
else
- ##find number of interfaces with ip and substitute in VagrantFile
- if_counter=0
- for interface in ${output}; do
-
- if [ "$if_counter" -ge 4 ]; then
- break
- fi
- interface_ip=$(find_ip $interface)
+ if [ ! -z $single_baremetal_nic ]; then
+ interface_ip=$(find_ip $single_baremetal_nic)
if [ ! "$interface_ip" ]; then
- continue
+ echo "${red}Unable to determine IP address of $single_baremetal_nic. Exiting...${reset}"
+ exit 1
+ fi
+ subnet_mask=$(find_netmask $single_baremetal_nic)
+ public_subnet_mask=$subnet_mask
+ if ! verify_subnet_size $public_subnet_mask 50; then
+ echo "${red} Not enough IPs in subnet: $interface_ip $subnet_mask. Need at least 50 IPs. Please resize subnet! Exiting ${reset}"
+ exit 1
fi
+
new_ip=$(next_usable_ip $interface_ip)
if [ ! "$new_ip" ]; then
- continue
+ echo "${red}Unable to allocate new IP address: $interface_ip $subnet_mask Exiting...${reset}"
+ exit 1
fi
- interface_arr[$interface]=$if_counter
- interface_ip_arr[$if_counter]=$new_ip
- subnet_mask=$(find_netmask $interface)
- if [ "$if_counter" -eq 0 ]; then
- admin_subnet_mask=$subnet_mask
- if ! verify_subnet_size $admin_subnet_mask 5; then
- echo "${red} Not enough IPs in admin subnet: ${interface_ip_arr[$if_counter]} ${admin_subnet_mask}. Need at least 5 IPs. Please resize subnet! Exiting ${reset}"
- exit 1
- fi
- elif [ "$if_counter" -eq 1 ]; then
- private_subnet_mask=$subnet_mask
- private_short_subnet_mask=$(find_short_netmask $interface)
+ this_default_gw=$(ip route | grep default | awk '{print $3}')
+ echo "${blue}Default Gateway: $this_default_gw ${reset}"
+ this_default_gw_interface=$(ip route get $this_default_gw | awk '{print $3}')
+ if [ "$this_default_gw_interface" != "$single_baremetal_nic" ]; then
+ echo "${red}Error: Your default gateway interface: $this_default_gw_interface does not \
+match the baremetal nic you provided: ${single_baremetal_nic}. Exiting...${reset}"
+ exit 1
+ fi
+ sed -i 's/^.*eth_replace0.*$/ config.vm.network "public_network", ip: '\""$new_ip"\"', bridge: '\'"$single_baremetal_nic"\'', netmask: '\""$subnet_mask"\"'/' Vagrantfile
+ interface_ip_arr[0]=$new_ip
+ interface_arr[$single_baremetal_nic]=0
+ admin_ip=$new_ip
+ admin_subnet_mask=$subnet_mask
+ public_short_subnet_mask=$(find_short_netmask $single_baremetal_nic)
+ if_counter=1
+ else
+ ##find number of interfaces with ip and substitute in VagrantFile
+ if_counter=0
+ for interface in ${output}; do
- if ! verify_subnet_size $private_subnet_mask 15; then
- echo "${red} Not enough IPs in private subnet: ${interface_ip_arr[$if_counter]} ${private_subnet_mask}. Need at least 15 IPs. Please resize subnet! Exiting ${reset}"
- exit 1
+ if [ "$if_counter" -ge 4 ]; then
+ break
fi
- elif [ "$if_counter" -eq 2 ]; then
- public_subnet_mask=$subnet_mask
- public_short_subnet_mask=$(find_short_netmask $interface)
-
- if ! verify_subnet_size $public_subnet_mask 25; then
- echo "${red} Not enough IPs in public subnet: ${interface_ip_arr[$if_counter]} ${public_subnet_mask}. Need at least 25 IPs. Please resize subnet! Exiting ${reset}"
- exit 1
+ interface_ip=$(find_ip $interface)
+ if [ ! "$interface_ip" ]; then
+ continue
fi
- elif [ "$if_counter" -eq 3 ]; then
- storage_subnet_mask=$subnet_mask
+ new_ip=$(next_usable_ip $interface_ip)
+ if [ ! "$new_ip" ]; then
+ continue
+ fi
+ interface_arr[$interface]=$if_counter
+ interface_ip_arr[$if_counter]=$new_ip
+ subnet_mask=$(find_netmask $interface)
+ if [ "$if_counter" -eq 0 ]; then
+ admin_subnet_mask=$subnet_mask
+ admin_ip=$new_ip
+ if ! verify_subnet_size $admin_subnet_mask 5; then
+ echo "${red} Not enough IPs in admin subnet: ${interface_ip_arr[$if_counter]} ${admin_subnet_mask}. Need at least 5 IPs. Please resize subnet! Exiting ${reset}"
+ exit 1
+ fi
+
+ elif [ "$if_counter" -eq 1 ]; then
+ private_subnet_mask=$subnet_mask
+ private_short_subnet_mask=$(find_short_netmask $interface)
- if ! verify_subnet_size $storage_subnet_mask 10; then
- echo "${red} Not enough IPs in storage subnet: ${interface_ip_arr[$if_counter]} ${storage_subnet_mask}. Need at least 10 IPs. Please resize subnet! Exiting ${reset}"
+ if ! verify_subnet_size $private_subnet_mask 15; then
+ echo "${red} Not enough IPs in private subnet: ${interface_ip_arr[$if_counter]} ${private_subnet_mask}. Need at least 15 IPs. Please resize subnet! Exiting ${reset}"
+ exit 1
+ fi
+ elif [ "$if_counter" -eq 2 ]; then
+ public_subnet_mask=$subnet_mask
+ public_short_subnet_mask=$(find_short_netmask $interface)
+
+ if ! verify_subnet_size $public_subnet_mask 25; then
+ echo "${red} Not enough IPs in public subnet: ${interface_ip_arr[$if_counter]} ${public_subnet_mask}. Need at least 25 IPs. Please resize subnet! Exiting ${reset}"
+ exit 1
+ fi
+ elif [ "$if_counter" -eq 3 ]; then
+ storage_subnet_mask=$subnet_mask
+
+ if ! verify_subnet_size $storage_subnet_mask 10; then
+ echo "${red} Not enough IPs in storage subnet: ${interface_ip_arr[$if_counter]} ${storage_subnet_mask}. Need at least 10 IPs. Please resize subnet! Exiting ${reset}"
+ exit 1
+ fi
+ else
+ echo "${red}ERROR: interface counter outside valid range of 0 to 3: $if_counter ! ${reset}"
exit 1
fi
- else
- echo "${red}ERROR: interface counter outside valid range of 0 to 3: $if_counter ! ${reset}"
- exit 1
- fi
- sed -i 's/^.*eth_replace'"$if_counter"'.*$/ config.vm.network "public_network", ip: '\""$new_ip"\"', bridge: '\'"$interface"\'', netmask: '\""$subnet_mask"\"'/' Vagrantfile
- ((if_counter++))
- done
+ sed -i 's/^.*eth_replace'"$if_counter"'.*$/ config.vm.network "public_network", ip: '\""$new_ip"\"', bridge: '\'"$interface"\'', netmask: '\""$subnet_mask"\"'/' Vagrantfile
+ ((if_counter++))
+ done
+ fi
fi
+
##now remove interface config in Vagrantfile for 1 node
##if 1, 3, or 4 interfaces set deployment type
##if 2 interfaces remove 2nd interface and set deployment type
@@ -645,6 +705,12 @@ configure_network() {
sed -i 's/^.*eth_replace0.*$/ config.vm.network "private_network", virtualbox__intnet: "my_admin_network", ip: '\""$admin_internal_ip"\"', netmask: '\""$private_subnet_mask"\"'/' Vagrantfile
remove_vagrant_network eth_replace3
deployment_type=three_network
+ elif [[ "$if_counter" == 1 ]]; then
+ echo "${blue}Single network detected for Baremetal deployment! ${reset}"
+ remove_vagrant_network eth_replace1
+ remove_vagrant_network eth_replace2
+ remove_vagrant_network eth_replace3
+ deployment_type="single_network"
else
echo "${blue}Single network or 2 network detected for baremetal deployment. This is unsupported! Exiting. ${reset}"
exit 1
@@ -703,7 +769,7 @@ configure_network() {
sed -i 's/^.*nat_flag =.*$/ nat_flag = true/' Vagrantfile
echo "${blue}Setting node gateway to be VM Admin IP${reset}"
node_default_gw=${interface_ip_arr[0]}
- public_gateway=$default_gw
+ public_gateway=$host_default_gw
;;
3)
echo "${red}Default Gateway Detected on Storage Interface!${reset}"
@@ -763,40 +829,79 @@ configure_network() {
##private interface will be of hosts, so we need to know the provisioned host interface name
##we add biosdevname=0, net.ifnames=0 to the kickstart to use regular interface naming convention on hosts
##replace IP for parameters with next IP that will be given to controller
- if [ "$deployment_type" == "single_network" ]; then
- ##we also need to assign IP addresses to nodes
- ##for single node, foreman is managing the single network, so we can't reserve them
- ##not supporting single network anymore for now
- echo "{blue}Single Network type is unsupported right now. Please check your interface configuration. Exiting. ${reset}"
- exit 0
- elif [[ "$deployment_type" == "multi_network" || "$deployment_type" == "three_network" ]]; then
+ if [[ "$deployment_type" == "single_network" || "$deployment_type" == "multi_network" || "$deployment_type" == "three_network" ]]; then
if [ "$deployment_type" == "three_network" ]; then
sed -i 's/^.*network_type:.*$/network_type: three_network/' opnfv_ksgen_settings.yml
+ elif [ "$deployment_type" == "single_network" ]; then
+ sed -i 's/^.*network_type:.*$/network_type: single_network/' opnfv_ksgen_settings.yml
+ next_single_ip=${interface_ip_arr[0]}
+ foreman_ip=$next_single_ip
+ next_single_ip=$(next_usable_ip $next_single_ip)
fi
sed -i 's/^.*deployment_type:.*$/ deployment_type: '"$deployment_type"'/' opnfv_ksgen_settings.yml
##get ip addresses for private network on controllers to make dhcp entries
##required for controllers_ip_array global param
- next_private_ip=${interface_ip_arr[1]}
- type=_private
- control_count=0
- for node in controller1 controller2 controller3; do
- next_private_ip=$(next_usable_ip $next_private_ip)
- if [ ! "$next_private_ip" ]; then
- printf '%s\n' 'deploy.sh: Unable to find next ip for private network for control nodes' >&2
- exit 1
- fi
- sed -i 's/'"$node$type"'/'"$next_private_ip"'/g' opnfv_ksgen_settings.yml
- controller_ip_array=$controller_ip_array$next_private_ip,
- controllers_ip_arr[$control_count]=$next_private_ip
- ((control_count++))
- done
+ if [ "$deployment_type" == "single_network" ]; then
+ next_private_ip=$next_single_ip
+ sed -i 's/^.*no_dhcp:.*$/no_dhcp: true/' opnfv_ksgen_settings.yml
+ nodes=`sed -nr '/nodes:/{:start /workaround/!{N;b start};//p}' opnfv_ksgen_settings.yml | sed -n '/^ [A-Za-z0-9]\+:$/p' | sed 's/\s*//g' | sed 's/://g'`
+ compute_nodes=`echo $nodes | tr " " "\n" | grep -v controller | tr "\n" " "`
+ controller_nodes=`echo $nodes | tr " " "\n" | grep controller | tr "\n" " "`
+ nodes=${controller_nodes}${compute_nodes}
+ next_admin_ip=${interface_ip_arr[0]}
+ type1=_admin
+ type2=_private
+ control_count=0
+ for node in ${controller_nodes}; do
+ next_private_ip=$(next_usable_ip $next_private_ip)
+ if [ ! "$next_private_ip" ]; then
+ echo "${red} Unable to find an unused IP for $node ! ${reset}"
+ exit 1
+ else
+ sed -i 's/'"$node$type1"'/'"$next_private_ip"'/g' opnfv_ksgen_settings.yml
+ sed -i 's/'"$node$type2"'/'"$next_private_ip"'/g' opnfv_ksgen_settings.yml
+ controller_ip_array=$controller_ip_array$next_private_ip,
+ controllers_ip_arr[$control_count]=$next_private_ip
+ ((control_count++))
+ fi
+ done
- next_public_ip=${interface_ip_arr[2]}
- foreman_ip=$next_public_ip
+ for node in ${compute_nodes}; do
+ next_private_ip=$(next_usable_ip $next_private_ip)
+ if [ ! "$next_private_ip" ]; then
+ echo "${red} Unable to find an unused IP for $node ! ${reset}"
+ exit 1
+ else
+ sed -i 's/'"$node$type1"'/'"$next_private_ip"'/g' opnfv_ksgen_settings.yml
+ fi
+ done
+
+ else
+ next_private_ip=${interface_ip_arr[1]}
+
+ type=_private
+ control_count=0
+ for node in controller1 controller2 controller3; do
+ next_private_ip=$(next_usable_ip $next_private_ip)
+ if [ ! "$next_private_ip" ]; then
+ printf '%s\n' 'deploy.sh: Unable to find next ip for private network for control nodes' >&2
+ exit 1
+ fi
+ sed -i 's/'"$node$type"'/'"$next_private_ip"'/g' opnfv_ksgen_settings.yml
+ controller_ip_array=$controller_ip_array$next_private_ip,
+ controllers_ip_arr[$control_count]=$next_private_ip
+ ((control_count++))
+ done
+ fi
+
+ if [[ "$deployment_type" != "single_network" ]]; then
+ next_public_ip=${interface_ip_arr[2]}
+ foreman_ip=$next_public_ip
+ fi
##if no dhcp, find all the Admin IPs for nodes in advance
if [ $virtual ]; then
@@ -862,11 +967,17 @@ configure_network() {
##replace foreman site
sed -i 's/^.*foreman_url:.*$/ foreman_url:'" https:\/\/$foreman_ip"'\/api\/v2\//' opnfv_ksgen_settings.yml
##replace public vips
- ##no need to do this if no dhcp
- if [[ -z "$enable_virtual_dhcp" && ! -z "$virtual" ]]; then
- next_public_ip=$(next_usable_ip $next_public_ip)
+
+ ##if single_network deployment we continue next_public_ip from next_private_ip
+ if [[ "$deployment_type" == "single_network" ]]; then
+ next_public_ip=$(next_usable_ip $next_private_ip)
else
- next_public_ip=$(increment_ip $next_public_ip 10)
+ ##no need to do this if no dhcp
+ if [[ -z "$enable_virtual_dhcp" && ! -z "$virtual" ]]; then
+ next_public_ip=$(next_usable_ip $next_public_ip)
+ else
+ next_public_ip=$(increment_ip $next_public_ip 10)
+ fi
fi
public_output=$(grep -E '*public_vip' opnfv_ksgen_settings.yml)
@@ -884,14 +995,28 @@ configure_network() {
done <<< "$public_output"
fi
+ ##replace admin_network param for bare metal deployments
+ if [[ -z "$virtual" && -z "$single_network" ]]; then
+ admin_subnet=$(find_subnet $admin_ip $admin_subnet_mask)
+ sed -i 's/^.*admin_network:.*$/ admin_network:'" $admin_subnet"'/' opnfv_ksgen_settings.yml
+ else
+ sed -i 's/^.*admin_network:.*$/ admin_network:'" \"false\""'/' opnfv_ksgen_settings.yml
+ fi
##replace public_network param
public_subnet=$(find_subnet $next_public_ip $public_subnet_mask)
sed -i 's/^.*public_network:.*$/ public_network:'" $public_subnet"'/' opnfv_ksgen_settings.yml
- ##replace private_network param
- private_subnet=$(find_subnet $next_private_ip $private_subnet_mask)
- sed -i 's/^.*private_network:.*$/ private_network:'" $private_subnet"'/' opnfv_ksgen_settings.yml
+ if [ "$deployment_type" == "single_network" ]; then
+ sed -i 's/^.*private_network:.*$/ private_network:'" $public_subnet"'/' opnfv_ksgen_settings.yml
+ else
+ ##replace private_network param
+ private_subnet=$(find_subnet $next_private_ip $private_subnet_mask)
+ sed -i 's/^.*private_network:.*$/ private_network:'" $private_subnet"'/' opnfv_ksgen_settings.yml
+ fi
+
##replace storage_network
- if [ "$deployment_type" == "three_network" ]; then
+ if [ "$deployment_type" == "single_network" ]; then
+ sed -i 's/^.*storage_network:.*$/ storage_network:'" $public_subnet"'/' opnfv_ksgen_settings.yml
+ elif [ "$deployment_type" == "three_network" ]; then
sed -i 's/^.*storage_network:.*$/ storage_network:'" $private_subnet"'/' opnfv_ksgen_settings.yml
else
next_storage_ip=${interface_ip_arr[3]}
@@ -902,18 +1027,30 @@ configure_network() {
##replace public_subnet param
public_subnet=$public_subnet'\'$public_short_subnet_mask
sed -i 's/^.*public_subnet:.*$/ public_subnet:'" $public_subnet"'/' opnfv_ksgen_settings.yml
- ##replace private_subnet param
- private_subnet=$private_subnet'\'$private_short_subnet_mask
- sed -i 's/^.*private_subnet:.*$/ private_subnet:'" $private_subnet"'/' opnfv_ksgen_settings.yml
+ if [ "$deployment_type" == "single_network" ]; then
+ sed -i 's/^.*private_subnet:.*$/ private_subnet:'" $public_subnet"'/' opnfv_ksgen_settings.yml
+ else
+ ##replace private_subnet param
+ private_subnet=$private_subnet'\'$private_short_subnet_mask
+ sed -i 's/^.*private_subnet:.*$/ private_subnet:'" $private_subnet"'/' opnfv_ksgen_settings.yml
+ fi
##replace public_dns param to be foreman server
- sed -i 's/^.*public_dns:.*$/ public_dns: '${interface_ip_arr[2]}'/' opnfv_ksgen_settings.yml
+ if [ "$deployment_type" == "single_network" ]; then
+ sed -i 's/^.*public_dns:.*$/ public_dns: '${interface_ip_arr[0]}'/' opnfv_ksgen_settings.yml
+ else
+ sed -i 's/^.*public_dns:.*$/ public_dns: '${interface_ip_arr[2]}'/' opnfv_ksgen_settings.yml
+ fi
##replace public_gateway
if [ -z "$public_gateway" ]; then
- ##if unset then we assume its the first IP in the public subnet
- public_subnet=$(find_subnet $next_public_ip $public_subnet_mask)
- public_gateway=$(increment_subnet $public_subnet 1)
+ if [ "$deployment_type" == "single_network" ]; then
+ public_gateway=$node_default_gw
+ else
+ ##if unset then we assume its the first IP in the public subnet
+ public_subnet=$(find_subnet $next_public_ip $public_subnet_mask)
+ public_gateway=$(increment_subnet $public_subnet 1)
+ fi
fi
sed -i 's/^.*public_gateway:.*$/ public_gateway:'" $public_gateway"'/' opnfv_ksgen_settings.yml
@@ -1023,6 +1160,19 @@ start_virtual_nodes() {
node_type=config_nodes_${node}_type
node_type=$(eval echo \$$node_type)
+ ##modify memory and cpu
+ node_memory=$(eval echo \${config_nodes_${node}_memory})
+ node_vcpus=$(eval echo \${config_nodes_${node}_cpus})
+ node_storage=$(eval echo \${config_nodes_${node}_disk})
+
+ sed -i 's/^.*vb.memory =.*$/ vb.memory = '"$node_memory"'/' Vagrantfile
+ sed -i 's/^.*vb.cpus =.*$/ vb.cpus = '"$node_vcpus"'/' Vagrantfile
+
+ if ! resize_vagrant_disk $node_storage; then
+ echo "${red}Error while resizing vagrant box to size $node_storage for $node! ${reset}"
+ exit 1
+ fi
+
##trozet test make compute nodes wait 20 minutes
if [ "$compute_wait_completed" = false ] && [ "$node_type" != "controller" ]; then
echo "${blue}Waiting 20 minutes for Control nodes to install before continuing with Compute nodes..."
@@ -1091,8 +1241,12 @@ start_virtual_nodes() {
##modify provisioning to do puppet install, config, and foreman check-in
##substitute host_name and dns_server in the provisioning script
- host_string=config_nodes_${node}_hostname
- host_name=$(eval echo \$$host_string)
+ host_string=config_nodes_${node}_short_name
+ short_host_name=$(eval echo \$$host_string)
+ ##substitute domain_name
+ domain_name=$config_domain_name
+ sed -i 's/^domain_name=REPLACE/domain_name='$domain_name'/' vm_nodes_provision.sh
+ host_name=${short_host_name}.${domain_name}
sed -i 's/^host_name=REPLACE/host_name='$host_name'/' vm_nodes_provision.sh
##dns server should be the foreman server
sed -i 's/^dns_server=REPLACE/dns_server='${interface_ip_arr[0]}'/' vm_nodes_provision.sh
@@ -1101,11 +1255,6 @@ start_virtual_nodes() {
sed -i 's/bootstrap.sh/vm_nodes_provision.sh/' Vagrantfile
## modify default_gw to be node_default_gw
sed -i 's/^.*default_gw =.*$/ default_gw = '\""$node_default_gw"\"'/' Vagrantfile
- ## modify VM memory to be 4gig
- ##if node type is controller
- if [ "$node_type" == "controller" ]; then
- sed -i 's/^.*vb.memory =.*$/ vb.memory = 4096/' Vagrantfile
- fi
echo "${blue}Starting Vagrant Node $node! ${reset}"
##stand up vagrant
if ! vagrant up; then
@@ -1226,6 +1375,77 @@ check_baremetal_nodes() {
fi
}
+##resizes vagrant disk (cannot shrink)
+##params: size in GB
+##usage: resize_vagrant_disk 100
+resize_vagrant_disk() {
+ if [[ "$1" < 40 ]]; then
+ echo "${blue}Warn: Requested disk size cannot be less than 40, using 40 as new size${reset}"
+ new_size_gb=40
+ else
+ new_size_gb=$1
+ fi
+
+ if ! vagrant box list | grep opnfv; then
+ vagrant box remove -f opnfv/centos-7.0
+ if ! vagrant box add opnfv/centos-7.0 --provider virtualbox; then
+ echo "${red}Unable to reclone vagrant box! Exiting...${reset}"
+ exit 1
+ fi
+ fi
+
+ pushd $vagrant_box_dir
+
+ # Close medium to make sure we can modify it
+ vboxmanage closemedium disk $vagrant_box_vmdk
+
+ cur_size=$(vboxmanage showhdinfo $vagrant_box_vmdk | grep -i capacity | grep -Eo [0-9]+)
+ cur_size_gb=$((cur_size / 1024))
+
+ if [ "$cur_size_gb" -eq "$new_size_gb" ]; then
+ echo "${blue}Info: Disk size already ${cur_size_gb} ${reset}"
+ popd
+ return
+ elif [[ "$new_size_gb" < "$cur_size_gb" ]] ; then
+ echo "${blue}Info: Requested disk is less than ${cur_size_gb} ${reset}"
+ echo "${blue}Re-adding vagrant box${reset}"
+ if vagrant box list | grep opnfv; then
+ popd
+ vagrant box remove -f opnfv/centos-7.0
+ if ! vagrant box add opnfv/centos-7.0 --provider virtualbox; then
+ echo "${red}Unable to reclone vagrant box! Exiting...${reset}"
+ exit 1
+ fi
+ pushd $vagrant_box_dir
+ fi
+ fi
+
+ new_size=$((new_size_gb * 1024))
+ if ! vboxmanage clonehd $vagrant_box_vmdk tmp-disk.vdi --format vdi; then
+ echo "${red}Error: Unable to clone ${vagrant_box_vmdk}${reset}"
+ popd
+ return 1
+ fi
+
+ if ! vboxmanage modifyhd tmp-disk.vdi --resize $new_size; then
+ echo "${red}Error: Unable modify tmp-disk.vdi to ${new_size}${reset}"
+ popd
+ return 1
+ fi
+
+ if ! vboxmanage clonehd tmp-disk.vdi resized-disk.vmdk --format vmdk; then
+ echo "${red}Error: Unable clone tmp-disk.vdi to vmdk${reset}"
+ popd
+ return 1
+ fi
+
+ vboxmanage closemedium disk tmp-disk.vdi --delete
+ rm -f tmp-disk.vdi $vagrant_box_vmdk
+ cp -f resized-disk.vmdk $vagrant_box_vmdk
+ vboxmanage closemedium disk resized-disk.vmdk --delete
+ popd
+}
+
##END FUNCTIONS
main() {
diff --git a/foreman/ci/opnfv_ksgen_settings.yml b/foreman/ci/opnfv_ksgen_settings.yml
index b41a41b..2859616 100644
--- a/foreman/ci/opnfv_ksgen_settings.yml
+++ b/foreman/ci/opnfv_ksgen_settings.yml
@@ -7,6 +7,7 @@ global_params:
controllers_hostnames_array: oscontroller1,oscontroller2,oscontroller3
controllers_ip_array:
amqp_vip:
+ admin_network:
private_subnet:
cinder_admin_vip:
cinder_private_vip:
@@ -45,6 +46,7 @@ global_params:
network_type: multi_network
default_gw:
no_dhcp: false
+domain_name: opnfv.com
foreman:
seed_values:
- { name: heat_cfn, oldvalue: true, newvalue: false }
@@ -100,8 +102,8 @@ workaround_vif_plugging: false
openstack_packstack_rpm: http://REPLACE_ME/brewroot/packages/openstack-puppet-modules/2013.2/9.el6ost/noarch/openstack-puppet-modules-2013.2-9.el6ost.noarch.rpm
nodes:
compute:
- name: oscompute11.opnfv.com
- hostname: oscompute11.opnfv.com
+ name: oscompute11.{{ domain_name }}
+ hostname: oscompute11.{{ domain_name }}
short_name: oscompute11
type: compute
host_type: baremetal
@@ -114,6 +116,9 @@ nodes:
admin_ip: compute_admin
ansible_ssh_pass: "Op3nStack"
admin_password: ""
+ cpus: 2
+ memory: 2048
+ disk: 40
groups:
- compute
- foreman_nodes
@@ -121,8 +126,8 @@ nodes:
- rdo
- neutron
controller1:
- name: oscontroller1.opnfv.com
- hostname: oscontroller1.opnfv.com
+ name: oscontroller1.{{ domain_name }}
+ hostname: oscontroller1.{{ domain_name }}
short_name: oscontroller1
type: controller
host_type: baremetal
@@ -137,6 +142,9 @@ nodes:
private_mac: "10:23:45:67:87:AC"
ansible_ssh_pass: "Op3nStack"
admin_password: "octopus"
+ cpus: 2
+ memory: 4096
+ disk: 40
groups:
- controller
- foreman_nodes
@@ -144,8 +152,8 @@ nodes:
- rdo
- neutron
controller2:
- name: oscontroller2.opnfv.com
- hostname: oscontroller2.opnfv.com
+ name: oscontroller2.{{ domain_name }}
+ hostname: oscontroller2.{{ domain_name }}
short_name: oscontroller2
type: controller
host_type: baremetal
@@ -160,6 +168,9 @@ nodes:
private_mac: "10:23:45:67:87:AD"
ansible_ssh_pass: "Op3nStack"
admin_password: "octopus"
+ cpus: 2
+ memory: 4096
+ disk: 40
groups:
- controller
- foreman_nodes
@@ -167,8 +178,8 @@ nodes:
- rdo
- neutron
controller3:
- name: oscontroller3.opnfv.com
- hostname: oscontroller3.opnfv.com
+ name: oscontroller3.{{ domain_name }}
+ hostname: oscontroller3.{{ domain_name }}
short_name: oscontroller3
type: controller
host_type: baremetal
@@ -183,6 +194,9 @@ nodes:
private_mac: "10:23:45:67:87:AE"
ansible_ssh_pass: "Op3nStack"
admin_password: "octopus"
+ cpus: 2
+ memory: 4096
+ disk: 40
groups:
- controller
- foreman_nodes
diff --git a/foreman/ci/opnfv_ksgen_settings_no_HA.yml b/foreman/ci/opnfv_ksgen_settings_no_HA.yml
index 79db257..3066038 100644
--- a/foreman/ci/opnfv_ksgen_settings_no_HA.yml
+++ b/foreman/ci/opnfv_ksgen_settings_no_HA.yml
@@ -3,6 +3,7 @@ global_params:
ha_flag: "false"
odl_flag: "true"
odl_control_ip:
+ admin_network:
private_network:
storage_network:
public_network:
@@ -12,6 +13,7 @@ global_params:
network_type: multi_network
default_gw:
no_dhcp: false
+domain_name: opnfv.com
foreman:
seed_values:
- { name: heat_cfn, oldvalue: true, newvalue: false }
@@ -67,8 +69,8 @@ workaround_vif_plugging: false
openstack_packstack_rpm: http://REPLACE_ME/brewroot/packages/openstack-puppet-modules/2013.2/9.el6ost/noarch/openstack-puppet-modules-2013.2-9.el6ost.noarch.rpm
nodes:
compute:
- name: oscompute11.opnfv.com
- hostname: oscompute11.opnfv.com
+ name: oscompute11.{{ domain_name }}
+ hostname: oscompute11.{{ domain_name }}
short_name: oscompute11
type: compute
host_type: baremetal
@@ -81,6 +83,9 @@ nodes:
admin_ip: compute_admin
ansible_ssh_pass: "Op3nStack"
admin_password: ""
+ cpus: 2
+ memory: 2048
+ disk: 40
groups:
- compute
- foreman_nodes
@@ -88,8 +93,8 @@ nodes:
- rdo
- neutron
controller1:
- name: oscontroller1.opnfv.com
- hostname: oscontroller1.opnfv.com
+ name: oscontroller1.{{ domain_name }}
+ hostname: oscontroller1.{{ domain_name }}
short_name: oscontroller1
type: controller
host_type: baremetal
@@ -104,6 +109,9 @@ nodes:
private_mac: "10:23:45:67:87:AC"
ansible_ssh_pass: "Op3nStack"
admin_password: "octopus"
+ cpus: 2
+ memory: 4096
+ disk: 40
groups:
- controller
- foreman_nodes
diff --git a/foreman/ci/resize_lvm.sh b/foreman/ci/resize_lvm.sh
new file mode 100755
index 0000000..64a9c62
--- /dev/null
+++ b/foreman/ci/resize_lvm.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+#script for resizing volumes in Foreman/QuickStack VM
+#author: Tim Rozet (trozet@redhat.com)
+#
+#Uses Vagrant and VirtualBox
+#VagrantFile uses resize_partition.sh
+#
+#Pre-requisties:
+#Vagrant box disk size already resized
+#Partition already resized
+
+##VARS
+reset=`tput sgr0`
+blue=`tput setaf 4`
+red=`tput setaf 1`
+green=`tput setaf 2`
+
+##END VARS
+
+echo "${blue}Resizing physical volume${reset}"
+if ! pvresize /dev/sda2; then
+ echo "${red}Unable to resize physical volume${reset}"
+ exit 1
+else
+ new_part_size=`pvdisplay | grep -Eo "PV Size\s*[0-9]+\." | awk {'print $3'} | tr -d .`
+ echo "${blue}New physical volume size: ${new_part_size}${reset}"
+fi
+
+echo "${blue}Resizing logical volume${reset}"
+if ! lvextend /dev/mapper/centos-root -r -l +100%FREE; then
+ echo "${red}Unable to resize logical volume${reset}"
+ exit 1
+else
+ new_fs_size=`df -h | grep centos-root | awk '{print $2}'`
+ echo "${blue}Filesystem resized to: ${new_fs_size}${reset}"
+fi
diff --git a/foreman/ci/resize_partition.sh b/foreman/ci/resize_partition.sh
new file mode 100755
index 0000000..4c5581d
--- /dev/null
+++ b/foreman/ci/resize_partition.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+#script for extending disk partition in Foreman/QuickStack VM
+#author: Tim Rozet (trozet@redhat.com)
+#
+#Uses Vagrant and VirtualBox
+#VagrantFile uses resize_partition.sh
+#
+#Pre-requisties:
+#Vagrant box disk size already resized
+
+##VARS
+reset=`tput sgr0`
+blue=`tput setaf 4`
+red=`tput setaf 1`
+green=`tput setaf 2`
+
+##END VARS
+
+echo "${blue}Extending partition...${reset}"
+echo "d
+2
+n
+p
+
+
+
+p
+t
+2
+8e
+w
+"|fdisk /dev/sda; true
diff --git a/foreman/ci/vm_nodes_provision.sh b/foreman/ci/vm_nodes_provision.sh
index e64c0ad..ef2b325 100755
--- a/foreman/ci/vm_nodes_provision.sh
+++ b/foreman/ci/vm_nodes_provision.sh
@@ -19,6 +19,7 @@ green=`tput setaf 2`
host_name=REPLACE
dns_server=REPLACE
host_ip=REPLACE
+domain_name=REPLACE
##END VARS
##set hostname
@@ -35,7 +36,7 @@ fi
##modify /etc/resolv.conf to point to foreman
echo "${blue} Configuring resolv.conf with DNS: $dns_server ${reset}"
cat > /etc/resolv.conf << EOF
-search ci.com opnfv.com
+search $domain_name
nameserver $dns_server
nameserver 8.8.8.8
@@ -94,10 +95,10 @@ pluginsync = true
report = true
ignoreschedules = true
daemon = false
-ca_server = foreman-server.opnfv.com
+ca_server = foreman-server.$domain_name
certname = $host_name
environment = production
-server = foreman-server.opnfv.com
+server = foreman-server.$domain_name
runinterval = 600
EOF
@@ -105,13 +106,13 @@ EOF
# Setup puppet to run on system reboot
/sbin/chkconfig --level 345 puppet on
-/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server foreman-server.opnfv.com --no-daemonize
+/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server foreman-server.$domain_name --no-daemonize
sync
# Inform the build system that we are done.
echo "Informing Foreman that we are built"
-wget -q -O /dev/null --no-check-certificate http://foreman-server.opnfv.com:80/unattended/built
+wget -q -O /dev/null --no-check-certificate http://foreman-server.$domain_name:80/unattended/built
echo "Starting puppet"
systemctl start puppet