diff --git a/functions.sh b/functions.sh index 4ae2d02..747af81 100644 --- a/functions.sh +++ b/functions.sh @@ -89,6 +89,46 @@ ensure_machine_in_state() done } +# Adds the VM into MAAS +maas_add_node() +{ + node_name=$1 + mac_addr=$2 + node_type=$3 + + machine_type="vm" + [[ $node_type == "physical"]] && machine_type="$node_type" + + if [[ $machine_type == "vm" ]] ; then + power_type=-"virsh" + power_params="power_parameters_power_id=${node_name}" + power_params+=" power_parameters_power_address=${qemu_connection}" + power_params+=" power_parameters_power_pass=${qemu_password}" + else + power_type="manual" + power_params="" + fi + + # This command creates the machine in MAAS. This will then automatically + # turn the machines on, and start commissioning. + maas ${maas_profile} machines create \ + hostname=${node_name} \ + mac_addresses=${mac_addr} \ + architecture=amd64/generic \ + power_type=${power_type} ${power_params} + + # Grabs the system_id for th node that we are adding + system_id=$(maas_system_id ${node_name}) + + ensure_machine_in_state ${system_id} "Ready" + + machine_add_tag ${system_id} ${node_type} + + # Ensure that all the networks on the system have the Auto-Assign set + # so that the all the of the networks on the host have an IP automatically. + maas_assign_networks ${system_id} +} + read_config() { configs="" diff --git a/manage-hypervisor-nodes.sh b/manage-hypervisor-nodes.sh index 0590be8..1ec6f3a 100755 --- a/manage-hypervisor-nodes.sh +++ b/manage-hypervisor-nodes.sh @@ -6,33 +6,6 @@ # Time between building VMs build_fanout=60 -# Adds the VM into MAAS -maas_add_node() -{ - node_name=$1 - mac_addr=$2 - node_type=$3 - - # This command creates the machine in MAAS. This will then automatically - # turn the machines on, and start commissioning. - maas ${maas_profile} machines create \ - hostname=${node_name} \ - mac_addresses=${mac_addr} \ - architecture=amd64/generic \ - power_type=manual - - # Grabs the system_id for th node that we are adding - system_id=$(maas_system_id ${node_name}) - - ensure_machine_in_state ${system_id} "Ready" - - machine_add_tag ${system_id} ${node_type} - - # Ensure that all the networks on the system have the Auto-Assign set - # so that the all the of the networks on the host have an IP automatically. - maas_assign_networks ${system_id} -} - # Attempts to auto assign all the networks for a host maas_assign_networks() { diff --git a/manage-maas-nodes.sh b/manage-maas-nodes.sh index f64a01c..46a7b78 100755 --- a/manage-maas-nodes.sh +++ b/manage-maas-nodes.sh @@ -13,39 +13,8 @@ stg_bus="scsi" # Time between building VMs build_fanout=60 -# Adds the VM into MAAS -maas_add_node() -{ - node_name=$1 - mac_addr=$2 - node_type=$3 - - # This command creates the machine in MAAS. This will then automatically - # turn the machines on, and start commissioning. - maas ${maas_profile} machines create \ - hostname=${node_name} \ - mac_addresses=${mac_addr} \ - architecture=amd64/generic \ - power_type=virsh \ - power_parameters_power_id=${node_name} \ - power_parameters_power_address=${qemu_connection} \ - power_parameters_power_pass=${qemu_password} - - # Grabs the system_id for th node that we are adding - system_id=$(maas_system_id ${node_name}) - - - ensure_machine_in_state ${system_id} "Ready" - - machine_add_tag ${system_id} ${node_type} - - # Ensure that all the networks on the system have the Auto-Assign set - # so that the all the of the networks on the host have an IP automatically. - maas_auto_assign_networks ${system_id} -} - # Attempts to auto assign all the networks for a host -maas_auto_assign_networks() +maas_assign_networks() { system_id=$1