예제 #1
0
파일: test_alert.py 프로젝트: dchirikov/pcs
    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()
        )
예제 #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"
         }))
예제 #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"
     )
예제 #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"
     )
예제 #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())
예제 #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"
         }))
예제 #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"]
         })],
     )
예제 #8
0
파일: test_alert.py 프로젝트: dchirikov/pcs
 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"}
         )
     )
예제 #9
0
파일: test_alert.py 프로젝트: dchirikov/pcs
 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"}
         )
     )
예제 #10
0
파일: test_alert.py 프로젝트: dchirikov/pcs
 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"}
         )
     )
예제 #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"]}
             )
         ],
     )
예제 #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"
             },
         )],
     )
예제 #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"
         }))