Exemplo n.º 1
0
    def test_update_all(self):
        cmd_alert.update_recipient(
            self.mock_env,
            "alert-recipient-1",
            {"attr1": "value"},
            {
                "attr1": "",
                "attr3": "new_val"
            },
            recipient_value="new_val",
            description="desc"
        )
        assert_xml_equal(
            """
<cib validate-with="pacemaker-2.5">
    <configuration>
        <alerts>
            <alert id="alert" path="path">
                <recipient id="alert-recipient" value="value1"/>
                <recipient
                    id="alert-recipient-1"
                    value="new_val"
                    description="desc"
                >
                    <meta_attributes
                        id="alert-recipient-1-meta_attributes"
                    >
                        <nvpair
                            id="alert-recipient-1-meta_attributes-attr2"
                            name="attr2"
                            value="val2"
                        />
                        <nvpair
                            id="alert-recipient-1-meta_attributes-attr3"
                            name="attr3"
                            value="new_val"
                        />
                    </meta_attributes>
                    <instance_attributes
                        id="alert-recipient-1-instance_attributes"
                    >
                        <nvpair
                            id="alert-recipient-1-instance_attributes-attr1"
                            name="attr1"
                            value="value"
                        />
                    </instance_attributes>
                </recipient>
            </alert>
        </alerts>
    </configuration>
</cib>
            """,
            self.mock_env._get_cib_xml()
        )
Exemplo n.º 2
0
 def test_update_all(self):
     self.config.env.push_cib(
         replace={
             './/alert[@id="alert"]':
             """
             <alert id="alert" path="path">
                 <recipient id="alert-recipient" value="value1"/>
                 <recipient
                     id="alert-recipient-1"
                     value="new_val"
                     description="desc"
                 >
                     <meta_attributes
                         id="alert-recipient-1-meta_attributes"
                     >
                         <nvpair
                             id="alert-recipient-1-meta_attributes-attr2"
                             name="attr2"
                             value="val2"
                         />
                         <nvpair
                             id="alert-recipient-1-meta_attributes-attr3"
                             name="attr3"
                             value="new_val"
                         />
                     </meta_attributes>
                     <instance_attributes
                         id="alert-recipient-1-instance_attributes"
                     >
                         <nvpair
                             id="alert-recipient-1-instance_attributes-attr1"
                             name="attr1"
                             value="value"
                         />
                     </instance_attributes>
                 </recipient>
             </alert>
             """,
         }
     )
     cmd_alert.update_recipient(
         self.env_assist.get_env(),
         "alert-recipient-1",
         {"attr1": "value"},
         {
             "attr1": "",
             "attr3": "new_val"
         },
         recipient_value="new_val",
         description="desc"
     )
Exemplo n.º 3
0
 def test_update_all(self):
     self.config.env.push_cib(
         replace={
             './/alert[@id="alert"]':
             """
             <alert id="alert" path="path">
                 <recipient id="alert-recipient" value="value1"/>
                 <recipient
                     id="alert-recipient-1"
                     value="new_val"
                     description="desc"
                 >
                     <meta_attributes
                         id="alert-recipient-1-meta_attributes"
                     >
                         <nvpair
                             id="alert-recipient-1-meta_attributes-attr2"
                             name="attr2"
                             value="val2"
                         />
                         <nvpair
                             id="alert-recipient-1-meta_attributes-attr3"
                             name="attr3"
                             value="new_val"
                         />
                     </meta_attributes>
                     <instance_attributes
                         id="alert-recipient-1-instance_attributes"
                     >
                         <nvpair
                             id="alert-recipient-1-instance_attributes-attr1"
                             name="attr1"
                             value="value"
                         />
                     </instance_attributes>
                 </recipient>
             </alert>
             """,
         }
     )
     cmd_alert.update_recipient(
         self.env_assist.get_env(),
         "alert-recipient-1",
         {"attr1": "value"},
         {
             "attr1": "",
             "attr3": "new_val"
         },
         recipient_value="new_val",
         description="desc"
     )
Exemplo n.º 4
0
    def test_update_all(self):
        cmd_alert.update_recipient(self.mock_env,
                                   "alert-recipient-1", {"attr1": "value"}, {
                                       "attr1": "",
                                       "attr3": "new_val"
                                   },
                                   recipient_value="new_val",
                                   description="desc")
        assert_xml_equal(
            """
<cib validate-with="pacemaker-2.5">
    <configuration>
        <alerts>
            <alert id="alert" path="path">
                <recipient id="alert-recipient" value="value1"/>
                <recipient
                    id="alert-recipient-1"
                    value="new_val"
                    description="desc"
                >
                    <meta_attributes
                        id="alert-recipient-1-meta_attributes"
                    >
                        <nvpair
                            id="alert-recipient-1-meta_attributes-attr2"
                            name="attr2"
                            value="val2"
                        />
                        <nvpair
                            id="alert-recipient-1-meta_attributes-attr3"
                            name="attr3"
                            value="new_val"
                        />
                    </meta_attributes>
                    <instance_attributes
                        id="alert-recipient-1-instance_attributes"
                    >
                        <nvpair
                            id="alert-recipient-1-instance_attributes-attr1"
                            name="attr1"
                            value="value"
                        />
                    </instance_attributes>
                </recipient>
            </alert>
        </alerts>
    </configuration>
</cib>
            """, self.mock_env._get_cib_xml())
Exemplo n.º 5
0
 def test_recipient_not_found(self):
     assert_raise_library_error(
         lambda: cmd_alert.update_recipient(self.mock_env, "recipient", {
         }, {}), (Severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "recipient",
             "id_description": "Recipient"
         }))
Exemplo n.º 6
0
 def test_empty_value(self):
     assert_raise_library_error(
         lambda: cmd_alert.update_recipient(self.mock_env,
                                            "alert-recipient-1", {}, {},
                                            recipient_value=""),
         (Severities.ERROR, report_codes.CIB_ALERT_RECIPIENT_VALUE_INVALID,
          {
              "recipient": ""
          }))
Exemplo n.º 7
0
 def test_recipient_not_found(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.update_recipient(self.env_assist.get_env(),
                                            "recipient", {}, {}),
         [(Severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "recipient",
             "id_description": "recipient"
         })],
     )
Exemplo n.º 8
0
 def test_recipient_not_found(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.update_recipient(self.env_assist.get_env(),
                                            "recipient", {}, {}),
         [(Severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "recipient",
             "expected_types": ["recipient"],
             "context_id": "",
             "context_type": "alerts",
         }, None)],
     )
Exemplo n.º 9
0
 def test_empty_value(self):
     self.config.remove("runner.cib.load")
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.update_recipient(self.env_assist.get_env(),
                                            "alert-recipient-1", {}, {},
                                            recipient_value=""),
         [(Severities.ERROR, report_codes.CIB_ALERT_RECIPIENT_VALUE_INVALID,
           {
               "recipient": ""
           })],
     )
Exemplo n.º 10
0
 def test_empty_value(self):
     assert_raise_library_error(
         lambda: cmd_alert.update_recipient(
             self.mock_env, "alert-recipient-1", {}, {}, recipient_value=""
         ),
         (
             Severities.ERROR,
             report_codes.CIB_ALERT_RECIPIENT_VALUE_INVALID,
             {"recipient": ""}
         )
     )
Exemplo n.º 11
0
 def test_recipient_not_found(self):
     assert_raise_library_error(
         lambda: cmd_alert.update_recipient(
             self.mock_env, "recipient", {}, {}
         ),
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "id": "recipient",
                 "id_description": "Recipient"
             }
         )
     )
Exemplo n.º 12
0
 def test_empty_value(self):
     self.config.remove("runner.cib.load")
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.update_recipient(
             self.env_assist.get_env(),
             "alert-recipient-1", {}, {}, recipient_value=""
         ),
         [
             (
                 Severities.ERROR,
                 report_codes.CIB_ALERT_RECIPIENT_VALUE_INVALID,
                 {"recipient": ""}
             )
         ],
     )
Exemplo n.º 13
0
 def test_recipient_not_found(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.update_recipient(
             self.env_assist.get_env(), "recipient", {}, {}
         ),
         [
             (
                 Severities.ERROR,
                 report_codes.ID_NOT_FOUND,
                 {
                     "id": "recipient",
                     "expected_types": ["recipient"],
                     "context_id": "",
                     "context_type": "alerts",
                 },
                 None
             )
         ],
     )