'Test create_node functionality.'

def test_create_node(self):

    image = NodeImage(id=5, name='Ubuntu    9.04    LAMP', driver=self.driver)
    size = OpenNebulaNodeSize(id=1, name='small', ram=1024, cpu=1, disk=None, bandwidth=None, price=None, driver=self.driver)
    networks = list()
    networks.append(OpenNebulaNetwork(id=5, name='Network    5', address='192.168.0.0', size=256, driver=self.driver))
    networks.append(OpenNebulaNetwork(id=15, name='Network    15', address='192.168.1.0', size=256, driver=self.driver))
    context = {'hostname': 'compute-5'}
    node = self.driver.create_node(name='Compute    5', image=image, size=size, networks=networks, context=context)
    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, 'Network    5')
    self.assertEqual(node.public_ips[0].address, '192.168.0.1')
    self.assertEqual(node.public_ips[0].size, 1)
    self.assertEqual(node.public_ips[0].extra['mac'], '02:00:c0:a8:00:01')
    self.assertEqual(node.public_ips[1].id, '15')
    self.assertEqual(node.public_ips[1].name, 'Network    15')
    self.assertEqual(node.public_ips[1].address, '192.168.1.1')
    self.assertEqual(node.public_ips[1].size, 1)
    self.assertEqual(node.public_ips[1].extra['mac'], '02:00:c0:a8:01:01')
    self.assertEqual(node.private_ips, [])
    self.assertTrue((len([s for s in self.driver.list_sizes() if (s.id == node.size.id)]) == 1))
    self.assertEqual(node.image.id, '5')
    self.assertEqual(node.image.name, 'Ubuntu    9.04    LAMP')
    self.assertEqual(node.image.extra['type'], 'DISK')
    self.assertEqual(node.image.extra['target'], 'hda')
    context = node.extra['context']
    self.assertEqual(context['hostname'], 'compute-5')
