switched pnodes to check commands ran for configuration
This commit is contained in:
parent
513bb7e263
commit
cd77875e64
1 changed files with 16 additions and 11 deletions
|
@ -125,7 +125,7 @@ class PhysicalNode(PyCoreNode):
|
||||||
same as SimpleLxcNode.addaddr()
|
same as SimpleLxcNode.addaddr()
|
||||||
"""
|
"""
|
||||||
if self.up:
|
if self.up:
|
||||||
self.cmd([constants.IP_BIN, "addr", "add", str(addr), "dev", self.ifname(ifindex)])
|
self.check_cmd([constants.IP_BIN, "addr", "add", str(addr), "dev", self.ifname(ifindex)])
|
||||||
|
|
||||||
self._netif[ifindex].addaddr(addr)
|
self._netif[ifindex].addaddr(addr)
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ class PhysicalNode(PyCoreNode):
|
||||||
logger.exception("trying to delete unknown address: %s", addr)
|
logger.exception("trying to delete unknown address: %s", addr)
|
||||||
|
|
||||||
if self.up:
|
if self.up:
|
||||||
self.cmd([constants.IP_BIN, "addr", "del", str(addr), "dev", self.ifname(ifindex)])
|
self.check_cmd([constants.IP_BIN, "addr", "del", str(addr), "dev", self.ifname(ifindex)])
|
||||||
|
|
||||||
def adoptnetif(self, netif, ifindex, hwaddr, addrlist):
|
def adoptnetif(self, netif, ifindex, hwaddr, addrlist):
|
||||||
"""
|
"""
|
||||||
|
@ -151,17 +151,22 @@ class PhysicalNode(PyCoreNode):
|
||||||
netif.name = "gt%d" % ifindex
|
netif.name = "gt%d" % ifindex
|
||||||
netif.node = self
|
netif.node = self
|
||||||
self.addnetif(netif, ifindex)
|
self.addnetif(netif, ifindex)
|
||||||
|
|
||||||
# use a more reasonable name, e.g. "gt0" instead of "gt.56286.150"
|
# use a more reasonable name, e.g. "gt0" instead of "gt.56286.150"
|
||||||
if self.up:
|
if self.up:
|
||||||
self.cmd([constants.IP_BIN, "link", "set", "dev", netif.localname, "down"])
|
self.check_cmd([constants.IP_BIN, "link", "set", "dev", netif.localname, "down"])
|
||||||
self.cmd([constants.IP_BIN, "link", "set", netif.localname, "name", netif.name])
|
self.check_cmd([constants.IP_BIN, "link", "set", netif.localname, "name", netif.name])
|
||||||
|
|
||||||
netif.localname = netif.name
|
netif.localname = netif.name
|
||||||
|
|
||||||
if hwaddr:
|
if hwaddr:
|
||||||
self.sethwaddr(ifindex, hwaddr)
|
self.sethwaddr(ifindex, hwaddr)
|
||||||
|
|
||||||
for addr in utils.make_tuple(addrlist):
|
for addr in utils.make_tuple(addrlist):
|
||||||
self.addaddr(ifindex, addr)
|
self.addaddr(ifindex, addr)
|
||||||
|
|
||||||
if self.up:
|
if self.up:
|
||||||
self.cmd([constants.IP_BIN, "link", "set", "dev", netif.localname, "up"])
|
self.check_cmd([constants.IP_BIN, "link", "set", "dev", netif.localname, "up"])
|
||||||
|
|
||||||
def linkconfig(self, netif, bw=None, delay=None,
|
def linkconfig(self, netif, bw=None, delay=None,
|
||||||
loss=None, duplicate=None, jitter=None, netif2=None):
|
loss=None, duplicate=None, jitter=None, netif2=None):
|
||||||
|
@ -230,19 +235,19 @@ class PhysicalNode(PyCoreNode):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(target)
|
os.makedirs(target)
|
||||||
self.cmd([constants.MOUNT_BIN, "--bind", source, target])
|
self.check_cmd([constants.MOUNT_BIN, "--bind", source, target])
|
||||||
self._mounts.append((source, target))
|
self._mounts.append((source, target))
|
||||||
except OSError:
|
except OSError:
|
||||||
logger.exception("error making directories")
|
logger.exception("error making directories")
|
||||||
except:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.exception("mounting failed for %s at %s", source, target)
|
logger.exception("mounting failed for %s at %s: %s", source, target, e.output)
|
||||||
|
|
||||||
def umount(self, target):
|
def umount(self, target):
|
||||||
logger.info("unmounting '%s'" % target)
|
logger.info("unmounting '%s'" % target)
|
||||||
try:
|
try:
|
||||||
self.cmd([constants.UMOUNT_BIN, "-l", target])
|
self.check_cmd([constants.UMOUNT_BIN, "-l", target])
|
||||||
except:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.exception("unmounting failed for %s", target)
|
logger.exception("unmounting failed for %s: %s", target, e.output)
|
||||||
|
|
||||||
def opennodefile(self, filename, mode="w"):
|
def opennodefile(self, filename, mode="w"):
|
||||||
dirname, basename = os.path.split(filename)
|
dirname, basename = os.path.split(filename)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue