def test_assert_node_raise(self): model = model_root.BaremetalModelRoot() node_uuid = uuidutils.generate_uuid() node = element.IronicNode(uuid=node_uuid) model.add_node(node) self.assertRaises(exception.IllegalArgumentException, model.assert_node, "obj")
def test_remove_node(self): model = model_root.BaremetalModelRoot() node_uuid = uuidutils.generate_uuid() node = element.IronicNode(uuid=node_uuid) model.add_node(node) self.assertEqual(node, model.get_node_by_uuid(node_uuid)) model.remove_node(node) self.assertRaises(exception.IronicNodeNotFound, model.get_node_by_uuid, node_uuid)
def from_xml(cls, data): model = cls() root = etree.fromstring(data) for cn in root.findall('.//IronicNode'): node = element.IronicNode(**cn.attrib) model.add_node(node) return model
def test_get_all_ironic_nodes(self): model = model_root.BaremetalModelRoot() for i in range(10): node_uuid = uuidutils.generate_uuid() node = element.IronicNode(uuid=node_uuid) model.add_node(node) all_nodes = model.get_all_ironic_nodes() for node_uuid in all_nodes: node = model.get_node_by_uuid(node_uuid) model.assert_node(node)
def build_ironic_node(self, node): """Build a Baremetal node from a Ironic node :param node: A ironic node :type node: :py:class:`~ironicclient.v1.node.Node` """ # build up the ironic node. node_attributes = { "uuid": node.uuid, "power_state": node.power_state, "maintenance": node.maintenance, "maintenance_reason": node.maintenance_reason, "extra": {"compute_node_id": node.extra.compute_node_id} } ironic_node = element.IronicNode(**node_attributes) return ironic_node
def build_scenario_1(self): model = modelroot.BaremetalModelRoot() # number of nodes node_count = 2 for i in range(0, node_count): uuid = utils.generate_uuid() node_attributes = { "uuid": uuid, "power_state": "power on", "maintenance": "false", "maintenance_reason": "null", "extra": {"compute_node_id": i} } node = element.IronicNode(**node_attributes) model.add_node(node) return model
def test_add_node(self): model = model_root.BaremetalModelRoot() node_uuid = uuidutils.generate_uuid() node = element.IronicNode(uuid=node_uuid) model.add_node(node) self.assertEqual(node, model.get_node_by_uuid(node_uuid))