def __init__(self, pif):
self._pif = pif
+ @classmethod
+ def rewrite(cls):
+ """Class method called when write action is called. Can be used
+ to update any backend specific configuration."""
+ pass
+
def configure_ipdev(self, cfg):
"""Write ifcfg TYPE field for an IPdev, plus any type specific
fields to cfg
"""
raise NotImplementedError
-def DatapathFactory(pif):
+def DatapathFactory():
# XXX Need a datapath object for bridgeless PIFs
try:
if network_backend == "bridge":
from InterfaceReconfigureBridge import DatapathBridge
- return DatapathBridge(pif)
+ return DatapathBridge
elif network_backend in ["openvswitch", "vswitch"]:
from InterfaceReconfigureVswitch import DatapathVswitch
- return DatapathVswitch(pif)
+ return DatapathVswitch
else:
raise Error("unknown network backend %s" % network_backend)
log("Configured for Vswitch datapath")
+ @classmethod
+ def rewrite(cls):
+ vsctl_argv = []
+ for pif in db().get_all_pifs():
+ pifrec = db().get_pif_record(pif)
+ if not pif_is_vlan(pif) and pifrec['currently_attached']:
+ vsctl_argv += set_br_external_ids(pif)
+
+ if vsctl_argv != []:
+ datapath_modify_config(vsctl_argv)
+
def configure_ipdev(self, cfg):
cfg.write("TYPE=Ethernet\n")
pifrec = db().get_pif_record(pif)
ipdev = pif_ipdev_name(pif)
- dp = DatapathFactory(pif)
+ dp = DatapathFactory()(pif)
log("action_up: %s" % ipdev)
def action_down(pif):
ipdev = pif_ipdev_name(pif)
- dp = DatapathFactory(pif)
+ dp = DatapathFactory()(pif)
log("action_down: %s" % ipdev)
dp.bring_down()
+def action_rewrite():
+ DatapathFactory().rewrite()
+
# This is useful for reconfiguring the mgmt interface after having lost connectivity to the pool master
def action_force_rewrite(bridge, config):
def getUUID():
pif = db().get_pif_by_uuid(pif_uuid)
if action == "rewrite":
- pass
+ action_rewrite()
else:
if not pif:
raise Usage("No PIF given")