def test_create_new_nvset_if_does_not_exist(self): root = etree.Element("root", id="root") nvpair.arrange_first_nvset( "nvset", root, { "attr": "10", "new_one": "20", "test": "0", "attr2": "" }, self.id_provider, ) assert_xml_equal( """ <root id="root"> <nvset id="root-nvset"> <nvpair id="root-nvset-attr" name="attr" value="10"/> <nvpair id="root-nvset-new_one" name="new_one" value="20"/> <nvpair id="root-nvset-test" name="test" value="0"/> </nvset> </root> """, etree_to_str(root), )
def test_create_new_nvset_if_does_not_exist(self): root = etree.Element("root", id="root") nvpair.arrange_first_nvset( "nvset", root, { "attr": "10", "new_one": "20", "test": "0", "attr2": "" }, self.id_provider ) assert_xml_equal( """ <root id="root"> <nvset id="root-nvset"> <nvpair id="root-nvset-attr" name="attr" value="10"/> <nvpair id="root-nvset-new_one" name="new_one" value="20"/> <nvpair id="root-nvset-test" name="test" value="0"/> </nvset> </root> """, etree_to_str(root) )
def disable(resource_el): """ Disable specified resource etree resource_el -- resource element """ nvpair.arrange_first_nvset("meta_attributes", resource_el, { "target-role": "Stopped", })
def unmanage(resource_el): """ Set the resource not to be managed by the cluster etree resource_el -- resource element """ nvpair.arrange_first_nvset("meta_attributes", resource_el, { "is-managed": "false", })
def test_empty_value_has_no_effect(self): nvpair.arrange_first_nvset("nvset", self.root, {}) assert_xml_equal( """ <nvset id="nvset"> <nvpair id="nvset-attr" name="attr" value="1"/> <nvpair id="nvset-attr2" name="attr2" value="2"/> <notnvpair id="nvset-test" name="test" value="0"/> </nvset> """, etree_to_str(self.nvset))
def test_empty_value_has_no_effect(self): nvpair.arrange_first_nvset("nvset", self.root, {}) assert_xml_equal( """ <nvset id="nvset"> <nvpair id="nvset-attr" name="attr" value="1"/> <nvpair id="nvset-attr2" name="attr2" value="2"/> <notnvpair id="nvset-test" name="test" value="0"/> </nvset> """, etree.tostring(self.nvset).decode(), )
def test_empty_value_has_no_effect(self): nvpair.arrange_first_nvset("nvset", self.root, {}, self.id_provider) assert_xml_equal( """ <nvset id="nvset"> <nvpair id="nvset-attr" name="attr" value="1"/> <nvpair id="nvset-attr2" name="attr2" value="2"/> <notnvpair id="nvset-test" name="test" value="0"/> </nvset> """, etree_to_str(self.nvset) )
def test_update_existing_nvset(self): nvpair.arrange_first_nvset("nvset", self.root, {"attr": "10", "new_one": "20", "test": "0", "attr2": ""}) assert_xml_equal( """ <nvset id="nvset"> <nvpair id="nvset-attr" name="attr" value="10"/> <notnvpair id="nvset-test" name="test" value="0"/> <nvpair id="nvset-new_one" name="new_one" value="20"/> <nvpair id="nvset-test-1" name="test" value="0"/> </nvset> """, etree.tostring(self.nvset).decode(), )
def test_update_existing_nvset(self): nvpair.arrange_first_nvset("nvset", self.root, { "attr": "10", "new_one": "20", "test": "0", "attr2": "" }) assert_xml_equal( """ <nvset id="nvset"> <nvpair id="nvset-attr" name="attr" value="10"/> <notnvpair id="nvset-test" name="test" value="0"/> <nvpair id="nvset-new_one" name="new_one" value="20"/> <nvpair id="nvset-test-1" name="test" value="0"/> </nvset> """, etree_to_str(self.nvset))