예제 #1
0
파일: acl.py 프로젝트: HideoYamauchi/pcs
def remove_role(lib_env, role_id, autodelete_users_groups=False):
    """
    Remove role with specified id from CIB.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnvironment
    role_id -- id of role which should be deleted
    autodelete_users_groups -- if True targets and groups which are empty after
        removal will be removed
    """
    with cib_acl_section(lib_env) as acl_section:
        acl.remove_role(acl_section, role_id, autodelete_users_groups)
예제 #2
0
def remove_role(lib_env, role_id, autodelete_users_groups=False):
    """
    Remove role with specified id from CIB.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnvironment
    role_id -- id of role which should be deleted
    autodelete_users_groups -- if True targets and groups which are empty after
        removal will be removed
    """
    with cib_acl_section(lib_env) as acl_section:
        acl.remove_role(acl_section, role_id, autodelete_users_groups)
예제 #3
0
파일: test_acl.py 프로젝트: thulyacloud/pcs
 def test_autodelete(self):
     expected_xml = """
     <cib>
         <configuration>
             <acls>
                 <acl_group>
                     <role id="some-role"/>
                 </acl_group>
             </acls>
         </configuration>
     </cib>
     """
     lib.remove_role(self.tree, "role-id", autodelete_users_groups=True)
     assert_xml_equal(expected_xml, etree.tostring(self.tree).decode())
예제 #4
0
 def test_autodelete(self):
     expected_xml = """
     <cib>
         <configuration>
             <acls>
                 <acl_group>
                     <role id="some-role"/>
                 </acl_group>
             </acls>
         </configuration>
     </cib>
     """
     lib.remove_role(self.tree, "role-id", autodelete_users_groups=True)
     assert_xml_equal(expected_xml, etree.tostring(self.tree).decode())
예제 #5
0
파일: test_acl.py 프로젝트: thulyacloud/pcs
 def test_success(self):
     expected_xml = """
     <cib>
         <configuration>
             <acls>
                 <acl_target/>
                 <acl_group>
                     <role id="some-role"/>
                 </acl_group>
             </acls>
         </configuration>
     </cib>
     """
     lib.remove_role(self.tree, "role-id")
     assert_xml_equal(expected_xml, etree.tostring(self.tree).decode())
예제 #6
0
 def test_success(self):
     expected_xml = """
     <cib>
         <configuration>
             <acls>
                 <acl_target/>
                 <acl_group>
                     <role id="some-role"/>
                 </acl_group>
             </acls>
         </configuration>
     </cib>
     """
     lib.remove_role(self.tree, "role-id")
     assert_xml_equal(expected_xml, etree.tostring(self.tree).decode())
예제 #7
0
def remove_role(lib_env, role_id, autodelete_users_groups=False):
    """
    Remove role with specified id from CIB.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnvironment
    role_id -- id of role which should be deleted
    autodelete_users_groups -- if True targets and groups which are empty after
        removal will be removed
    """
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    try:
        acl.remove_role(cib, role_id, autodelete_users_groups)
    except acl.AclRoleNotFound as e:
        raise LibraryError(acl.acl_error_to_report_item(e))
    lib_env.push_cib(cib)
예제 #8
0
파일: acl.py 프로젝트: jmartign/pcs
def remove_role(lib_env, role_id, autodelete_users_groups=False):
    """
    Remove role with specified id from CIB.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnvironment
    role_id -- id of role which should be deleted
    autodelete_users_groups -- if True targets and groups which are empty after
        removal will be removed
    """
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    try:
        acl.remove_role(cib, role_id, autodelete_users_groups)
    except acl.AclRoleNotFound as e:
        raise LibraryError(acl.acl_error_to_report_item(e))
    lib_env.push_cib(cib)
예제 #9
0
파일: test_acl.py 프로젝트: thulyacloud/pcs
 def test_id_not_exists(self):
     assert_raise_library_error(
         lambda: lib.remove_role(self.tree.find(".//acls"), "id-of-role"),
         (
             severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "context_type": "acls",
                 "context_id": "",
                 "id": "id-of-role",
             },
         ),
     )
예제 #10
0
파일: test_acl.py 프로젝트: tomjelinek/pcs
 def test_id_not_exists(self):
     assert_raise_library_error(
         lambda: lib.remove_role(self.tree.find(".//acls"), "id-of-role"),
         (
             severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "context_type": "acls",
                 "context_id": "",
                 "id": "id-of-role",
             },
         ),
     )
예제 #11
0
 def test_id_not_exists(self):
     self.assert_raises(
         lib.AclRoleNotFound,
         lambda: lib.remove_role(self.tree, "id-of-role"),
         {"role_id": "id-of-role"}
     )