def delete_template(template_name, network, user): '''Delete template file :param template_name: template name :param network: IPv4 or IPv6 :param user: user :raise GITCommandError: Failed to execute command ''' try: ip_version = IP_VERSION.IPv4[0] if network == IP_VERSION.IPv4[ 1] else IP_VERSION.IPv6[0] path = "%s%s/%s%s" % (PATH_ACL, ip_version, PATH_ACL_TEMPLATES, template_name) chdir(PATH_TYPES.TEMPLATE, ip_version, path) Git.synchronization() File.remove(template_name) Git.remove(template_name) Git.commit( template_name, "Exclusão do Arquivo %s pelo usuário:%s" % (template_name, user.get_username())) Git.push() logger.info("%s excluiu no GIT o arquivo: %s" % (user.get_username(), (path + template_name))) except (GITCommandError, FileError, Exception), e: logger.error( "Erro quando o usuário %s tentou excluiu o arquivo: %s no Git" % (user.get_username(), (path + template_name))) logger.error(e) raise GITCommandError(e)
def deleteAclGit(acl_name, environment, network, user): '''Delete acl file :param acl_name: acl name :param environment: Environment :param network: v4 or v6 :param user: user :raise GITCommandError: Failed to execute command ''' try: acl = check_name_file(acl_name) path = path_acl(environment["nome_ambiente_logico"], environment["nome_divisao"], environment["acl_path"]) os.chdir(PATH_ACL) Git.synchronization() path_to_acl = "%s/%s/%s" % (network, path, acl) Git.remove(path_to_acl) Git.commit( path_to_acl, "Exclusão do Arquivo %s pelo usuário:%s" % (acl, user.get_username())) Git.push() logger.info("%s excluiu no GIT o arquivo: %s" % (user.get_username(), (path + acl))) except (GITCommandError, FileError, Exception), e: logger.error( "Erro quando o usuário %s tentou excluiu o arquivo: %s no Git" % (user.get_username(), (path + acl))) logger.error(e) raise GITCommandError(e)