Add ability to set a custom port on IPMI agents (#12634)

* Add ability to set a csutom port on IPMI agents

* Casting the port value to int
This commit is contained in:
Yif Swery
2021-03-24 04:11:05 +13:00
committed by GitHub
parent e973a5fd49
commit de0fc2125c
2 changed files with 15 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
if ($_POST['editing']) {
if (Auth::user()->hasGlobalAdmin()) {
$ipmi_hostname = mres($_POST['ipmi_hostname']);
$ipmi_port = (int) $_POST['ipmi_port'];
$ipmi_username = mres($_POST['ipmi_username']);
$ipmi_password = mres($_POST['ipmi_password']);
@@ -12,6 +13,12 @@ if ($_POST['editing']) {
del_dev_attrib($device, 'ipmi_hostname');
}
if ($ipmi_port != '') {
set_dev_attrib($device, 'ipmi_port', $ipmi_port);
} else {
set_dev_attrib($device, 'ipmi_port', '623'); // Default port
}
if ($ipmi_username != '') {
set_dev_attrib($device, 'ipmi_username', $ipmi_username);
} else {
@@ -50,6 +57,12 @@ if ($updated && $update_message) {
<input id="ipmi_hostname" name="ipmi_hostname" class="form-control" value="<?php echo get_dev_attrib($device, 'ipmi_hostname'); ?>" />
</div>
</div>
<div class="form-group">
<label for="ipmi_port" class="col-sm-2 control-label">IPMI/BMC Port</label>
<div class="col-sm-6">
<input id="ipmi_port" name="ipmi_port" class="form-control" value="<?php echo get_dev_attrib($device, 'ipmi_port'); ?>" placeholder="623" />
</div>
</div>
<div class="form-group">
<label for="ipmi_username" class="col-sm-2 control-label">IPMI/BMC Username</label>
<div class="col-sm-6">

View File

@@ -9,6 +9,7 @@ if (is_array($ipmi_rows)) {
d_echo($ipmi_rows);
if ($ipmi['host'] = $attribs['ipmi_hostname']) {
$ipmi['port'] = filter_var($attribs['ipmi_port'], FILTER_VALIDATE_INT) ? $attribs['ipmi_port'] : '623';
$ipmi['user'] = $attribs['ipmi_username'];
$ipmi['password'] = $attribs['ipmi_password'];
$ipmi['type'] = $attribs['ipmi_type'];
@@ -17,7 +18,7 @@ if (is_array($ipmi_rows)) {
$cmd = [Config::get('ipmitool', 'ipmitool')];
if (Config::get('own_hostname') != $device['hostname'] || $ipmi['host'] != 'localhost') {
array_push($cmd, '-H', $ipmi['host'], '-U', $ipmi['user'], '-P', $ipmi['password'], '-L', 'USER');
array_push($cmd, '-H', $ipmi['host'], '-U', $ipmi['user'], '-P', $ipmi['password'], '-L', 'USER', '-p', $ipmi['port']);
}
// Check to see if we know which IPMI interface to use