'Test list_nodes functionality.'

def test_list_nodes(self):

    nodes = self.driver.list_nodes()
    self.assertEqual(len(nodes), 3)
    node = nodes[0]
    self.assertEqual(node.id, '5')
    self.assertEqual(node.name, 'Compute    5')
    self.assertEqual(node.state, OpenNebulaNodeDriver.NODE_STATE_MAP['ACTIVE'])
    self.assertEqual(node.public_ips[0].id, '5')
    self.assertEqual(node.public_ips[0].name, None)
    self.assertEqual(node.public_ips[0].address, '192.168.0.1')
    self.assertEqual(node.public_ips[0].size, 1)
    self.assertEqual(node.public_ips[1].id, '15')
    self.assertEqual(node.public_ips[1].name, None)
    self.assertEqual(node.public_ips[1].address, '192.168.1.1')
    self.assertEqual(node.public_ips[1].size, 1)
    self.assertEqual(node.private_ips, [])
    self.assertEqual(node.image.id, '5')
    self.assertEqual(node.image.extra['dev'], 'sda1')
    node = nodes[1]
    self.assertEqual(node.id, '15')
    self.assertEqual(node.name, 'Compute    15')
    self.assertEqual(node.state, OpenNebulaNodeDriver.NODE_STATE_MAP['ACTIVE'])
    self.assertEqual(node.public_ips[0].id, '5')
    self.assertEqual(node.public_ips[0].name, None)
    self.assertEqual(node.public_ips[0].address, '192.168.0.2')
    self.assertEqual(node.public_ips[0].size, 1)
    self.assertEqual(node.public_ips[1].id, '15')
    self.assertEqual(node.public_ips[1].name, None)
    self.assertEqual(node.public_ips[1].address, '192.168.1.2')
    self.assertEqual(node.public_ips[1].size, 1)
    self.assertEqual(node.private_ips, [])
    self.assertEqual(node.image.id, '15')
    self.assertEqual(node.image.extra['dev'], 'sda1')
    node = nodes[2]
    self.assertEqual(node.id, '25')
    self.assertEqual(node.name, 'Compute    25')
    self.assertEqual(node.state, NodeState.UNKNOWN)
    self.assertEqual(node.public_ips[0].id, '5')
    self.assertEqual(node.public_ips[0].name, None)
    self.assertEqual(node.public_ips[0].address, '192.168.0.3')
    self.assertEqual(node.public_ips[0].size, 1)
    self.assertEqual(node.public_ips[1].id, '15')
    self.assertEqual(node.public_ips[1].name, None)
    self.assertEqual(node.public_ips[1].address, '192.168.1.3')
    self.assertEqual(node.public_ips[1].size, 1)
    self.assertEqual(node.private_ips, [])
    self.assertEqual(node.image, None)
