Esempio n. 1
0
 def test_target_id_is_not_unique_id(self):
     lib.create_target(self.acls, "target3")
     self.assert_cib_equal(self.create_cib().append_to_first_tag_name(
         "configuration", """
         <acls>
             <acl_role id="target3"/>
             <acl_target id="target2"/>
             <acl_target id="target3"/>
         </acls>
         """))
Esempio n. 2
0
 def test_success(self):
     lib.create_target(self.acls, "target1")
     self.assert_cib_equal(self.create_cib().append_to_first_tag_name(
         "configuration", """
         <acls>
             <acl_role id="target3"/>
             <acl_target id="target2"/>
             <acl_target id="target1"/>
         </acls>
         """))
Esempio n. 3
0
 def test_target_id_is_not_unique_id(self):
     lib.create_target(self.cib.tree, "target3")
     self.assert_cib_equal(self.create_cib().append_to_first_tag_name(
         "configuration",
         """
         <acls>
             <acl_role id="target3"/>
             <acl_target id="target2"/>
             <acl_target id="target3"/>
         </acls>
         """
     ))
Esempio n. 4
0
 def test_success(self):
     lib.create_target(self.acls, "target1")
     self.assert_cib_equal(self.create_cib().append_to_first_tag_name(
         "configuration",
         """
         <acls>
             <acl_role id="target3"/>
             <acl_target id="target2"/>
             <acl_target id="target1"/>
         </acls>
         """
     ))
Esempio n. 5
0
 def test_target_id_is_not_unique_target_id(self):
     assert_raise_library_error(
         lambda: lib.create_target(self.cib.tree, "target2"),
         (
             severities.ERROR,
             report_codes.CIB_ACL_TARGET_ALREADY_EXISTS,
             {"target_id":"target2"}
         )
     )
Esempio n. 6
0
def create_target(lib_env, target_id, role_list):
    """
    Create new target with id target_id and assign roles role_list to it.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnvironment
    target_id -- id of new target
    role_list -- list of roles to assign to new target
    """
    with cib_acl_section(lib_env) as acl_section:
        acl.assign_all_roles(acl_section, role_list,
                             acl.create_target(acl_section, target_id))
Esempio n. 7
0
def create_target(lib_env, target_id, role_list):
    """
    Create new target with id target_id and assign roles role_list to it.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnvironment
    target_id -- id of new target
    role_list -- list of roles to assign to new target
    """
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    _assign_roles_to_element(cib, acl.create_target(cib, target_id), role_list)
    lib_env.push_cib(cib)
Esempio n. 8
0
File: acl.py Progetto: jmartign/pcs
def create_target(lib_env, target_id, role_list):
    """
    Create new target with id target_id and assign roles role_list to it.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnvironment
    target_id -- id of new target
    role_list -- list of roles to assign to new target
    """
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    _assign_roles_to_element(cib, acl.create_target(cib, target_id), role_list)
    lib_env.push_cib(cib)
Esempio n. 9
0
def create_target(lib_env, target_id, role_list):
    """
    Create new target with id target_id and assign roles role_list to it.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnvironment
    target_id -- id of new target
    role_list -- list of roles to assign to new target
    """
    with cib_acl_section(lib_env) as acl_section:
        acl.assign_all_roles(
            acl_section,
            role_list,
            acl.create_target(acl_section, target_id)
        )