コード例 #1
0
ファイル: test_vmhosts.py プロジェクト: emonty/healthnmon
 def test_vmhost_identifier_xml(self):
     request = webob.Request.blank(
         '/v2.0/vmhosts/host-01.xml?fields=storagevolume',
         base_url='http://localhost:8774/v2.0/')
     request.environ['nova.context'] = self.admin_context
     item_list = self.get_host_list()
     self.assertEquals(
         VmHostsController()._show(request, item_list[0]).body,
         self.expected_identifier_show_xml)
     self.assertEquals(
         VmHostsController()._detail(request, item_list, []).body,
         self.expected_identifier_detail_xml)
コード例 #2
0
ファイル: test_vmhosts.py プロジェクト: emonty/healthnmon
 def test_list_vmhost_none_check(self):
     self.mock.StubOutWithMock(api, 'vm_host_get_all_by_filters')
     api.vm_host_get_all_by_filters(mox.IgnoreArg(), mox.IgnoreArg(),
                                    mox.IgnoreArg(),
                                    mox.IgnoreArg()).AndReturn(None)
     self.mock.ReplayAll()
     request = webob.Request.blank('/v2.0/vmhosts',
                                   base_url='http://localhost:8774/v2.0/')
     request.environ['nova.context'] = self.admin_context
     resp = VmHostsController().index(request)
     self.assertEqual(resp.body, '{"vmhosts": []}', 'Return json string')
コード例 #3
0
ファイル: test_vmhosts.py プロジェクト: emonty/healthnmon
    def test_host_details_none_xml(self):
        hosts = None
        self.mock.StubOutWithMock(api, 'vm_host_get_by_ids')

        api.vm_host_get_by_ids(mox.IgnoreArg(),
                               mox.IgnoreArg()).AndReturn(hosts)
        self.mock.ReplayAll()
        request = webob.Request.blank('/v2.0/vmhosts/host-01.xml',
                                      base_url='http://localhost:8774/v2.0/')
        request.environ['nova.context'] = self.admin_context
        resp = VmHostsController().show(request, 'host-01')
        self.assertNotEqual(resp, None, 'Return xml response for host-01')
コード例 #4
0
ファイル: test_vmhosts.py プロジェクト: emonty/healthnmon
 def test_list_hosts_none_detail_xml(self):
     hosts = None
     self.mock.StubOutWithMock(api, 'vm_host_get_all_by_filters')
     api.vm_host_get_all_by_filters(mox.IgnoreArg(), mox.IgnoreArg(),
                                    mox.IgnoreArg(),
                                    mox.IgnoreArg()).AndReturn(hosts)
     self.mock.ReplayAll()
     request = webob.Request.blank('/v2.0/vmhosts/detail.xml',
                                   base_url='http://localhost:8774/v2.0/')
     request.environ['nova.context'] = self.admin_context
     resp = VmHostsController().detail(request)
     self.assertNotEqual(resp, None, 'Return xml string')
コード例 #5
0
ファイル: test_vmhosts.py プロジェクト: emonty/healthnmon
    def test_host_details_json(self):
        hosts = self.get_single_host()
        self.mock.StubOutWithMock(api, 'vm_host_get_by_ids')

        api.vm_host_get_by_ids(mox.IgnoreArg(),
                               mox.IgnoreArg()).AndReturn(hosts)
        self.mock.ReplayAll()
        request = webob.Request.blank('/v2.0/vmhosts/host-01.json',
                                      base_url='http://localhost:8774/v2.0/')
        request.environ['nova.context'] = self.admin_context
        resp = VmHostsController().show(request, 'host-01')
        self.assertNotEqual(resp, None, 'Return json response for host-01')
        self.assertEqual(self.expected_limited_detail_json, resp.body)
コード例 #6
0
ファイル: test_vmhosts.py プロジェクト: emonty/healthnmon
 def test_list_hosts_limited_xml(self):
     hosts = self.get_limited_list(3)
     self.mock.StubOutWithMock(api, 'vm_host_get_all_by_filters')
     api.vm_host_get_all_by_filters(mox.IgnoreArg(), mox.IgnoreArg(),
                                    mox.IgnoreArg(),
                                    mox.IgnoreArg()).AndReturn(hosts)
     self.mock.ReplayAll()
     request = webob.Request.blank(
         '/v2.0/vmhosts.xml?limit=1&marker=host-1',
         base_url='http://localhost:8774/v2.0/')
     request.environ['nova.context'] = self.admin_context
     resp = VmHostsController().index(request)
     self.assertEqual(resp.body, self.expected_index_limited_xml)
コード例 #7
0
ファイル: test_vmhosts.py プロジェクト: emonty/healthnmon
 def test_list_hosts_json(self):
     hosts = self.get_host_list()
     self.mock.StubOutWithMock(api, 'vm_host_get_all_by_filters')
     api.vm_host_get_all_by_filters(mox.IgnoreArg(), mox.IgnoreArg(),
                                    mox.IgnoreArg(),
                                    mox.IgnoreArg()).AndReturn(hosts)
     self.mock.ReplayAll()
     request = webob.Request.blank('/v2.0/vmhosts.json',
                                   base_url='http://localhost:8774/v2.0/')
     request.environ['nova.context'] = self.admin_context
     resp = VmHostsController().index(request)
     self.assertNotEqual(resp, None, 'Return json string')
     self.assertEqual(self.expected_index_json, resp.body)
コード例 #8
0
ファイル: test_vmhosts.py プロジェクト: emonty/healthnmon
 def test_list_host_details_limited_json(self):
     hosts = self.get_host_list()
     self.mock.StubOutWithMock(api, 'vm_host_get_all_by_filters')
     api.vm_host_get_all_by_filters(mox.IgnoreArg(), mox.IgnoreArg(),
                                    mox.IgnoreArg(),
                                    mox.IgnoreArg()).AndReturn(hosts)
     self.mock.ReplayAll()
     request = webob.Request.blank(
         '/v2.0/vmhosts/detail?limit=1&marker=host-01',
         base_url='http://localhost:8774/v2.0/')
     request.environ['nova.context'] = self.admin_context
     resp = VmHostsController().detail(request)
     self.assertNotEqual(resp, None)
     self.assertEqual(self.expected_detail_limit_marker_json, resp.body)
コード例 #9
0
ファイル: test_vmhosts.py プロジェクト: emonty/healthnmon
    def test_host_details_json_exception(self):
        hosts = self.get_host_list()
        xml_utils = util
        self.mock.StubOutWithMock(xml_utils, 'xml_to_dict')
        xml_utils.xml_to_dict(mox.IgnoreArg()).AndRaise(
            Exception('Test Exception'))
        self.mock.StubOutWithMock(api, 'vm_host_get_by_ids')

        api.vm_host_get_by_ids(mox.IgnoreArg(),
                               mox.IgnoreArg()).AndReturn(hosts)
        self.mock.ReplayAll()
        request = webob.Request.blank('/v2.0/vmhosts/host-01.json',
                                      base_url='http://localhost:8774/v2.0/')
        request.environ['nova.context'] = self.admin_context
        resp = VmHostsController().show(request, 'host-01')
        self.assertTrue(isinstance(resp, HTTPNotFound))
コード例 #10
0
ファイル: test_vmhosts.py プロジェクト: emonty/healthnmon
    def test_utilization_query(self):
        hosts = self.get_single_host()
        self.mock.StubOutWithMock(api, 'vm_host_get_by_ids')

        api.vm_host_get_by_ids(mox.IgnoreArg(),
                               mox.IgnoreArg()).AndReturn(hosts)
        self.mock.StubOutWithMock(rpc, 'call')

        rpc.call(mox.IgnoreArg(), mox.IgnoreArg(),
                 mox.IgnoreArg()).AndReturn(self.get_resource_utilization())
        self.mock.ReplayAll()
        request = \
            webob.Request.blank('/v2.0/vmhosts/host-01.xml?utilization',
                                base_url='http://localhost:8774/v2.0/')

        request.environ['nova.context'] = self.admin_context
        resp = VmHostsController().show(request, 'host-01')
        self.assertNotEqual(resp, None, 'Return xml response for host-01')
        self.assertEqual(self.expected_utilization_xml, resp.body)