Ejemplo n.º 1
0
    def test_with_id(self):
        cmd_alert.add_recipient(
            self.mock_env,
            "alert",
            "value",
            {"attr1": "val1"},
            {
                "attr2": "val2",
                "attr1": "val1"
            },
            recipient_id="my-recipient"
        )
        assert_xml_equal(
            """
<cib validate-with="pacemaker-2.5">
    <configuration>
        <alerts>
            <alert id="alert" path="path">
                <recipient id="alert-recipient" value="value1"/>
                <recipient id="my-recipient" value="value">
                    <meta_attributes
                        id="my-recipient-meta_attributes"
                    >
                        <nvpair
                            id="my-recipient-meta_attributes-attr1"
                            name="attr1"
                            value="val1"
                        />
                        <nvpair
                            id="my-recipient-meta_attributes-attr2"
                            name="attr2"
                            value="val2"
                        />
                    </meta_attributes>
                    <instance_attributes
                        id="my-recipient-instance_attributes"
                    >
                        <nvpair
                            id="my-recipient-instance_attributes-attr1"
                            name="attr1"
                            value="val1"
                        />
                    </instance_attributes>
                </recipient>
            </alert>
        </alerts>
    </configuration>
</cib>
            """,
            self.mock_env._get_cib_xml()
        )
Ejemplo n.º 2
0
 def test_alert_not_found(self):
     assert_raise_library_error(
         lambda: cmd_alert.add_recipient(self.mock_env, "unknown",
                                         "recipient", {}, {}),
         (Severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, {
             "alert": "unknown"
         }))
Ejemplo n.º 3
0
 def test_with_id(self):
     self.config.env.push_cib(
         replace={
             './/alert[@id="alert"]':
             """
             <alert id="alert" path="path">
                 <recipient id="alert-recipient" value="value1"/>
                 <recipient id="my-recipient" value="value">
                     <meta_attributes
                         id="my-recipient-meta_attributes"
                     >
                         <nvpair
                             id="my-recipient-meta_attributes-attr1"
                             name="attr1"
                             value="val1"
                         />
                         <nvpair
                             id="my-recipient-meta_attributes-attr2"
                             name="attr2"
                             value="val2"
                         />
                     </meta_attributes>
                     <instance_attributes
                         id="my-recipient-instance_attributes"
                     >
                         <nvpair
                             id="my-recipient-instance_attributes-attr1"
                             name="attr1"
                             value="val1"
                         />
                     </instance_attributes>
                 </recipient>
             </alert>
             """
         }
     )
     cmd_alert.add_recipient(
         self.env_assist.get_env(),
         "alert",
         "value",
         {"attr1": "val1"},
         {
             "attr2": "val2",
             "attr1": "val1"
         },
         recipient_id="my-recipient"
     )
Ejemplo n.º 4
0
 def test_with_id(self):
     self.config.env.push_cib(
         replace={
             './/alert[@id="alert"]':
             """
             <alert id="alert" path="path">
                 <recipient id="alert-recipient" value="value1"/>
                 <recipient id="my-recipient" value="value">
                     <meta_attributes
                         id="my-recipient-meta_attributes"
                     >
                         <nvpair
                             id="my-recipient-meta_attributes-attr1"
                             name="attr1"
                             value="val1"
                         />
                         <nvpair
                             id="my-recipient-meta_attributes-attr2"
                             name="attr2"
                             value="val2"
                         />
                     </meta_attributes>
                     <instance_attributes
                         id="my-recipient-instance_attributes"
                     >
                         <nvpair
                             id="my-recipient-instance_attributes-attr1"
                             name="attr1"
                             value="val1"
                         />
                     </instance_attributes>
                 </recipient>
             </alert>
             """
         }
     )
     cmd_alert.add_recipient(
         self.env_assist.get_env(),
         "alert",
         "value",
         {"attr1": "val1"},
         {
             "attr2": "val2",
             "attr1": "val1"
         },
         recipient_id="my-recipient"
     )
Ejemplo n.º 5
0
    def test_with_id(self):
        cmd_alert.add_recipient(self.mock_env,
                                "alert",
                                "value", {"attr1": "val1"}, {
                                    "attr2": "val2",
                                    "attr1": "val1"
                                },
                                recipient_id="my-recipient")
        assert_xml_equal(
            """
<cib validate-with="pacemaker-2.5">
    <configuration>
        <alerts>
            <alert id="alert" path="path">
                <recipient id="alert-recipient" value="value1"/>
                <recipient id="my-recipient" value="value">
                    <meta_attributes
                        id="my-recipient-meta_attributes"
                    >
                        <nvpair
                            id="my-recipient-meta_attributes-attr1"
                            name="attr1"
                            value="val1"
                        />
                        <nvpair
                            id="my-recipient-meta_attributes-attr2"
                            name="attr2"
                            value="val2"
                        />
                    </meta_attributes>
                    <instance_attributes
                        id="my-recipient-instance_attributes"
                    >
                        <nvpair
                            id="my-recipient-instance_attributes-attr1"
                            name="attr1"
                            value="val1"
                        />
                    </instance_attributes>
                </recipient>
            </alert>
        </alerts>
    </configuration>
</cib>
            """, self.mock_env._get_cib_xml())
Ejemplo n.º 6
0
 def test_recipient_already_exists(self):
     assert_raise_library_error(
         lambda: cmd_alert.add_recipient(self.mock_env,
                                         "alert",
                                         "value1", {}, {},
                                         recipient_id="alert-recipient"),
         (Severities.ERROR, report_codes.ID_ALREADY_EXISTS, {
             "id": "alert-recipient"
         }))
Ejemplo n.º 7
0
 def test_value_not_defined(self):
     self.config.remove("runner.cib.load")
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.add_recipient(self.env_assist.get_env(),
                                         "unknown", "", {}, {}),
         [(Severities.ERROR, report_codes.REQUIRED_OPTIONS_ARE_MISSING, {
             "option_names": ["value"]
         })],
     )
Ejemplo n.º 8
0
 def test_value_not_defined(self):
     assert_raise_library_error(
         lambda: cmd_alert.add_recipient(
             self.mock_env, "unknown", "", {}, {}
         ),
         (
             Severities.ERROR,
             report_codes.REQUIRED_OPTION_IS_MISSING,
             {"option_name": "value"}
         )
     )
Ejemplo n.º 9
0
 def test_alert_not_found(self):
     assert_raise_library_error(
         lambda: cmd_alert.add_recipient(
             self.mock_env, "unknown", "recipient", {}, {}
         ),
         (
             Severities.ERROR,
             report_codes.CIB_ALERT_NOT_FOUND,
             {"alert": "unknown"}
         )
     )
Ejemplo n.º 10
0
 def test_recipient_already_exists(self):
     assert_raise_library_error(
         lambda: cmd_alert.add_recipient(
             self.mock_env, "alert", "value1", {}, {},
             recipient_id="alert-recipient"
         ),
         (
             Severities.ERROR,
             report_codes.ID_ALREADY_EXISTS,
             {"id": "alert-recipient"}
         )
     )
Ejemplo n.º 11
0
 def test_value_not_defined(self):
     self.config.remove("runner.cib.load")
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.add_recipient(
             self.env_assist.get_env(), "unknown", "", {}, {}
         ),
         [
             (
                 Severities.ERROR,
                 report_codes.REQUIRED_OPTION_IS_MISSING,
                 {"option_names": ["value"]}
             )
         ],
     )
Ejemplo n.º 12
0
 def test_recipient_already_exists(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.add_recipient(
             self.env_assist.get_env(),
             "alert",
             "value1",
             {},
             {},
             recipient_id="alert-recipient",
         ),
         [(
             Severities.ERROR,
             report_codes.ID_ALREADY_EXISTS,
             {
                 "id": "alert-recipient"
             },
         )],
     )
Ejemplo n.º 13
0
 def test_value_not_defined(self):
     assert_raise_library_error(
         lambda: cmd_alert.add_recipient(self.mock_env, "unknown", "", {}, {
         }), (Severities.ERROR, report_codes.REQUIRED_OPTION_IS_MISSING, {
             "option_name": "value"
         }))