Example #1
0
    def _pair_with_coordinator(self, api_secret, coordinator_uri, personality):

        #get registration info and call the coordinator
        worker_registration = WorkerRegistration(personality)
        registration = {'worker_registration': worker_registration.format()}

        auth_header = {'X-AUTH-TOKEN': api_secret}

        #register with coordinator
        if self._register_with_coordinator(coordinator_uri, personality,
                                           registration, auth_header):
            server = NativeProxy()
            server.restart()
Example #2
0
    def _pair_with_coordinator(self, api_secret, coordinator_uri, personality):

        #get registration info and call the coordinator
        worker_registration = WorkerRegistration(personality)
        registration = {'worker_registration': worker_registration.format()}

        auth_header = {'X-AUTH-TOKEN': api_secret}

        #register with coordinator
        if self._register_with_coordinator(
                coordinator_uri, personality, registration, auth_header):
            server = NativeProxy()
            server.restart()
Example #3
0
    def before(self):
        self.status = 'online'
        self.system_info = SystemInfo().format()
        self.worker_status = {
            'worker_status': {
                'system_info': self.system_info,
                'status': self.status
            }
        }

        self.bad_status = 'bad_status'
        self.bad_system_info = SystemInfo()
        self.bad_worker_status = {
            'worker_status': {
                'system_info': self.system_info,
                'status': self.bad_status
            }
        }

        self.req = MagicMock()
        self.resp = MagicMock()
        self.registration = WorkerRegistration('worker').format()
        self.worker_dict = Worker(**self.registration).format()
        self.worker_not_found = None
        self.db_handler = MagicMock()
        self.resource = WorkerStatusResource(self.db_handler)
        self.worker_id = '51375fc4eea50d53066292b6'
        self.test_route = '/v1/worker/{worker_id}/status'
        self.api.add_route(self.test_route, self.resource)
Example #4
0
 def setUp(self):
     self.req = MagicMock()
     self.resp = MagicMock()
     self.db_handler = MagicMock()
     self.resource = WorkersStatusResource(self.db_handler)
     self.registration = WorkerRegistration('worker').format()
     self.worker = Worker(**self.registration)
     self.worker_dict = Worker(**self.registration).format()
Example #5
0
    def before(self):

        self.db_handler = MagicMock()
        self.resource = WorkerRegistrationResource(self.db_handler)
        self.body = {'worker_registration':
                     WorkerRegistration('worker').format()}
        self.body_bad_personality = {'worker_registration':
                                     WorkerRegistration(
                                         'bad_personality').format()}

        self.body_bad = {'worker_registration': 'bad_registration'}
        self.req = MagicMock()
        self.req.content_type = 'application/json'
        self.req.stream.read.return_value = jsonutils.dumps(self.body)
        self.resp = MagicMock()
        self.test_route = '/v1/pairing'
        self.api.add_route(self.test_route, self.resource)
Example #6
0
 def setUp(self):
     self.req = MagicMock()
     self.resp = MagicMock()
     self.db_handler = MagicMock()
     self.resource = WorkerStatusResource(self.db_handler)
     self.registration = WorkerRegistration('worker').format()
     self.worker = Worker(**self.registration)
     self.worker_dict = Worker(**self.registration).format()
     self.worker_id = '51375fc4eea50d53066292b6'
     self.worker_not_found = None
Example #7
0
class WhenTestingWorkerRegistrationObject(unittest.TestCase):
    def setUp(self):
        self.worker_reg = WorkerRegistration('correlation', 'new')

    def test_WorkerRegistration_new(self):
        worker_dict = self.worker_reg.format()
        self.assertTrue('hostname' in worker_dict)
        self.assertTrue('ip_address_v4' in worker_dict)
        self.assertTrue('ip_address_v6' in worker_dict)
        self.assertTrue('personality' in worker_dict)
        self.assertTrue('status' in worker_dict)
        self.assertTrue('system_info' in worker_dict)
Example #8
0
class WhenTestingWorkerRegistrationObject(unittest.TestCase):
    def setUp(self):
        self.worker_reg = WorkerRegistration('correlation', 'new')

    def test_WorkerRegistration_new(self):
        worker_dict = self.worker_reg.format()
        self.assertTrue('hostname' in worker_dict)
        self.assertTrue('ip_address_v4' in worker_dict)
        self.assertTrue('ip_address_v6' in worker_dict)
        self.assertTrue('personality' in worker_dict)
        self.assertTrue('status' in worker_dict)
        self.assertTrue('system_info' in worker_dict)
    def setUp(self):
        self.api_secret = "3F2504E0-4F89-11D3-9A0C-0305E82C3301"
        self.coordinator_uri = "http://localhost:8080/v1"
        self.personality = 'normalization'
        self.pairing_process = PairingProcess(self.api_secret,
                                              self.coordinator_uri,
                                              self.personality)
        self.native_proxy = MagicMock()
        self.get_config = WorkerConfiguration(
            personality='pairing',
            personality_module='meniscus.personas.pairing.app',
            worker_token='token_id',
            worker_id='worker_id',
            coordinator_uri="192.168.1.1:8080/v1")

        self.resp = requests.Response()
        self.http_request = MagicMock(return_value=self.resp)
        self.registration = WorkerRegistration(personality='correlation')\
            .format()
Example #10
0
 def setUp(self):
     self.worker_reg = WorkerRegistration('correlation', 'new')
Example #11
0
 def setUp(self):
     self.worker_reg = WorkerRegistration('correlation', 'new')
Example #12
0
 def setUp(self):
     self.db_handler = MagicMock()
     self.worker_id = "0123456789"
     self.req = MagicMock()
     self.resp = MagicMock()
     self.body_bad_header = {'worker':
                             WorkerRegistration('correlation').format()}
     self.body_bad_personality = {'worker_registration':
                                  WorkerRegistration(
                                      'bad_personality').format()}
     self.new_status = 'offline'
     self.new_bad_status = 'bad_status'
     self.system_info = SystemInfo()
     self.worker_dict = {"worker_id": self.worker_id,
                         "hostname": "worker-01",
                         "callback": "192.168.100.101:8080/v1/callback/",
                         "ip_address_v4": "192.168.100.101",
                         "ip_address_v6": "::1",
                         "personality": "worker.storage",
                         "status": "draining",
                         "system_info": {
                             "os_type": "Darwin-11.4.2-x86_64-i386-64bit",
                             "memory_mb": "1024",
                             "architecture": "",
                             "cpu_cores": "4",
                             "load_average": "0.234353456",
                             "disk_usage": {
                                 "/dev/sda1": {
                                     "total": 313764528,
                                     "used": 112512436
                                 }
                             }
                         }
                         }
     self.worker = Worker(_id='010101',
                          worker_id=self.worker_id,
                          worker_token='9876543210',
                          hostname='worker01',
                          callback='172.22.15.25:8080/v1/config/',
                          ip_address_v4='172.23.1.100',
                          ip_address_v6='::1',
                          personality='correlation',
                          status='online',
                          system_info=self.system_info.format())
     self.worker_list = [
         {"hostname": "worker-01",
          "callback": "192.168.100.101:8080/v1/callback/",
          "ip_address_v4": "192.168.100.101",
          "ip_address_v6": "::1",
          "personality": "storage",
          "status": "draining",
          "system_info": {
              "os_type": "Darwin-11.4.2-x86_64-i386-64bit",
              "memory_mb": "1024",
              "architecture": "",
              "cpu_cores": "4",
              "load_average": "0.234353456",
              "disk_usage": {
                  "/dev/sda1": {
                      "total": 313764528,
                      "used": 112512436
                  }}}},
         {"hostname": "worker-01",
          "callback": "192.168.100.101:8080/v1/callback/",
          "ip_address_v4": "192.168.100.101",
          "ip_address_v6": "::1",
          "personality": "storage",
          "status": "online",
          "system_info": {
              "os_type": "Darwin-11.4.2-x86_64-i386-64bit",
              "memory_mb": "1024",
              "architecture": "",
              "cpu_cores": "4",
              "load_average": "0.234353456",
              "disk_usage": {
                  "/dev/sda1": {
                      "total": 313764528,
                      "used": 112512436
                  }}}},
         {'hostname': "worker-01",
          "callback": "192.168.100.101:8080/v1/callback/",
          "ip_address_v4": "192.168.100.101",
          "ip_address_v6": "::1",
          "personality": "normalization",
          "status": "draining",
          "system_info": {
              "os_type": "Darwin-11.4.2-x86_64-i386-64bit",
              "memory_mb": "1024",
              "architecture": "",
              "cpu_cores": "4",
              "load_average": "0.234353456",
              "disk_usage": {
                  "/dev/sda1": {
                      "total": 313764528,
                      "used": 112512436
                  }}}}]