From 21fa6ea76ee0c1582810ff7c99fde10ab8a8953a Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 20 Apr 2016 19:18:54 -0700 Subject: [PATCH 1/3] Add option to disable autoports to commitAddObject Added (optional) 6th parameter to commitAddObject to disable calling the executeAutoPorts logic (e.g. kvm, eth0, eth1) Initially intended for UCS population where specific ports are defined at object creation time --- wwwroot/inc/database.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wwwroot/inc/database.php b/wwwroot/inc/database.php index c3b33f34f..5068de5ff 100644 --- a/wwwroot/inc/database.php +++ b/wwwroot/inc/database.php @@ -927,7 +927,7 @@ function checkObjectNameUniqueness ($name, $type_id, $object_id = 0) throw new InvalidRequestArgException ('name', $name, 'An object with that name already exists'); } -function commitAddObject ($new_name, $new_label, $new_type_id, $new_asset_no, $taglist = array()) +function commitAddObject ($new_name, $new_label, $new_type_id, $new_asset_no, $taglist = array(), $disable_autoports = FALSE) { checkObjectNameUniqueness ($new_name, $new_type_id); usePreparedInsertBlade @@ -959,7 +959,7 @@ function commitAddObject ($new_name, $new_label, $new_type_id, $new_asset_no, $t lastCreated ($realm, $object_id); // Do AutoPorts magic - if ($realm == 'object') + if (($realm == 'object') && !$disable_autoports) executeAutoPorts ($object_id); // Now tags... produceTagsForNewRecord ($realm, $taglist, $object_id); From 7f271f808a39de55153f1b432749ca94a1df7249 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 20 Apr 2016 19:22:38 -0700 Subject: [PATCH 2/3] Add option to disable autoports to renderEditUCSForm() Added checkbox to renderEditUCSForm() that defaults to on/checked/TRUE to disable creating the AUTOPORTS (e.g. kvm, eth0, eth1) --- wwwroot/inc/interface.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wwwroot/inc/interface.php b/wwwroot/inc/interface.php index 352d41299..775dc8bdc 100644 --- a/wwwroot/inc/interface.php +++ b/wwwroot/inc/interface.php @@ -6346,6 +6346,8 @@ function renderEditUCSForm() echo "\n"; echo ""; echo "\n"; + echo ""; + echo "\n"; echo "Actions:"; printImageHREF ('DQUEUE sync_ready', 'Auto-populate UCS', TRUE); echo ''; From 41ac2300d344c2325342135a0232580be6c91f01 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 20 Apr 2016 19:26:09 -0700 Subject: [PATCH 3/3] Add handling to disable AUTOPORTS in autoPopulateUCS() Added logic to call commitAddObject with (optional) 6th parameter to disable calling executeAutoPorts during object creation. This disables ccreating the default AUTOPORTS (e.g. kvm, eth0, eth1) since this function will populate each server with the actual ports configured on it. --- wwwroot/inc/ophandlers.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wwwroot/inc/ophandlers.php b/wwwroot/inc/ophandlers.php index 7aa3328a2..c82434331 100644 --- a/wwwroot/inc/ophandlers.php +++ b/wwwroot/inc/ophandlers.php @@ -3320,6 +3320,7 @@ function autoPopulateUCS() $oinfo = spotEntity ('object', $ucsm_id); $chassis_id = array(); $done = 0; + $disable_autoports = isCheckSet('disable_autoports'); # There are three request parameters (use_terminal_settings, ucs_login and # ucs_password) not processed here. These are asserted and used inside # queryTerminal(). @@ -3338,7 +3339,7 @@ function autoPopulateUCS() $mname = preg_replace ('#^sys/(.+)$#', $oinfo['name'] . '/\\1', $item['DN']); if ($item['type'] == 'NetworkElement') { - $new_object_id = commitAddObject ($mname, NULL, 8, NULL); + $new_object_id = commitAddObject ($mname, NULL, 8, NULL, NULL, $disable_autoports); # Set H/W Type for Network Switch if (array_key_exists ($item['model'], $ucsproductmap)) commitUpdateAttrValue ($new_object_id, 2, $ucsproductmap[$item['model']]); @@ -3350,7 +3351,7 @@ function autoPopulateUCS() } elseif ($item['type'] == 'EquipmentChassis') { - $chassis_id[$item['DN']] = $new_object_id = commitAddObject ($mname, NULL, 1502, NULL); + $chassis_id[$item['DN']] = $new_object_id = commitAddObject ($mname, NULL, 1502, NULL, NULL, $disable_autoports); # Set H/W Type for Server Chassis if (array_key_exists ($item['model'], $ucsproductmap)) commitUpdateAttrValue ($new_object_id, 2, $ucsproductmap[$item['model']]); @@ -3362,7 +3363,7 @@ function autoPopulateUCS() elseif ($item['type'] == 'ComputeBlade') { if ($item['assigned'] == '') - $new_object_id = commitAddObject ($mname, NULL, 4, NULL); + $new_object_id = commitAddObject ($mname, NULL, 4, NULL, NULL, $disable_autoports); else { $spname = preg_replace ('#.+/ls-(.+)#i', '${1}', $item['assigned']) . "(" . $oinfo['name'] . ")"; @@ -3391,11 +3392,11 @@ function autoPopulateUCS() elseif ($item['type'] == 'ComputeRackUnit') { if ($item['assigned'] == '') - $new_object_id = commitAddObject ($mname, NULL, 4, NULL); + $new_object_id = commitAddObject ($mname, NULL, 4, NULL, NULL, $disable_autoports); else { $spname = preg_replace ('#.+/ls-(.+)#i', '${1}', $item['assigned']) . "(" . $oinfo['name'] . ")"; - $new_object_id = commitAddObject ($spname, NULL, 4, NULL); + $new_object_id = commitAddObject ($spname, NULL, 4, NULL, NULL, $disable_autoports); } # Set H/W Type for RackmountServer if (array_key_exists ($item['model'], $ucsproductmap))