Esempio 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()
Esempio 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()
Esempio n. 3
0
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing, software
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.
#
#     \author/s: Dominique Hunziker
#
#

# rce specific imports
from rce.util.settings import getSettings

settings = getSettings()


def isLocalhost(ip):
    """ Check if the IP address matches the loopback address.

        @param ip:          IP address which should be checked
        @type  ip:          str

        @return:            True if the address is the loopback address;
                            False otherwise.
        @rtype:             bool
    """
    return ip in (settings.localhost_IP, 'localhost')
Esempio n. 4
0
    from cStringIO import StringIO, InputType, OutputType
    from StringIO import StringIO as pyStringIO

    def _checkIsStringIO(obj):
        return isinstance(obj, (InputType, OutputType, pyStringIO))
except ImportError:
    from StringIO import StringIO

    def _checkIsStringIO(obj):
        return isinstance(obj, StringIO)

# rce specific imports
from rce.util.error import InternalError
from rce.slave.interface import Interface, InvalidResoureName
from rce.util.settings import getSettings
settings = getSettings()


class ConversionError(Exception):
    """ Exception is raised in case a ROS message could not be converted.
    """


class ServiceError(Exception):
    """ Exception is raised in case a response message was received, but not
        corresponding request is available.
    """


class _AbstractConverter(Interface):
    """ Abstract base class which provides the basics for the robot-side
Esempio 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)