def ensure_removal_of_template(self, template_name): matching = [template for template in self.templates if template.name == template_name] root = Ensurance(self.__xml_root) templates_element = root.ensure_child('templates').element for template in matching: templates_element.remove(template.element) if len(self.templates) == 0: root.element.remove(templates_element) return self
def ensure_permissions(configurator, pipeline_group, permission, roles): """ Ensure that only the ``roles`` are given the ``permission`` in the ``pipeline_group``. Arguments: pipeline_group (gomatic.PipelineGroup) permission (Permission) roles (list): List of role names to ensure """ for role in roles: ensure_role(configurator, role) authorization = Ensurance(pipeline_group.element).ensure_child('authorization') permission = authorization.ensure_child(permission.value) permission.element[:] = [] for role in roles: role_element = ET.SubElement(permission.element, tag='role') role_element.text = role
def ensure_permissions(configurator, pipeline_group, permission, roles): """ Ensure that only the ``roles`` are given the ``permission`` in the ``pipeline_group``. Arguments: pipeline_group (gomatic.PipelineGroup) permission (Permission) roles (list): List of role names to ensure """ for role in roles: ensure_role(configurator, role) authorization = Ensurance( pipeline_group.element).ensure_child('authorization') permission = authorization.ensure_child(permission.value) permission.element[:] = [] for role in roles: role_element = ET.SubElement(permission.element, tag='role') role_element.text = role