class GreTapBridge(LxBrNet): """ A network consisting of a bridge with a gretap device for tunneling to another system. """ def __init__(self, session, remoteip=None, objid=None, name=None, policy="ACCEPT", localip=None, ttl=255, key=None, start=True): """ Create a GreTapBridge instance. :param core.session.Session session: core session instance :param str remoteip: remote address :param int objid: object id :param str name: object name :param policy: network policy :param str localip: local address :param ttl: ttl value :param key: gre tap key :param bool start: start flag :return: """ LxBrNet.__init__(self, session=session, objid=objid, name=name, policy=policy, start=False) self.grekey = key if self.grekey is None: self.grekey = self.session.session_id ^ self.objid self.localnum = None self.remotenum = None self.remoteip = remoteip self.localip = localip self.ttl = ttl if remoteip is None: self.gretap = None else: self.gretap = GreTap(node=self, session=session, remoteip=remoteip, localip=localip, ttl=ttl, key=self.grekey) if start: self.startup() def startup(self): """ Creates a bridge and adds the gretap device to it. :return: nothing """ LxBrNet.startup(self) if self.gretap: self.attach(self.gretap) def shutdown(self): """ Detach the gretap device and remove the bridge. :return: nothing """ if self.gretap: self.detach(self.gretap) self.gretap.shutdown() self.gretap = None LxBrNet.shutdown(self) def addrconfig(self, addrlist): """ Set the remote tunnel endpoint. This is a one-time method for creating the GreTap device, which requires the remoteip at startup. The 1st address in the provided list is remoteip, 2nd optionally specifies localip. :param list addrlist: address list :return: nothing """ if self.gretap: raise ValueError("gretap already exists for %s" % self.name) remoteip = addrlist[0].split("/")[0] localip = None if len(addrlist) > 1: localip = addrlist[1].split("/")[0] self.gretap = GreTap(session=self.session, remoteip=remoteip, localip=localip, ttl=self.ttl, key=self.grekey) self.attach(self.gretap) def setkey(self, key): """ Set the GRE key used for the GreTap device. This needs to be set prior to instantiating the GreTap device (before addrconfig). :param key: gre key :return: nothing """ self.grekey = key
class GreTapBridge(LxBrNet): ''' A network consisting of a bridge with a gretap device for tunneling to another system. ''' def __init__(self, session, remoteip = None, objid = None, name = None, policy = "ACCEPT", localip = None, ttl = 255, key = None, verbose = False, start = True): LxBrNet.__init__(self, session = session, objid = objid, name = name, verbose = verbose, policy = policy, start = False) self.grekey = key if self.grekey is None: self.grekey = self.session.sessionid ^ self.objid self.localnum = None self.remotenum = None self.remoteip = remoteip self.localip = localip self.ttl = ttl if remoteip is None: self.gretap = None else: self.gretap = GreTap(node = self, name = None, session = session, remoteip = remoteip, objid = None, localip = localip, ttl = ttl, key = self.grekey) if start: self.startup() def startup(self): ''' Creates a bridge and adds the gretap device to it. ''' LxBrNet.startup(self) if self.gretap: self.attach(self.gretap) def shutdown(self): ''' Detach the gretap device and remove the bridge. ''' if self.gretap: self.detach(self.gretap) self.gretap.shutdown() self.gretap = None LxBrNet.shutdown(self) def addrconfig(self, addrlist): ''' Set the remote tunnel endpoint. This is a one-time method for creating the GreTap device, which requires the remoteip at startup. The 1st address in the provided list is remoteip, 2nd optionally specifies localip. ''' if self.gretap: raise ValueError, "gretap already exists for %s" % self.name remoteip = addrlist[0].split('/')[0] localip = None if len(addrlist) > 1: localip = addrlist[1].split('/')[0] self.gretap = GreTap(session = self.session, remoteip = remoteip, objid = None, name = None, localip = localip, ttl = self.ttl, key = self.grekey) self.attach(self.gretap) def setkey(self, key): ''' Set the GRE key used for the GreTap device. This needs to be set prior to instantiating the GreTap device (before addrconfig). ''' self.grekey = key
class GreTapBridge(LxBrNet): ''' A network consisting of a bridge with a gretap device for tunneling to another system. ''' def __init__(self, session, remoteip=None, objid=None, name=None, policy="ACCEPT", localip=None, ttl=255, key=None, verbose=False, start=True): LxBrNet.__init__(self, session=session, objid=objid, name=name, verbose=verbose, policy=policy, start=False) self.grekey = key if self.grekey is None: self.grekey = self.session.sessionid ^ self.objid self.localnum = None self.remotenum = None self.remoteip = remoteip self.localip = localip self.ttl = ttl if remoteip is None: self.gretap = None else: self.gretap = GreTap(node=self, name=None, session=session, remoteip=remoteip, objid=None, localip=localip, ttl=ttl, key=self.grekey) if start: self.startup() def startup(self): ''' Creates a bridge and adds the gretap device to it. ''' LxBrNet.startup(self) if self.gretap: self.attach(self.gretap) def shutdown(self): ''' Detach the gretap device and remove the bridge. ''' if self.gretap: self.detach(self.gretap) self.gretap.shutdown() self.gretap = None LxBrNet.shutdown(self) def addrconfig(self, addrlist): ''' Set the remote tunnel endpoint. This is a one-time method for creating the GreTap device, which requires the remoteip at startup. The 1st address in the provided list is remoteip, 2nd optionally specifies localip. ''' if self.gretap: raise ValueError, "gretap already exists for %s" % self.name remoteip = addrlist[0].split('/')[0] localip = None if len(addrlist) > 1: localip = addrlist[1].split('/')[0] self.gretap = GreTap(session=self.session, remoteip=remoteip, objid=None, name=None, localip=localip, ttl=self.ttl, key=self.grekey) self.attach(self.gretap) def setkey(self, key): ''' Set the GRE key used for the GreTap device. This needs to be set prior to instantiating the GreTap device (before addrconfig). ''' self.grekey = key
class GreTapBridge(LxBrNet): """ A network consisting of a bridge with a gretap device for tunneling to another system. """ def __init__(self, session, remoteip=None, objid=None, name=None, policy="ACCEPT", localip=None, ttl=255, key=None, start=True): """ Create a GreTapBridge instance. :param core.session.Session session: core session instance :param str remoteip: remote address :param int objid: object id :param str name: object name :param policy: network policy :param str localip: local address :param ttl: ttl value :param key: gre tap key :param bool start: start flag :return: """ LxBrNet.__init__(self, session=session, objid=objid, name=name, policy=policy, start=False) self.grekey = key if self.grekey is None: self.grekey = self.session.session_id ^ self.objid self.localnum = None self.remotenum = None self.remoteip = remoteip self.localip = localip self.ttl = ttl if remoteip is None: self.gretap = None else: self.gretap = GreTap(node=self, session=session, remoteip=remoteip, localip=localip, ttl=ttl, key=self.grekey) if start: self.startup() def startup(self): """ Creates a bridge and adds the gretap device to it. :return: nothing """ LxBrNet.startup(self) if self.gretap: self.attach(self.gretap) def shutdown(self): """ Detach the gretap device and remove the bridge. :return: nothing """ if self.gretap: self.detach(self.gretap) self.gretap.shutdown() self.gretap = None LxBrNet.shutdown(self) def addrconfig(self, addrlist): """ Set the remote tunnel endpoint. This is a one-time method for creating the GreTap device, which requires the remoteip at startup. The 1st address in the provided list is remoteip, 2nd optionally specifies localip. :param list addrlist: address list :return: nothing """ if self.gretap: raise ValueError("gretap already exists for %s" % self.name) remoteip = addrlist[0].split("/")[0] localip = None if len(addrlist) > 1: localip = addrlist[1].split("/")[0] self.gretap = GreTap(session=self.session, remoteip=remoteip, localip=localip, ttl=self.ttl, key=self.grekey) self.attach(self.gretap) def setkey(self, key): """ Set the GRE key used for the GreTap device. This needs to be set prior to instantiating the GreTap device (before addrconfig). :param key: gre key :return: nothing """ self.grekey = key