option to renumber to existing interface address

This commit is contained in:
Oliver Gorwits
2022-07-26 22:32:58 +01:00
parent b52b24dd9b
commit 5ecb09dcb7
3 changed files with 14 additions and 4 deletions

View File

@@ -370,7 +370,8 @@ sub renumber {
$device->update({
ip => $new_ip,
dns => hostname_from_ip($new_ip),
dns => (hostname_from_ip($new_ip)
|| eval { $schema->resultset('DeviceIp')->find($new_ip,$new_ip)->dns } || undef),
});
return $device;

View File

@@ -30,9 +30,14 @@ ajax '/ajax/content/device/details' => require_login sub {
= schema('netdisco')->resultset('DevicePower')
->search( { 'me.ip' => $device->ip } )->with_poestats->hri->all;
my @interfaces
= schema('netdisco')->resultset('Device')
->find($device->ip)
->device_ips->hri->all;
content_type('text/html');
template 'ajax/device/details.tt', {
d => $results[0], p => \@power
d => $results[0], p => \@power, interfaces => \@interfaces,
}, { layout => undef };
};

View File

@@ -245,8 +245,12 @@
<li><p>No check is made as to whether the new IP is reachable</p></li>
</ul>
</blockquote>
<textarea id="nd_devrenumber-newip" class="input-block-level" rows="1" data-form="renumber"
placeholder="Enter new IP address" name="newip"></textarea>
<label>Enter new IP address: <input list="interfaces" name="newip" data-form="renumber"/></label>
<datalist id="interfaces">
[% FOREACH i IN interfaces %]
<option value="[% i.alias | html_entity %]">[% i.dns | html_entity %]</option>
[% END %]
</datalist>
<input type="hidden" data-form="renumber" value="[% d.ip | html_entity %]" name="device"/>
</div>
<div class="modal-footer">