コード例 #1
0
ファイル: test_compute_node.py プロジェクト: hsluoyz/patron
 def test_recreate_fails(self):
     self.mox.StubOutWithMock(db, 'compute_node_create')
     db.compute_node_create(self.context, {'service_id': 456}).AndReturn(
         fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode(context=self.context)
     compute.service_id = 456
     compute.create()
     self.assertRaises(exception.ObjectActionError, compute.create,
                       self.context)
コード例 #2
0
 def test_recreate_fails(self):
     self.mox.StubOutWithMock(db, 'compute_node_create')
     db.compute_node_create(self.context, {
         'service_id': 456
     }).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode(context=self.context)
     compute.service_id = 456
     compute.create()
     self.assertRaises(exception.ObjectActionError, compute.create,
                       self.context)
コード例 #3
0
    def _create_compute_service(self):
        """Create compute-manager(ComputeNode and Service record)."""
        ctxt = self.req.environ["patron.context"]
        dic = {'host': 'dummy', 'binary': 'patron-compute', 'topic': 'compute',
               'report_count': 0}
        s_ref = db.service_create(ctxt, dic)

        dic = {'service_id': s_ref['id'],
               'host': s_ref['host'],
               'vcpus': 16, 'memory_mb': 32, 'local_gb': 100,
               'vcpus_used': 16, 'memory_mb_used': 32, 'local_gb_used': 10,
               'hypervisor_type': 'qemu', 'hypervisor_version': 12003,
               'cpu_info': '', 'stats': ''}
        db.compute_node_create(ctxt, dic)

        return db.service_get(ctxt, s_ref['id'])
コード例 #4
0
ファイル: compute_node.py プロジェクト: hsluoyz/patron
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')
        updates = self.obj_get_changes()
        self._convert_stats_to_db_format(updates)
        self._convert_host_ip_to_db_format(updates)
        self._convert_supported_instances_to_db_format(updates)
        self._convert_pci_stats_to_db_format(updates)

        db_compute = db.compute_node_create(self._context, updates)
        self._from_db_object(self._context, self, db_compute)
コード例 #5
0
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')
        updates = self.obj_get_changes()
        self._convert_stats_to_db_format(updates)
        self._convert_host_ip_to_db_format(updates)
        self._convert_supported_instances_to_db_format(updates)
        self._convert_pci_stats_to_db_format(updates)

        db_compute = db.compute_node_create(self._context, updates)
        self._from_db_object(self._context, self, db_compute)
コード例 #6
0
 def test_create(self):
     self.mox.StubOutWithMock(db, 'compute_node_create')
     db.compute_node_create(
         self.context, {
             'service_id': 456,
             'stats': fake_stats_db_format,
             'host_ip': fake_host_ip,
             'supported_instances': fake_supported_hv_specs_db_format,
         }).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode(context=self.context)
     compute.service_id = 456
     compute.stats = fake_stats
     # NOTE (pmurray): host_ip is coerced to an IPAddress
     compute.host_ip = fake_host_ip
     compute.supported_hv_specs = fake_supported_hv_specs
     compute.create()
     self.compare_obj(compute,
                      fake_compute_node,
                      subs=self.subs(),
                      comparators=self.comparators())
コード例 #7
0
ファイル: test_compute_node.py プロジェクト: hsluoyz/patron
 def test_create(self):
     self.mox.StubOutWithMock(db, 'compute_node_create')
     db.compute_node_create(
         self.context,
         {
             'service_id': 456,
             'stats': fake_stats_db_format,
             'host_ip': fake_host_ip,
             'supported_instances': fake_supported_hv_specs_db_format,
         }).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode(context=self.context)
     compute.service_id = 456
     compute.stats = fake_stats
     # NOTE (pmurray): host_ip is coerced to an IPAddress
     compute.host_ip = fake_host_ip
     compute.supported_hv_specs = fake_supported_hv_specs
     compute.create()
     self.compare_obj(compute, fake_compute_node,
                      subs=self.subs(),
                      comparators=self.comparators())