Exemplo n.º 1
0
    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),
        )
Exemplo n.º 2
0
    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)
        )
Exemplo n.º 3
0
def disable(resource_el):
    """
    Disable specified resource
    etree resource_el -- resource element
    """
    nvpair.arrange_first_nvset("meta_attributes", resource_el, {
        "target-role": "Stopped",
    })
Exemplo n.º 4
0
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",
    })
Exemplo n.º 5
0
 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))
Exemplo n.º 6
0
 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(),
     )
Exemplo n.º 7
0
 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)
     )
Exemplo n.º 8
0
 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(),
     )
Exemplo n.º 9
0
 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))