Move maas_add_node to functions, and standardise
This commit is contained in:
parent
098be2f389
commit
770ade65ba
40
functions.sh
40
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=""
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user