示例#1
0
    def test_node_list_unracked(self):
        nodes = self.baremetalclient_nodes.list()
        all_nodes = self.baremetalclient_nodes_all.list()
        racks = self.tuskarclient_racks.list()

        self.mox.StubOutWithMock(baremetal.BareMetalNodeManager, 'list')
        baremetal.BareMetalNodeManager.list().AndReturn(all_nodes)

        tuskarclient = self.stub_tuskarclient()
        tuskarclient.racks = self.mox.CreateMockAnything()
        tuskarclient.racks.list().MultipleTimes().AndReturn(racks)

        novaclient = self.stub_novaclient()
        novaclient.servers = self.mox.CreateMockAnything()
        novaclient.servers.list(True,
                                {'all_tenants': True,
                                 'limit': 21}).MultipleTimes().AndReturn([])

        self.mox.StubOutWithMock(baremetal.BareMetalNodeManager, 'get')
        for n in nodes:
            baremetal.BareMetalNodeManager.get(n.id).\
                MultipleTimes().AndReturn(n)
        self.mox.ReplayAll()

        ret_val = Node.list_unracked(self.request)
        for node in ret_val:
            self.assertIsInstance(node, Node)
        self.assertEquals(1, len(ret_val))
示例#2
0
    def test_node_create(self):
        node = self.baremetalclient_nodes.first()

        self.mox.StubOutWithMock(baremetal.BareMetalNodeManager, 'create')
        baremetal.BareMetalNodeManager.create('node',
                                              1,
                                              1024,
                                              10,
                                              'aa:bb:cc:dd:ee',
                                              '0.0.0.0',
                                              'user',
                                              'password',
                                              0).AndReturn(node)
        self.mox.ReplayAll()

        ret_val = Node.create(self.request,
                              name='node',
                              cpus=1,
                              memory_mb=1024,
                              local_gb=10,
                              prov_mac_address='aa:bb:cc:dd:ee',
                              pm_address='0.0.0.0',
                              pm_user='******',
                              pm_password='******',
                              terminal_port=0)
        self.assertIsInstance(ret_val, Node)
示例#3
0
    def test_node_list(self):
        nodes = self.baremetalclient_nodes_all.list()

        self.mox.StubOutWithMock(baremetal.BareMetalNodeManager, 'list')
        baremetal.BareMetalNodeManager.list().AndReturn(nodes)
        self.mox.ReplayAll()

        ret_val = Node.list(self.request)
        for node in ret_val:
            self.assertIsInstance(node, Node)
示例#4
0
    def test_node_get(self):
        node = self.baremetalclient_nodes.first()

        self.mox.StubOutWithMock(baremetal.BareMetalNodeManager, 'get')
        baremetal.BareMetalNodeManager.get(node.id).AndReturn(node)

        novaclient = self.stub_novaclient()
        novaclient.servers = self.mox.CreateMockAnything()
        novaclient.servers.list(True,
                                {'all_tenants': True,
                                 'limit': 21}).AndReturn([])
        self.mox.ReplayAll()

        ret_val = Node.get(self.request, node.id)
        self.assertIsInstance(ret_val, Node)