Example #1
0
 def __init__(self, personality, status='new'):
     self.hostname = platform.node()
     self.ip_address_v4 = sys_assist.get_interface_ip()
     self.ip_address_v6 = ""
     self.personality = personality
     self.status = status
     self.system_info = SystemInfo()
Example #2
0
 def __init__(self, personality, status='new'):
     self.hostname = platform.node()
     self.ip_address_v4 = sys_assist.get_interface_ip()
     self.ip_address_v6 = ""
     self.personality = personality
     self.status = status
     self.system_info = SystemInfo()
Example #3
0
 def test_get_interface_ip_should_return_external_ip(self):
     with patch.object(sys_assist, 'get_interface_ip',
                       return_value='10.6.60.99'), \
         patch.object(sys_assist.socket, 'gethostbyname',
                      return_value='127.0.0.1'):
         ip = sys_assist.get_interface_ip()
         self.assertEqual(ip, '10.6.60.99')
Example #4
0
 def test_get_interface_ip(self):
     with patch.object(sys_assist.socket, 'socket',
                       MagicMock()), \
         patch.object(sys_assist.fcntl, 'ioctl',
                      MagicMock()), \
         patch.object(sys_assist.socket, 'inet_ntoa',
                      return_value='10.6.60.95'):
         ip = sys_assist.get_interface_ip('etho0')
         self.assertEqual(ip, '10.6.60.95')
Example #5
0
    def __init__(self, personality='worker', **kwargs):
        """
        The init function accepts **kwargs so that a Worker object can be
        constructed from its dictionary representation or from a
        WorkerRegistration object's dictionary representation.
        """

        if kwargs:
            self._id = kwargs.get('_id')
            self.hostname = kwargs['hostname']
            self.ip_address_v4 = kwargs['ip_address_v4']
            self.ip_address_v6 = kwargs['ip_address_v6']
            self.personality = personality
            self.status = kwargs['status']
            self.system_info = SystemInfo(**kwargs['system_info'])
        else:
            self.hostname = platform.node()
            self.ip_address_v4 = sys_assist.get_interface_ip()
            self.ip_address_v6 = ""
            self.personality = personality
            self.status = "online"
            self.system_info = SystemInfo()
Example #6
0
    def __init__(self, personality="worker", **kwargs):
        """
        The init function accepts **kwargs so that a Worker object can be
        constructed from its dictionary representation or from a
        WorkerRegistration object's dictionary representation.
        """

        if kwargs:
            self._id = kwargs.get("_id")
            self.hostname = kwargs["hostname"]
            self.ip_address_v4 = kwargs["ip_address_v4"]
            self.ip_address_v6 = kwargs["ip_address_v6"]
            self.personality = personality
            self.status = kwargs["status"]
            self.system_info = SystemInfo(**kwargs["system_info"])
        else:
            self.hostname = platform.node()
            self.ip_address_v4 = sys_assist.get_interface_ip()
            self.ip_address_v6 = ""
            self.personality = personality
            self.status = "online"
            self.system_info = SystemInfo()
Example #7
0
 def test_get_lan_ip_should_return_localhost(self):
     with patch.object(sys_assist.socket, 'gethostbyname',
                       return_value='127.0.0.1'):
         ip = sys_assist.get_interface_ip('ABC9')
         self.assertEqual(ip, '127.0.0.1')