def run(self): banner("Reset the cloudmesh management yaml files ") yaml_files = ['cloudmesh_user.yaml', 'cloudmesh_project.yaml'] dir_path = path_expand("~/.cloudmesh/{0}".format("accounts")) if not os.path.exists(dir_path): Shell.mkdir(dir_path) for yaml_file in yaml_files: filename = path_expand("~/.cloudmesh/{0}/{1}".format( "accounts", yaml_file)) if os.path.isfile(filename): Console.info("Removing file: {0}".format(filename)) Shell.rm(filename) Console.info("Copying file: {0} -> {1} ".format( path_expand("etc/{0}/{1}".format("accounts", yaml_file)), filename)) shutil.copy( "etc/{0}/{1}".format("accounts", yaml_file), path_expand("~/.cloudmesh/{0}/{1}".format( "accounts", yaml_file))) else: Console.info("Copying file: {0} -> {1} ".format( path_expand("etc/{0}/{1}".format("accounts", yaml_file)), filename)) shutil.copy( "etc/{0}/{1}".format("accounts", yaml_file), path_expand("~/.cloudmesh/{0}/{1}".format( "accounts", yaml_file)))
def _grep(self, search, platform): if not search: search = "'OS_PASSWORD': '******'" cmd = "egrep -ri \"{0}\" * | cut -d\":\" -f1 > a.tmp".format(search) print("[{0}]:{1}".format(platform, cmd)) os.system(cmd) res = Shell.cat("a.tmp") if res: print ('[{0}]: [ERROR] PASSWORD(OR SECRET KEY) DETECTED, SEE FILES ' 'BELOW'.format(platform)) print ("") print (res) else: print ("[{0}]: NO PASSWORD DETECTED".format(platform)) Shell.rm("a.tmp") print ("")
def run(self): banner("Reset the cloudmesh management yaml files ") yaml_files = ['cloudmesh_user.yaml', 'cloudmesh_project.yaml'] dir_path = path_expand("~/.cloudmesh/{0}".format("accounts")) if not os.path.exists(dir_path): Shell.mkdir(dir_path) for yaml_file in yaml_files: filename = path_expand("~/.cloudmesh/{0}/{1}".format("accounts", yaml_file)) if os.path.isfile(filename): Console.info("Removing file: {0}".format(filename)) Shell.rm(filename) Console.info("Copying file: {0} -> {1} ".format(path_expand("etc/{0}/{1}".format("accounts", yaml_file)), filename)) shutil.copy("etc/{0}/{1}".format("accounts", yaml_file), path_expand("~/.cloudmesh/{0}/{1}".format("accounts", yaml_file))) else: Console.info("Copying file: {0} -> {1} ".format(path_expand("etc/{0}/{1}".format("accounts", yaml_file)), filename)) shutil.copy("etc/{0}/{1}".format("accounts", yaml_file), path_expand("~/.cloudmesh/{0}/{1}".format("accounts", yaml_file)))