headers = "Server Name|User Name|Gecos|Locked|Groups|Sudo Rights"

	appServersList = parseCSV(options.serversListFile)
	for appName,serversList in appServersList.iteritems():
		if options.verbose:
			printTitle("Working on application {0}".format(appName), True)

		with open(os.path.join(outputDirectory, "{0}.psv".format(appName)), 'w') as f:
			f.write(headers+ os.linesep)

			for serverName in serversList:
				if options.verbose:
					printTitle("Parsing server {0}".format(serverName))
					print headers

				server = Server(serverName)
				users = server.getUsers()
				for user in users:
					row = "{0}|{1}|{2}|{3}|{4}|{5}".format(
							server.getName(),
							user.name,
							user.gecos,
							user.isLocked,
							" ".join(user.groups),
							";".join(str(v).strip() for v in user.sudoPerms)
							)
					if options.verbose:
						print row
					f.write(row + os.linesep)

        parser.print_help()
        sys.exit(1)

    outputDirectory = options.outputDirectory
    headers = "Server Name|User Name|Gecos|Locked|Groups|Sudo Rights"

    appServersList = parseCSV(options.serversListFile)
    for appName, serversList in appServersList.iteritems():
        if options.verbose:
            printTitle("Working on application {0}".format(appName), True)

        with open(os.path.join(outputDirectory, "{0}.psv".format(appName)),
                  'w') as f:
            f.write(headers + os.linesep)

            for serverName in serversList:
                if options.verbose:
                    printTitle("Parsing server {0}".format(serverName))
                    print headers

                server = Server(serverName)
                users = server.getUsers()
                for user in users:
                    row = "{0}|{1}|{2}|{3}|{4}|{5}".format(
                        server.getName(), user.name, user.gecos, user.isLocked,
                        " ".join(user.groups),
                        ";".join(str(v).strip() for v in user.sudoPerms))
                    if options.verbose:
                        print row
                    f.write(row + os.linesep)
예제 #3
0
 def test_server_getname(self):
     server = Server('aws-devbox-root')
     self.assertEqual(server.getName(), 'aws-devbox-root')