From: Mitchell E Berger Date: Fri, 18 May 2018 03:21:01 +0000 (-0400) Subject: Implement handling of various actions to perform related to the "other" X-Git-Tag: 0.0.54~2 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-xen-config.git/commitdiff_plain/8d64933f6aca827aea4f1c4b2e658cf77424ed5a?hp=bffb8c5bde4ab1b8911e77271ce3dca2829d2633 Implement handling of various actions to perform related to the "other" set of network parameters, including a minimalistic state machine. --- diff --git a/debian/changelog b/debian/changelog index 3a715ce..819085f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,12 @@ invirt-xen-config (0.0.54) unstable; urgency=low - * invirt-database: pass through parameters for the "other" IP address, - if any, to vif-invirtroute. Also, use the netmask and gateway for - the VM when autoinstalling, rather than parameters from the global - cluster configuration. + * invirt-database: handle several possible actions to take with an + "other" set of network parameters. Renumber a machine by swapping + the sets of netparams, DNAT from an old address by passing through + additional parameters to vif-invirtroute, and teardown an IP + transition by clearing all the "other" values. Also, use the + netmask and gateway for the VM when autoinstalling, rather than + parameters from the global cluster configuration. * vif-invirtroute: if there is an "other" IP address, DNAT it to the primary IP, set up routing to get it to the VM, and arp for it. Also, cut out the nonsense with backgrounding arpspoof, sleeping, and diff --git a/invirt-database b/invirt-database index 936c2a7..5fb7378 100644 --- a/invirt-database +++ b/invirt-database @@ -1,5 +1,5 @@ # -*- mode: python; -*- -from invirt.database import models, connect +from invirt.database import models, connect, session from invirt.config import structs as config import re @@ -120,11 +120,26 @@ elif codepath == 'paravm': for n in machine.nics: + other_netparams = '' + other_action = n.other_action if n.other_action else '' + if other_action == 'renumber': + (n.ip, n.netmask, n.gateway, + n.other_ip, n.other_netmask, n.other_gateway) = ( + n.other_ip, n.other_netmask, n.other_gateway, + n.ip, n.netmask, n.gateway) + other_action = n.other_action = 'dnat' + session.add(n) + session.flush() + if other_action == 'dnat': + other_netparams = ('other_ip=%s other_gateway=%s' + % (n.other_ip, n.other_gateway)) + if other_action == 'remove': + n.other_ip = n.other_netmask = n.other_gateway = n.other_action = None + session.add(n) + session.flush() check(re.match('^[0-9a-fA-F:]+$', n.mac_addr) and re.match('^[0-9.]*$', n.ip)) if n.nic_type: viftype = viftype.replace("pcnet", n.nic_type) - other_netparams = ('other_ip=%s other_gateway=%s' - % (n.other_ip, n.other_gateway) if n.other_ip else '') d = ('%smac=%s, ip=%s, script=vif-invirtroute netdev=%s gateway=%s %s' % (viftype, n.mac_addr, n.ip, config.xen.iface, n.gateway, other_netparams)) vif.append(d)