Exemplo n.º 1
0
    def __init__(self, ref, data, balancer):
        """ Initialize the Machine.

            @param ref:         Remote reference to the ContainerClient in the
                                container process.
            @type  ref:         twisted.spread.pb.RemoteReference

            @param data:        Data about the machine.
            @type  data:        dict

            @param balancer:    Reference to the load balancer which is
                                responsible for this machine.
            @type  balancer:    rce.core.machine.LoadBalancer
        """
        self._ref = ref

        self._size = data.get('size')
        self._cpu = data.get('cpu')
        self._memeory = data.get('memory')
        self._bandwidth = data.get('bandwidth')
        self._specialFeatures = data.get('specialFeatures')

        ip = ref.broker.transport.getPeer().host
        self._ip = getSettings().internal_IP if isLocalhost(ip) else ip
        self._balancer = balancer

        self._containers = set()
        self._users = Counter()
Exemplo n.º 2
0
    def __init__(self, ref, data, balancer):
        """ Initialize the Machine.

            @param ref:         Remote reference to the ContainerClient in the
                                container process.
            @type  ref:         twisted.spread.pb.RemoteReference

            @param data:        Data about the machine.
            @type  data:        dict

            @param balancer:    Reference to the load balancer which is
                                responsible for this machine.
            @type  balancer:    rce.core.machine.LoadBalancer
        """
        self._ref = ref

        self._size = data.get('size')
        self._cpu = data.get('cpu')
        self._memeory = data.get('memory')
        self._bandwidth = data.get('bandwidth')
        self._specialFeatures = data.get('specialFeatures')

        ip = ref.broker.transport.getPeer().host
        self._ip = getSettings().internal_IP if isLocalhost(ip) else ip
        self._balancer = balancer

        self._containers = set()
        self._users = Counter()
Exemplo n.º 3
0
 def __init__(self, ref, maxNr, root):
     """ Initialize the Machine.
         
         @param ref:         Remote reference to the ContainerClient in the
                             container process.
         @type  ref:         twisted::RemoteReference
         
         @param maxNr:       The maximum number of container which are
                             allowed in the machine.
         @type  maxNr:       int
         
         @param root:        Reference to top level of data structure.
         @type  root:        rce.master.core.RoboEarthCloudEngine
     """
     self._ref = ref
     self._maxNr = maxNr
     
     ip = ref.broker.transport.getPeer().host
     self._ip = root.getInternalIP() if isLocalhost(ip) else ip
     
     self._containers = set()
Exemplo n.º 4
0
 def cb(remote):
     ip = remote.broker.transport.getPeer().host
     ip = self._root.getInternalIP() if isLocalhost(ip) else ip
     return IPv4Address('TCP', ip, self._port)
Exemplo n.º 5
0
 def cb(remote):
     ip = remote.broker.transport.getPeer().host
     ip = getSettings().internal_IP if isLocalhost(ip) else ip
     return IPv4Address('TCP', ip, self._port)
Exemplo n.º 6
0
    def __init__(self, reactor, masterIP, masterPort, masterPasswd, infraPasswd,
                 intIP, bridgeIP, envPort, rosproxyPort, rootfsDir, confDir,
                 dataDir, pkgDir):
        """ Initialize the Container Client.

            @param reactor:       Reference to the twisted reactor.
            @type  reactor:       twisted::reactor

            @param masterIP:      IP address of the Master process.
            @type  masterIP:      str

            @param masterPort:    Port of the Master process used for internal
                                  communications.
            @type  masterPort:    int

            @param masterPasswd:  SHA 256 Digested Master Password.
            @type  masterPasswd:  str

            @param infraPasswd:   SHA 256 Digested Infra Password.
            @type  infraPasswd:   str

            @param intIP:         IP address of the network interface used for
                                  the internal communication.
            @type  intIP:         str

            @param bridgeIP:      IP address of the network interface used for
                                  the container communication.
            @type  bridgeIP:      str

            @param envPort:       Port where the environment process running
                                  inside the container is listening for
                                  connections to other endpoints. (Used for
                                  port forwarding.)
            @type  envPort:       int

            @param rosproxyPort:  Port where the rosproxy process running
                                  inside the container is listening for
                                  connections to console clients. (Used for
                                  port forwarding.)
            @type  rosproxyPort:  int

            @param rootfsDir:     Filesystem path to the root directory of the
                                  container filesystem.
            @type  rootfsDir:     str

            @param confDir:       Filesystem path to the directory where
                                  container configuration files should be
                                  stored.
            @type  confDir:       str

            @param dataDir:       Filesystem path to the directory where
                                  temporary data of a container should be
                                  stored.
            @type  dataDir:       str

            @param pkgDir:        Filesystem paths to the package directories
                                  as a list of tuples where each tuple contains
                                  the path to the directory in the host machine
                                  and the path to the directory to which the
                                  host directory will be bound in the container
                                  filesystem (without the @param rootfsDir).
            @type  pkgDir:        [(str, str)]
        """
        self._reactor = reactor
        self._internalIP = intIP
        self._envPort = envPort
        self._rosproxyPort = rosproxyPort
        self._masterPort = masterPort

        if isLocalhost(masterIP):
            self._masterIP = bridgeIP
        else:
            self._masterIP = masterIP

        self._masterPasswd = masterPasswd
        self._infraPasswd = infraPasswd

        self._rootfs = rootfsDir
        self._confDir = confDir
        self._dataDir = dataDir
        self._pkgDir = pkgDir

        for _, path in self._pkgDir:
            os.mkdir(os.path.join(self._rootfs, path))

        self._nrs = set(range(100, 200))
        self._containers = set()

        # Network configuration
        self._network = bridgeIP[:bridgeIP.rfind('.')]
        self._networkConf = _NETWORK_INTERFACES.format(network=self._network)

        # Common iptables references
        nat = iptc.Table(iptc.Table.NAT)
        self._prerouting = iptc.Chain(nat, 'PREROUTING')
        self._output = iptc.Chain(nat, 'OUTPUT')
Exemplo n.º 7
0
    def __init__(self, reactor, masterIP, masterPort, masterPasswd,
                 infraPasswd, bridgeIF, intIP, bridgeIP, envPort, rosproxyPort,
                 rootfsDir, confDir, dataDir, pkgDir, ubuntuRel, rosRel, data):
        """ Initialize the Container Client.

            @param reactor:         Reference to the twisted reactor.
            @type  reactor:         twisted::reactor

            @param masterIP:        IP address of the Master process.
            @type  masterIP:        str

            @param masterPort:      Port of the Master process used for internal
                                    communications.
            @type  masterPort:      int

            @param masterPasswd:    SHA 256 Digested Master Password.
            @type  masterPasswd:    str

            @param infraPasswd:     SHA 256 Digested Infra Password.
            @type  infraPasswd:     str

            @param bridgeIF:        Network interface used for the container
                                    communication.
            @type  bridgeIF:        str

            @param intIP:           IP address of the network interface used for
                                    the internal communication.
            @type  intIP:           str

            @param bridgeIP:        IP address of the network interface used for
                                    the container communication.
            @type  bridgeIP:        str

            @param envPort:         Port where the environment process running
                                    inside the container is listening for
                                    connections to other endpoints. (Used for
                                    port forwarding.)
            @type  envPort:         int

            @param rosproxyPort:    Port where the rosproxy process running
                                    inside the container is listening for
                                    connections to console clients. (Used for
                                    port forwarding.)
            @type  rosproxyPort:    int

            @param rootfsDir:       Filesystem path to the root directory of the
                                    container filesystem.
            @type  rootfsDir:       str

            @param confDir:         Filesystem path to the directory where
                                    container configuration files should be
                                    stored.
            @type  confDir:         str

            @param dataDir:         Filesystem path to the directory where
                                    temporary data of a container should be
                                    stored.
            @type  dataDir:         str

            @param pkgDir:          Filesystem paths to the package directories
                                    as a list of tuples where each tuple
                                    contains the path to the directory in the
                                    host machine and the path to the directory
                                    to which the host directory will be bound in
                                    the container filesystem (without the
                                    @param rootfsDir).
            @type  pkgDir:          [(str, str)]

            @param ubuntuRel:       Host filesystem Ubuntu release used in this
                                    machine.
            @type  ubuntuRel:       str

            @param rosRel:          Container filesytem ROS release in this
                                    deployment instance of the cloud engine
            @type  rosRel:          str

            @param data:            More data about the machine configuration.
            @type  data:            dict
        """
        self._reactor = reactor
        self._internalIP = intIP
        self._envPort = envPort
        self._rosproxyPort = rosproxyPort
        self._masterPort = masterPort

        if isLocalhost(masterIP):
            self._masterIP = bridgeIP
        else:
            self._masterIP = masterIP

        self._masterPasswd = masterPasswd
        self._infraPasswd = infraPasswd

        # Container directories
        self._rootfs = rootfsDir
        self._confDir = confDir
        self._dataDir = dataDir
        self._pkgDir = pkgDir

        # Release info
        self._ubuntuRel = ubuntuRel
        self._rosRel = rosRel

        for _, path in self._pkgDir:
            os.mkdir(os.path.join(self._rootfs, path))

        # Container info
        self._nrs = set(range(100, 200))
        self._containers = set()

        # Network configuration
        self._bridgeIF = bridgeIF
        self._bridgeIP = bridgeIP

        # Virtual network
        self._bridges = set()
        self._uid = {}

        # Physical parameters of machine
        # TODO: Is a human settings at this time,
        #       rce.util.sysinfo should fill this role soon
        self._size = data.get('size')
        self._cpu = data.get('cpu')
        self._memeory = data.get('memory')
        self._bandwidth = data.get('bandwidth')
        self._specialFeatures = data.get('special_features')

        # Common iptables references
        nat = iptc.Table(iptc.Table.NAT)
        self._prerouting = iptc.Chain(nat, 'PREROUTING')
        self._output = iptc.Chain(nat, 'OUTPUT')
Exemplo n.º 8
0
    def __init__(self, reactor, masterIP, masterPort, masterPasswd, infraPasswd,
                 bridgeIF, intIP, bridgeIP, envPort, rosproxyPort, rootfsDir,
                 confDir, dataDir, pkgDir, ubuntuRel, rosRel, data):
        """ Initialize the Container Client.

            @param reactor:         Reference to the twisted reactor.
            @type  reactor:         twisted::reactor

            @param masterIP:        IP address of the Master process.
            @type  masterIP:        str

            @param masterPort:      Port of the Master process used for internal
                                    communications.
            @type  masterPort:      int

            @param masterPasswd:    SHA 256 Digested Master Password.
            @type  masterPasswd:    str

            @param infraPasswd:     SHA 256 Digested Infra Password.
            @type  infraPasswd:     str

            @param bridgeIF:        Network interface used for the container
                                    communication.
            @type  bridgeIF:        str

            @param intIP:           IP address of the network interface used for
                                    the internal communication.
            @type  intIP:           str

            @param bridgeIP:        IP address of the network interface used for
                                    the container communication.
            @type  bridgeIP:        str

            @param envPort:         Port where the environment process running
                                    inside the container is listening for
                                    connections to other endpoints. (Used for
                                    port forwarding.)
            @type  envPort:         int

            @param rosproxyPort:    Port where the rosproxy process running
                                    inside the container is listening for
                                    connections to console clients. (Used for
                                    port forwarding.)
            @type  rosproxyPort:    int

            @param rootfsDir:       Filesystem path to the root directory of the
                                    container filesystem.
            @type  rootfsDir:       str

            @param confDir:         Filesystem path to the directory where
                                    container configuration files should be
                                    stored.
            @type  confDir:         str

            @param dataDir:         Filesystem path to the directory where
                                    temporary data of a container should be
                                    stored.
            @type  dataDir:         str

            @param pkgDir:          Filesystem paths to the package directories
                                    as a list of tuples where each tuple
                                    contains the path to the directory in the
                                    host machine and the path to the directory
                                    to which the host directory will be bound in
                                    the container filesystem (without the
                                    @param rootfsDir).
            @type  pkgDir:          [(str, str)]

            @param ubuntuRel:       Host filesystem Ubuntu release used in this
                                    machine.
            @type  ubuntuRel:       str

            @param rosRel:          Container filesytem ROS release in this
                                    deployment instance of the cloud engine
            @type  rosRel:          str

            @param data:            More data about the machine configuration.
            @type  data:            dict
        """
        self._reactor = reactor
        self._internalIP = intIP
        self._envPort = envPort
        self._rosproxyPort = rosproxyPort
        self._masterPort = masterPort

        if isLocalhost(masterIP):
            self._masterIP = bridgeIP
        else:
            self._masterIP = masterIP

        self._masterPasswd = masterPasswd
        self._infraPasswd = infraPasswd

        # Container directories
        self._rootfs = rootfsDir
        self._confDir = confDir
        self._dataDir = dataDir
        self._pkgDir = pkgDir

        # Release info
        self._ubuntuRel = ubuntuRel
        self._rosRel = rosRel

        for _, path in self._pkgDir:
            os.mkdir(os.path.join(self._rootfs, path))

        # Container info
        self._nrs = set(range(100, 200))
        self._containers = set()

        # Network configuration
        self._bridgeIF = bridgeIF
        self._bridgeIP = bridgeIP

        # Virtual network
        self._bridges = set()
        self._uid = {}

        # Physical parameters of machine
        # TODO: Is a human settings at this time,
        #       rce.util.sysinfo should fill this role soon
        self._size = data.get('size')
        self._cpu = data.get('cpu')
        self._memeory = data.get('memory')
        self._bandwidth = data.get('bandwidth')
        self._specialFeatures = data.get('special_features')

        # Common iptables references
        nat = iptc.Table(iptc.Table.NAT)
        self._prerouting = iptc.Chain(nat, 'PREROUTING')
        self._output = iptc.Chain(nat, 'OUTPUT')