Exemple #1
0
    def test_get(self, mock_request_get):
        mock_reader = mock.MagicMock()
        mock_reader.__iter__.return_value = ['a', 'b', 'c']
        mock_response = mock.MagicMock()
        mock_response.iter_content.return_value = mock_reader
        mock_request_get.return_value = mock_response

        self.assertEqual('abc', urlfetch.get('http://example.com'))
Exemple #2
0
 def _get_manifest(self):
     if not self.manifest and not self.manifest_url:
         return None
     if self.manifest:
         return self.manifest
     if self.manifest_url:
         self.manifest = urlfetch.get(self.manifest_url)
         return self.manifest
Exemple #3
0
 def _get_manifest(self):
     if not self.manifest and not self.manifest_url:
         return None
     if self.manifest:
         return self.manifest
     if self.manifest_url:
         self.manifest = urlfetch.get(self.manifest_url)
         return self.manifest
Exemple #4
0
    def test_get(self,
                 mock_request_get):
        mock_reader = mock.MagicMock()
        mock_reader.__iter__.return_value = ['a', 'b', 'c']
        mock_response = mock.MagicMock()
        mock_response.iter_content.return_value = mock_reader
        mock_request_get.return_value = mock_response

        self.assertEqual('abc', urlfetch.get('http://example.com'))
Exemple #5
0
 def _get_manifest(self):
     if not self.manifest and not self.manifest_url:
         return None
     if self.manifest is not wsme.Unset and self.manifest is not None:
         return self.manifest
     if (self.manifest_url is not wsme.Unset
             and self.manifest_url is not None):
         self.manifest = urlfetch.get(self.manifest_url)
         return self.manifest
Exemple #6
0
 def _get_manifest(self):
     if not self.manifest and not self.manifest_url:
         return None
     if self.manifest is not wsme.Unset and self.manifest is not None:
         return self.manifest
     if (self.manifest_url is not wsme.Unset
             and self.manifest_url is not None):
         self.manifest = urlfetch.get(self.manifest_url)
         return self.manifest
Exemple #7
0
 def pull_data(self):
     mesos_master_url = self._build_url(self.bay.api_address,
                                        port='5050',
                                        path='/state')
     state_json = jsonutils.loads(urlfetch.get(mesos_master_url))
     self.data['mem_total'] = 0
     self.data['mem_used'] = 0
     for slave in state_json['slaves']:
         self.data['mem_total'] += slave['resources']['mem']
         self.data['mem_used'] += slave['used_resources']['mem']
Exemple #8
0
 def pull_data(self):
     mesos_master_url = self._build_url(self.bay.api_address,
                                        port='5050',
                                        path='/state')
     state_json = jsonutils.loads(urlfetch.get(mesos_master_url))
     self.data['mem_total'] = 0
     self.data['mem_used'] = 0
     for slave in state_json['slaves']:
         self.data['mem_total'] += slave['resources']['mem']
         self.data['mem_used'] += slave['used_resources']['mem']
Exemple #9
0
 def pull_data(self):
     self.data['mem_total'] = 0
     self.data['mem_used'] = 0
     for master_addr in self.bay.master_addresses:
         mesos_master_url = self._build_url(master_addr, port='5050',
                                            path='/state')
         master = jsonutils.loads(urlfetch.get(mesos_master_url))
         if self._is_leader(master):
             for slave in master['slaves']:
                 self.data['mem_total'] += slave['resources']['mem']
                 self.data['mem_used'] += slave['used_resources']['mem']
             break