[pve-devel] [PATCH 3/3] add hotplug ip configuration
Alexandre Derumier
aderumier at odiso.com
Thu Jun 25 07:06:43 CEST 2015
fixme:
-ip removal
-ipv6 support
-permanent guest file write config ?
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
src/PVE/LXC.pm | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 8d24adb..c40b09c 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1165,6 +1165,7 @@ sub update_net {
hotplug_net($vmid, $newnet);
}
+ update_ipconfig($vmid, $eth, $oldnet, $newnet);
}
sub hotplug_net {
@@ -1186,4 +1187,23 @@ sub hotplug_net {
PVE::Tools::run_command($cmd);
}
+sub update_ipconfig {
+ my ($vmid, $eth, $oldnet, $newnet) = @_;
+
+
+ if (&$safe_string_ne($oldnet->{ip}, $newnet->{ip})) {
+ my $cmd = ['lxc-attach', '-n', $vmid, '-s', 'NETWORK', '--', '/sbin/ip', 'addr', 'add', $newnet->{ip}, 'dev', $eth ];
+ PVE::Tools::run_command($cmd);
+ }
+
+ if (&$safe_string_ne($oldnet->{gw}, $newnet->{gw})) {
+ my $cmd = ['lxc-attach', '-n', $vmid, '-s', 'NETWORK', '--', '/sbin/ip', 'route', 'add', 'default', 'via', $newnet->{gw} ];
+ PVE::Tools::run_command($cmd);
+ }
+ #fix me : ip,gateway removal
+ #fix me : ipv6
+ #fix me : write /etc/network/interfaces ?
+
+}
+
1;
--
2.1.4
More information about the pve-devel
mailing list