summaryrefslogtreecommitdiffstats
path: root/modules-available/dnbd3
diff options
context:
space:
mode:
authorSimon Rettberg2017-12-11 16:10:38 +0100
committerSimon Rettberg2017-12-11 16:10:38 +0100
commit7c5bebc943557d771d0310bb7d82fbfbcc51b62b (patch)
tree5615822623f33440d69f18216656ce1ecc911dd6 /modules-available/dnbd3
parent[dozmod] Increase limits for maxImageValidityDays and maxLectureValidityDays (diff)
downloadslx-admin-7c5bebc943557d771d0310bb7d82fbfbcc51b62b.tar.gz
slx-admin-7c5bebc943557d771d0310bb7d82fbfbcc51b62b.tar.xz
slx-admin-7c5bebc943557d771d0310bb7d82fbfbcc51b62b.zip
[dnbd3] Allow configuring alternative IP address for managed proxy
Diffstat (limited to 'modules-available/dnbd3')
-rw-r--r--modules-available/dnbd3/baseconfig/getconfig.inc.php3
-rw-r--r--modules-available/dnbd3/inc/dnbd3util.inc.php11
-rw-r--r--modules-available/dnbd3/lang/de/template-tags.json2
-rw-r--r--modules-available/dnbd3/lang/en/template-tags.json2
-rw-r--r--modules-available/dnbd3/page.inc.php34
-rw-r--r--modules-available/dnbd3/templates/fragment-server-settings.html14
6 files changed, 55 insertions, 11 deletions
diff --git a/modules-available/dnbd3/baseconfig/getconfig.inc.php b/modules-available/dnbd3/baseconfig/getconfig.inc.php
index e0389c71..fe1bef17 100644
--- a/modules-available/dnbd3/baseconfig/getconfig.inc.php
+++ b/modules-available/dnbd3/baseconfig/getconfig.inc.php
@@ -24,6 +24,7 @@ $res = Database::simpleQuery('SELECT s.fixedip, m.clientip, sxl.locationid FROM
LEFT JOIN dnbd3_server_x_location sxl USING (serverid)
WHERE sxl.locationid IS NULL OR sxl.locationid IN (:lids)', array('lids' => $locationIds));
// Lookup of priority - first index (0) will be closest location in chain
+// low value is higher priority
$locationsAssoc = array_flip($locationIds);
$servers = array();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
@@ -33,7 +34,7 @@ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
} else {
$defPrio = 1000;
}
- $ip = $row['clientip'] ? $row['clientip'] : $row['fixedip'];
+ $ip = $row['fixedip'] ? $row['fixedip'] : $row['clientip'];
if ($defPrio === 1000 && is_null($row['locationid'])) {
$serverLoc = Location::getFromIp($ip);
if ($serverLoc !== false) {
diff --git a/modules-available/dnbd3/inc/dnbd3util.inc.php b/modules-available/dnbd3/inc/dnbd3util.inc.php
index 02ca89c2..95b6ffe2 100644
--- a/modules-available/dnbd3/inc/dnbd3util.inc.php
+++ b/modules-available/dnbd3/inc/dnbd3util.inc.php
@@ -11,10 +11,10 @@ class Dnbd3Util {
FROM dnbd3_server s
LEFT JOIN machine m USING (machineuuid)');
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- if (!is_null($row['clientip'])) {
- $ip = $row['clientip'];
- } elseif (!is_null($row['fixedip'])) {
+ if (!is_null($row['fixedip'])) {
$ip = $row['fixedip'];
+ } elseif (!is_null($row['clientip'])) {
+ $ip = $row['clientip'];
} else {
continue; // Huh?
}
@@ -25,6 +25,9 @@ class Dnbd3Util {
RunMode::setRunMode($row['machineuuid'], 'dnbd3', null, null, null);
continue;
}
+ } elseif ($ip === $satServerIp) {
+ // Manually configured sat server as dnbd3 server - makes no sense
+ continue;
}
$server = array(
'serverid' => $row['serverid'],
@@ -141,7 +144,7 @@ class Dnbd3Util {
$self = Property::getServerIp();
$public[$self] = $self;
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $ip = $row['clientip'] ? $row['clientip'] : $row['fixedip'];
+ $ip = $row['fixedip'] ? $row['fixedip'] : $row['clientip'];
if ($ip === '<self>') {
continue;
}
diff --git a/modules-available/dnbd3/lang/de/template-tags.json b/modules-available/dnbd3/lang/de/template-tags.json
index a178df6d..5406f1b5 100644
--- a/modules-available/dnbd3/lang/de/template-tags.json
+++ b/modules-available/dnbd3/lang/de/template-tags.json
@@ -38,6 +38,8 @@
"lang_managedServerAdd": "Automatisch konfigurierten Proxy hinzuf\u00fcgen",
"lang_managedServerHelp": "Automatisch konfigurierte DNBD3-Proxies booten wie gew\u00f6hnliche bwLehrpool-Clients via PXE \u00fcber den Satelliten-Server. Sobald ein bwLehrpool-Client als DNBD3-Proxy konfiguriert wird, erh\u00e4lt er beim Booten eine gesonderte Konfiguration, sodass er fortan exklusiv als DNBD3-Proxy arbeitet, und nicht mehr als Arbeitsstation zur Verf\u00fcgung steht.\r\nDer Vorteil ist, dass die Konfiguration automatisiert erfolgt, und durch w\u00f6chentliche Reboots sichergestellt wird, dass eventuelle Updates des MiniLinux angewendet werden.\r\nIn diesem Fall legen Sie bitte eine Partition mit der ID 45 auf der Festplatte des Proxy-Servers an; diese wird persistent Behandelt und im Gegensatz zur ID44-Partition nicht beim Booten formatiert. Generell sollte diese Partition so gro\u00df wie m\u00f6glich sein, abh\u00e4ngig von der Anzahl der genutzten VMs. Bei Platzmangel l\u00f6scht der Proxy automatisch die VM, die am l\u00e4ngsten nicht verwendet wurde, um neuen VMs Platz zu machen.\r\nWeitere Informationen dazu finden Sie im Wiki.",
"lang_numFails": "Fehler",
+ "lang_overrideIp": "Zu verwendende IP-Adresse",
+ "lang_overrideIpInfo": "Normalerweise wird die automatisch per DHCP zugewiesene Adresse auf dem Boot-Interface verwendet. Falls der Proxy mit weiteren Netzwerkkarten ausgestattet ist (die ebenfalls per DHCP konfiguriert werden) kann durch Angabe einer solchen Alternativadresse hier die Verwendung der entsprechenden Karte erzwungen werden.",
"lang_proxyConfig": "Konfiguration",
"lang_proxyLocationText": "Hier k\u00f6nnen Sie festlegen, dass nur Clients aus bestimmten R\u00e4umen\/Orten diesen Proxy verwenden. Damit vermeiden Sie die Metrikmessung zwischen Client und Proxy, wenn aufgrund der Infrastruktur bereits bekannt ist, dass dieser Proxy nur f\u00fcr bestimmte R\u00e4ume sinnvoll ist. ",
"lang_proxyServerTHead": "Server\/Proxy",
diff --git a/modules-available/dnbd3/lang/en/template-tags.json b/modules-available/dnbd3/lang/en/template-tags.json
index 0441521f..81b9d538 100644
--- a/modules-available/dnbd3/lang/en/template-tags.json
+++ b/modules-available/dnbd3/lang/en/template-tags.json
@@ -38,6 +38,8 @@
"lang_managedServerAdd": "Add automatically configured proxy",
"lang_managedServerHelp": "Automatically configured DNBD3-Proxies will boot like normal bwLehrpool-Clients over PXE and the satellite server. If a client is configured as proxy it will boot with a different configuration and acts exclusively as proxy. The client can therefore not be used as a normal working station.\r\nThe advantage is that you don't need to install or configure anything else. The client will reboot every week to get possible updates ot the minilinux.\r\nIf you want to use this feature, please create a partition with ID 45 on the local hard disk of the proxy server. In contrast to the ID 44 partition which is formated after every reboot, this partition is persistent. As a rule of thumb the partition should be as big as possible. If there is no space left the proxy will delete the VM which hasn't be used for the longest time. More information in the wiki.",
"lang_numFails": "Errors",
+ "lang_overrideIp": "IP address to use",
+ "lang_overrideIpInfo": "Usually the address that the DHCP server assigns to the boot interface of the proxy will be used. If the proxy has multiple interfaces (that also get an address assigned via DHCP) you can specify that address here to enforce their usage instead.",
"lang_proxyConfig": "Configuration",
"lang_proxyLocationText": "Here you can restrict the usage of this proxy to certain locations. This can be useful if the usage is only reasonable from some locations. That may be because of the network infrastructure.",
"lang_proxyServerTHead": "Server\/Proxy",
diff --git a/modules-available/dnbd3/page.inc.php b/modules-available/dnbd3/page.inc.php
index 74a23021..39500f83 100644
--- a/modules-available/dnbd3/page.inc.php
+++ b/modules-available/dnbd3/page.inc.php
@@ -39,6 +39,34 @@ class Page_Dnbd3 extends Page
}
$bgr = Request::post('bgr', false, 'bool');
$firewall = Request::post('firewall', false, 'bool');
+ $overrideIp = false;
+ $sip = Request::post('fixedip', null, 'string');
+ if (empty($sip)) {
+ $overrideIp = null;
+ } elseif ($server['fixedip'] !== $overrideIp) {
+ $ip = ip2long(trim($sip));
+ if ($ip !== false) {
+ $ip = long2ip($ip);
+ }
+ if ($ip === false) {
+ Message::addError('invalid-ipv4', $sip);
+ return;
+ }
+ $res = Database::queryFirst('SELECT serverid FROM dnbd3_server s
+ LEFT JOIN machine m USING (machineuuid)
+ WHERE s.fixedip = :ip OR m.clientip = :ip', compact('ip'));
+ if ($res !== false) {
+ Message::addError('server-already-exists', $ip);
+ return;
+ }
+ $overrideIp = $ip;
+ }
+ if ($overrideIp !== false) {
+ Database::exec('UPDATE dnbd3_server SET fixedip = :fixedip WHERE machineuuid = :uuid', array(
+ 'uuid' => $server['machineuuid'],
+ 'fixedip' => $overrideIp,
+ ));
+ }
RunMode::setRunMode($server['machineuuid'], 'dnbd3', 'proxy',
json_encode(compact('bgr', 'firewall')), false);
}
@@ -310,10 +338,10 @@ class Page_Dnbd3 extends Page
Message::addError('server-non-existent', 'server');
Util::redirect('?do=dnbd3');
}
- if (!is_null($server['clientip'])) {
- $server['ip'] = $server['clientip'];
- } elseif (!is_null($server['fixedip'])) {
+ if (!is_null($server['fixedip'])) {
$server['ip'] = $server['fixedip'];
+ } elseif (!is_null($server['clientip'])) {
+ $server['ip'] = $server['clientip'];
} else {
$server['ip'] = '127.0.0.1';
}
diff --git a/modules-available/dnbd3/templates/fragment-server-settings.html b/modules-available/dnbd3/templates/fragment-server-settings.html
index 61b0626d..be3e74e2 100644
--- a/modules-available/dnbd3/templates/fragment-server-settings.html
+++ b/modules-available/dnbd3/templates/fragment-server-settings.html
@@ -2,13 +2,21 @@
<div class="checkbox">
<input type="checkbox" name="bgr" id="bgr" {{#bgr}}checked{{/bgr}}>
- <label for="bgr">{{lang_backgroundReplication}}</label>
+ <label for="bgr"><b>{{lang_backgroundReplication}}</b></label>
</div>
<i>{{lang_backgroundReplicationInfo}}</i>
-<br>
+<br><br>
+
<div class="checkbox">
<input type="checkbox" name="firewall" id="firewall" {{#firewall}}checked{{/firewall}}>
- <label for="firewall">{{lang_firewalled}}</label>
+ <label for="firewall"><b>{{lang_firewalled}}</b></label>
</div>
<i>{{lang_firewallInfo}}</i>
+<br><br>
+
+<div>
+ <label for="fixedip">{{lang_overrideIp}}</label>
+ <input class="form-control" type="text" name="fixedip" id="fixedip" value="{{fixedip}}">
+</div>
+<i>{{lang_overrideIpInfo}}</i>
<br>