/** * start a vm * * @api * * @param int $vm_id vm id * * @return bool on success TRUE/FALSE */ function ace_vm_activate($vm_id) { $lab_id = ace_db_vm_get_lab_id($vm_id); $lab_active = ace_db_lab_get_state($lab_id); if ($lab_active) { $network_ids_to_toggle = array(); $vm_nics = ace_vm_get_nic_table($vm_id); if (is_array($vm_nics)) { foreach ($vm_nics as $vm_nic) { if (!ace_network_is_active($vm_nic['network_id'])) { $network_ids_to_toggle[] = $vm_nic['network_id']; } } } if (is_array($network_ids_to_toggle)) { # start all associated inactive networks foreach ($network_ids_to_toggle as $network_id) { ace_network_activate($network_id); } } # start the vm if (ace_virt_vm_activate($vm_id)) { $db_success = ace_db_vm_activate($vm_id); $return = $db_success; } else { $return = FALSE; } if (is_array($network_ids_to_toggle)) { # stop all associated inactive networks foreach ($network_ids_to_toggle as $network_id) { ace_network_deactivate($network_id); } } } else { $db_success = ace_db_vm_activate($vm_id); $return = $db_success; } return $return; }
$message = create_message($success, "creating {$network_display_name}"); } else { $message = create_message($success, "creating network, network_id not returned"); } } else { $message = create_message(FALSE, "creating network, no lab_id specified"); } break; case 'network_change_state': if (isset($_POST['network_id'])) { $network = ace_network_get_info($_POST['network_id']); $network_display_name = $network['display_name']; if ($network['instance'] != 0) { // make sure we're not modifying the tenant-public network if (ace_network_is_active($_POST['network_id'])) { $success = ace_network_deactivate($_POST['network_id']); $message = create_message($success, "deactivating {$network_display_name}"); } else { $success = ace_network_activate($_POST['network_id']); $message = create_message($success, "activating {$network_display_name}"); } } else { $message = create_message(FALSE, "deactivating {$network_display_name}, not allowed"); } } else { $message = create_message(FALSE, "activating network, no network_id specified"); } break; case 'network_rename': if (isset($_POST['network_id'])) { if ($_POST['network_new_name'] == '..new name..' || $_POST['network_new_name'] == '') {