X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-xen-config.git/blobdiff_plain/35d7c25d5f400feba0ea1a8f69e28c1b6ccb4393..c5315b74b7779e829ffcc28ac02543b5a5a3a200:/invirt-database?ds=sidebyside 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)