Esempio n. 1
0
 def __init__(self, session, objid=None, name=None, nodedir=None):
     PyCoreNode.__init__(self, session, objid, name)
     self.nodedir = nodedir
     self.pid = None
     self.up = False
     self.lock = threading.RLock()
     self._mounts = []
Esempio n. 2
0
 def __init__(self, session, objid=None, name=None, nodedir=None, start=True):
     PyCoreNode.__init__(self, session, objid, name, start=start)
     self.nodedir = nodedir
     self.up = start
     self.lock = threading.RLock()
     self._mounts = []
     if start:
         self.startup()
Esempio n. 3
0
 def __init__(self, session, objid=None, name=None, nodedir=None, start=True):
     PyCoreNode.__init__(self, session, objid, name, start=start)
     self.nodedir = nodedir
     self.up = start
     self.lock = threading.RLock()
     self._mounts = []
     if start:
         self.startup()
Esempio n. 4
0
    def __init__(self,
                 session,
                 objid=None,
                 name=None,
                 nodedir=None,
                 bootsh="boot.sh",
                 start=True,
                 model=None,
                 vgname=None,
                 ramsize=None,
                 disksize=None,
                 isofile=None):
        # SimpleLxcNode initialization
        PyCoreNode.__init__(self, session=session, objid=objid, name=name)
        self.nodedir = nodedir
        self.model = model
        # indicates startup() has been invoked and disk has been initialized
        self.up = False
        # indicates boot() has been invoked and domU is running
        self.booted = False
        self.ifindex = 0
        self.lock = threading.RLock()
        self._netif = {}
        # domU name
        self.vmname = "c" + str(session.session_id) + "-" + name
        # LVM volume group name
        self.vgname = self.getconfigitem("vg_name", vgname)
        # LVM logical volume name
        self.lvname = self.vmname + "-"
        # LVM logical volume device path name
        self.lvpath = os.path.join("/dev", self.vgname, self.lvname)
        self.disksize = self.getconfigitem("disk_size", disksize)
        self.ramsize = int(self.getconfigitem("ram_size", ramsize))
        self.isofile = self.getconfigitem("iso_file", isofile)
        # temporary mount point for paused VM persistent filesystem
        self.mountdir = None
        self.etcdir = self.getconfigitem("etc_path")

        # TODO: remove this temporary hack
        self.files_redirection[
            "/usr/local/etc/quagga/Quagga.conf"] = os.path.join(
                self.getconfigitem("mount_path"), self.etcdir,
                "quagga/Quagga.conf")

        # LxcNode initialization
        # self.makenodedir()
        if self.nodedir is None:
            self.nodedir = os.path.join(session.session_dir,
                                        self.name + ".conf")
            self.mountdir = self.nodedir + self.getconfigitem("mount_path")
            if not os.path.isdir(self.mountdir):
                os.makedirs(self.mountdir)
            self.tmpnodedir = True
        else:
            raise Exception("Xen PVM node requires a temporary nodedir")
        self.bootsh = bootsh
        if start:
            self.startup()
Esempio n. 5
0
 def __init__(self, session, objid = None, name = None, nodedir = None,
              verbose = False):
     PyCoreNode.__init__(self, session, objid, name)
     self.nodedir = nodedir
     self.verbose = verbose
     self.pid = None
     self.up = False
     self.lock = threading.RLock()
     self._mounts = []
 def __init__(self, session, objid=None, name=None, nodedir=None, verbose=False, start=True):
     PyCoreNode.__init__(self, session, objid, name, verbose=verbose, start=start)
     self.nodedir = nodedir
     self.ctrlchnlname = os.path.abspath(os.path.join(self.session.sessiondir, self.name))
     self.vnodeclient = None
     self.pid = None
     self.up = False
     self.lock = threading.RLock()
     self._mounts = []
Esempio n. 7
0
 def __init__(self, session, objid = None, name = None, nodedir = None,
              verbose = False, start = True):
     PyCoreNode.__init__(self, session, objid, name, verbose=verbose,
                         start=start)
     self.nodedir = nodedir
     self.ctrlchnlname = \
         os.path.abspath(os.path.join(self.session.sessiondir, self.name))
     self.vnodeclient = None
     self.pid = None
     self.up = False
     self.lock = threading.RLock()
     self._mounts = []
Esempio n. 8
0
File: xen.py Progetto: Benocs/core
    def __init__(self, session, objid = None, name = None,
                 nodedir = None, bootsh = "boot.sh", verbose = False,
                 start = True, model = None,
                 vgname = None, ramsize = None, disksize = None, 
                 isofile = None):
        # SimpleLxcNode initialization
        PyCoreNode.__init__(self, session = session, objid = objid, name = name,
                            verbose = verbose)
        self.nodedir = nodedir
        self.model = model
        # indicates startup() has been invoked and disk has been initialized
        self.up = False
        # indicates boot() has been invoked and domU is running
        self.booted = False
        self.ifindex = 0
        self.lock = threading.RLock()
        self._netif = {}
        # domU name
        self.vmname = "c" + str(session.sessionid) + "-" + name
        # LVM volume group name
        self.vgname = self.getconfigitem('vg_name', vgname)
        # LVM logical volume name
        self.lvname = self.vmname + '-'
        # LVM logical volume device path name
        self.lvpath = os.path.join('/dev', self.vgname, self.lvname)
        self.disksize = self.getconfigitem('disk_size', disksize)
        self.ramsize = int(self.getconfigitem('ram_size', ramsize))
        self.isofile = self.getconfigitem('iso_file', isofile)
        # temporary mount point for paused VM persistent filesystem
        self.mountdir = None
        self.etcdir = self.getconfigitem('etc_path')

        # TODO: remove this temporary hack
        self.FilesRedirection['/usr/local/etc/quagga/Quagga.conf'] = \
            os.path.join(self.getconfigitem('mount_path'), self.etcdir,
                        'quagga/Quagga.conf')

        # LxcNode initialization
        # self.makenodedir()
        if self.nodedir is None:
            self.nodedir = \
                os.path.join(session.sessiondir, self.name + ".conf")
            self.mountdir = self.nodedir + self.getconfigitem('mount_path')
            if not os.path.isdir(self.mountdir):
                os.makedirs(self.mountdir)
            self.tmpnodedir = True
        else:
            raise Exception("Xen PVM node requires a temporary nodedir")
            self.tmpnodedir = False
        self.bootsh = bootsh
        if start:
            self.startup()
Esempio n. 9
0
 def __init__(self, session, objid = None, name = None, mtu = 1500,
              verbose = False, start = True):
     PyCoreNode.__init__(self, session, objid, name, verbose=verbose,
                         start=start)
     # this initializes net, params, poshook
     PyCoreNetIf.__init__(self, node=self, name=name, mtu = mtu)
     self.up = False
     self.lock = threading.RLock()
     self.ifindex = None
     # the following are PyCoreNetIf attributes
     self.transport_type = "raw"
     self.localname = name
     if start:
         self.startup()
Esempio n. 10
0
    def __init__(self, session, objid=None, name=None, nodedir=None, start=True):
        """
        Create a SimpleLxcNode instance.

        :param core.session.Session session: core session instance
        :param int objid: object id
        :param str name: object name
        :param str nodedir: node directory
        :param bool start: start flag
        """
        PyCoreNode.__init__(self, session, objid, name, start=start)
        self.nodedir = nodedir
        self.ctrlchnlname = os.path.abspath(os.path.join(self.session.session_dir, self.name))
        self.client = None
        self.pid = None
        self.up = False
        self.lock = threading.RLock()
        self._mounts = []
Esempio n. 11
0
    def __init__(self, session, objid=None, name=None, mtu=1500, start=True):
        """
        Create an RJ45Node instance.

        :param core.session.Session session: core session instance
        :param int objid: node id
        :param str name: node name
        :param mtu: rj45 mtu
        :param bool start: start flag
        :return:
        """
        PyCoreNode.__init__(self, session, objid, name, start=start)
        # this initializes net, params, poshook
        PyCoreNetIf.__init__(self, node=self, name=name, mtu=mtu)
        self.up = False
        self.lock = threading.RLock()
        self.ifindex = None
        # the following are PyCoreNetIf attributes
        self.transport_type = "raw"
        self.localname = name
        if start:
            self.startup()
Esempio n. 12
0
 def __init__(self,
              session,
              objid=None,
              name=None,
              mtu=1500,
              verbose=False,
              start=True):
     PyCoreNode.__init__(self,
                         session,
                         objid,
                         name,
                         verbose=verbose,
                         start=start)
     # this initializes net, params, poshook
     PyCoreNetIf.__init__(self, node=self, name=name, mtu=mtu)
     self.up = False
     self.lock = threading.RLock()
     self.ifindex = None
     # the following are PyCoreNetIf attributes
     self.transport_type = "raw"
     self.localname = name
     if start:
         self.startup()
Esempio n. 13
0
File: nodes.py Progetto: gsomlo/core
    def __init__(self, session, objid=None, name=None, mtu=1500, start=True):
        """
        Create an RJ45Node instance.

        :param core.session.Session session: core session instance
        :param int objid: node id
        :param str name: node name
        :param mtu: rj45 mtu
        :param bool start: start flag
        :return:
        """
        PyCoreNode.__init__(self, session, objid, name, start=start)
        PyCoreNetIf.__init__(self, node=self, name=name, mtu=mtu)
        self.up = False
        self.lock = threading.RLock()
        self.ifindex = None
        # the following are PyCoreNetIf attributes
        self.transport_type = "raw"
        self.localname = name
        self.old_up = False
        self.old_addrs = []

        if start:
            self.startup()
Esempio n. 14
0
    def physnodehandlelink(self, message):
        """
        Broker handler. Snoop Link add messages to get
        node numbers of PhyiscalNodes and their nets.
        Physical nodes exist only on other servers, but a shadow object is
        created here for tracking node position.

        :param message: link message to handle
        :return: nothing
        """
        if message.message_type == MessageTypes.LINK.value and message.flags & MessageFlags.ADD.value:
            nn = message.node_numbers()
            # first node is always link layer node in Link add message
            if nn[0] not in self.session.broker.network_nodes:
                return
            if nn[1] in self.session.broker.physical_nodes:
                # record the fact that this PhysicalNode is linked to a net
                dummy = PyCoreNode(session=self.session, objid=nn[1], name="n%d" % nn[1], start=False)
                self.addphys(nn[0], dummy)
Esempio n. 15
0
 def physnodehandlelink(self, msg):
     ''' Broker handler. Snoop Link add messages to get
         node numbers of PhyiscalNodes and their nets.
         Physical nodes exist only on other servers, but a shadow object is
         created here for tracking node position.
     '''
     if msg.msgtype == coreapi.CORE_API_LINK_MSG and \
        msg.flags & coreapi.CORE_API_ADD_FLAG:
         nn = msg.nodenumbers()
         # first node is always link layer node in Link add message
         if nn[0] not in self.session.broker.nets:
             return
         if nn[1] in self.session.broker.phys:
             # record the fact that this PhysicalNode is linked to a net
             dummy = PyCoreNode(session=self.session,
                                objid=nn[1],
                                name="n%d" % nn[1],
                                start=False)
             self.addphys(nn[0], dummy)
Esempio n. 16
0
 def newifindex(self):
     with self.lock:
         return PyCoreNode.newifindex(self)
Esempio n. 17
0
File: xen.py Progetto: Benocs/core
 def delnetif(self, ifindex):
     self.warn("XEN PVM delnetif() called")
     PyCoreNode.delnetif(self, ifindex)
Esempio n. 18
0
File: xen.py Progetto: Benocs/core
 def addnetif(self, netif, ifindex):
     self.warn("XEN PVM addnetif() called")
     PyCoreNode.addnetif(self, netif, ifindex)
Esempio n. 19
0
 def delnetif(self, ifindex):
     self.warn("XEN PVM delnetif() called")
     PyCoreNode.delnetif(self, ifindex)
Esempio n. 20
0
 def addnetif(self, netif, ifindex):
     self.warn("XEN PVM addnetif() called")
     PyCoreNode.addnetif(self, netif, ifindex)
 def newifindex(self):
     with self.lock:
         return PyCoreNode.newifindex(self)