Beispiel #1
0
def performDeviceUpgradeByOrg(orgId):
	devices = ""
	if (orgId == "0"):
		#get devices for all orgs
		devices = c42Lib.getAllDevices()
	else:
		#run get devices
		devices = c42Lib.getAllDevicesByOrg(int(orgId))
	if (devices != "" and devices is not None):
		for index, device in enumerate(devices):
			#update device
			computerId = device['computerId']
			flaggedForUpgrade = c42Lib.putDeviceUpgrade(computerId)
			if flaggedForUpgrade:
				logging.info("computerId:[" + str(computerId) + "] flagged for upgrade")
			else:
				logging.info("computerId:[" + str(computerId) + "] failed to be flagged for upgrade")
	else:
		logging.info("No computers returned to flag for upgrade")
def getDeviceReport():
	csvDeviceFile = csv.writer(open("allDeviceReport.csv", "wb+"))
	csvDeviceFile.writerow(csvDeviceHeader)

	devices = c42Lib.getAllDevices()
	# devices = c42Lib.getDevices(1)

	for index, device in enumerate(devices):
		# device = c42Lib.getDeviceById(8637)
		printValues = []
		
		# computerId = loopDevice['computerId']

		# device = c42Lib.getDeviceById(computerId)

		userId = device['userId']
		printValues.extend([str(userId)])

		# print deviceObject
		computerId = device['computerId']
		printValues.extend([str(computerId)])

		computerName = device['name']
		printValues.extend([computerName.encode('utf-8')])

		computerType = device['type']
		printValues.extend([computerType.encode('utf-8')])

		osName = device['osName']
		printValues.extend([osName.encode('utf-8')])

		computerStatus = device['status']
		printValues.extend([computerStatus.encode('utf-8')])


		if 'backupUsage' in device:

			deviceObjectBackupUsage = device['backupUsage']

			for backupUsage in deviceObjectBackupUsage:

				#only if SOM-backup
				if backupUsage['targetComputerId'] == 2:

					storePointId = backupUsage['storePointId']
					printValues.extend([str(storePointId)])

					storePointName = backupUsage['storePointName']
					printValues.extend([storePointName.encode('utf-8')])

					serverId = backupUsage['serverId']
					printValues.extend([str(serverId)])

					serverName = backupUsage['serverName']
					printValues.extend([serverName.encode('utf-8')])

					selectedFiles = backupUsage['selectedFiles']
					printValues.extend([str(selectedFiles)])

					selectedBytes = backupUsage['selectedBytes']
					printValues.extend([str(selectedBytes)])

					printValues.extend([c42Lib.sizeof_fmt(selectedBytes)])

					archiveBytes = backupUsage['archiveBytes']
					printValues.extend([str(archiveBytes)])

					printValues.extend([c42Lib.sizeof_fmt(archiveBytes)])

					percentComplete = backupUsage['percentComplete']
					printValues.extend([str(percentComplete)])

					lastCompletedBackup = backupUsage['lastCompletedBackup']
					printValues.extend([str(lastCompletedBackup)])


					if 'history' in backupUsage:
						
						backupHistory = backupUsage['history']

						if backupHistory:

							oldestDate = 9999999999999999999
							# "20130801": 1909986568291,
							oldestDateBytes = 0
							newestDate = 0
						    # "20130830": 1932985363857
							newestDateBytes = 0

							for singleHistory in backupHistory:
								# print key, value
								# print oldestDate, int(key)
								currDate = singleHistory['date'].replace('-','')

								currarchiveBytes = singleHistory['archiveBytes']

								if (oldestDate > int(currDate)):
									oldestDate = int(currDate)
									oldestDateBytes = currarchiveBytes
								
								# print newestDate, int(key)
								if (newestDate <= int(currDate)):
									newestDate = int(currDate)
									newestDateBytes = currarchiveBytes

							printValues.extend([str(oldestDate)])
							printValues.extend([str(oldestDateBytes)])
							printValues.extend([c42Lib.sizeof_fmt(oldestDateBytes)])

							printValues.extend([str(newestDate)])
							printValues.extend([str(newestDateBytes)])
							printValues.extend([c42Lib.sizeof_fmt(newestDateBytes)])

							pArchiveBytesDeltaMonth = newestDateBytes - oldestDateBytes
							printValues.extend([str(pArchiveBytesDeltaMonth)])
							printValues.extend([c42Lib.sizeof_fmt(pArchiveBytesDeltaMonth)])
						# else:
							# printDeviceEmptyBlock(8)
					# else:
						# printDeviceEmptyBlock(8)
				# else:
				# 	print("hi")
					# printDeviceEmptyBlock(19)

		# else:
			# print("bye")
			# printDeviceEmptyBlock(19)
	
		# print ', '.join(printValues)
		logging.info(str(printValues))
		csvDeviceFile.writerow(printValues)
Beispiel #3
0
def getStoredBytesHistory():
    params = {}
    payload = {}

    r = c42Lib.executeRequest("get", "/api/storedBytesHistory", params,
                              payload)

    content = r.content
    binary = json.loads(content)

    latestStoredNumber = binary['data'][0][1]['archiveBytes']

    return latestStoredNumber


devices = c42Lib.getAllDevices()

totalDestinationData = getStoredBytesHistory()

totalDeviceData = 0

for index, device in enumerate(devices):
    cur_selectedBytes = 0
    cur_percentComplete = 0

    if device['backupUsage']:
        cur_selectedBytes = device['backupUsage'][0]['selectedBytes']
        # print str(cur_selectedBytes)
        cur_percentComplete = int(device['backupUsage'][0]['percentComplete'])
        # print str(cur_percentComplete)
def getStoredBytesHistory():
	params = {}
	payload = {}

	r = c42Lib.executeRequest("get", "/api/storedBytesHistory", params, payload)

	content = r.content
	binary = json.loads(content)

	latestStoredNumber = binary['data'][0][1]['archiveBytes']

	return latestStoredNumber



devices = c42Lib.getAllDevices()

totalDestinationData = getStoredBytesHistory()

totalDeviceData = 0

for index, device in enumerate(devices):
	cur_selectedBytes = 0
	cur_percentComplete = 0

	if device['backupUsage']:
		cur_selectedBytes = device['backupUsage'][0]['selectedBytes']
		# print str(cur_selectedBytes)
		cur_percentComplete = int(device['backupUsage'][0]['percentComplete'])
		# print str(cur_percentComplete)
Beispiel #5
0
def getDeviceReport():
    csvDeviceFile = csv.writer(open("allDeviceReport.csv", "wb+"))
    csvDeviceFile.writerow(csvDeviceHeader)

    users = c42Lib.getAllUsers()
    # get all the users to have in memory

    devices = c42Lib.getAllDevices()
    # devices = c42Lib.getDevices(1)

    for index, device in enumerate(devices):
        # device = c42Lib.getDeviceById(8637)
        printValues = []

        # computerId = loopDevice['computerId']

        # device = c42Lib.getDeviceById(computerId)

        userId = device['userId']
        printValues.extend([str(userId)])

        # Lookup User Info
        userInfo = findRecord(userId, users)

        logging.debug(userInfo)

        #Get User Name
        if userInfo:
            userName = userInfo['username']
        else:
            username = '******'
        printValues.extend([userName.encode('utf-8')])

        # print deviceObject
        computerId = device['computerId']
        printValues.extend([str(computerId)])

        computerName = device['name']
        printValues.extend([computerName.encode('utf-8')])

        computerType = device['type']
        printValues.extend([computerType.encode('utf-8')])

        osName = device['osName']
        printValues.extend([osName.encode('utf-8')])

        computerStatus = device['status']
        printValues.extend([computerStatus.encode('utf-8')])

        if 'backupUsage' in device:

            deviceObjectBackupUsage = device['backupUsage']

            for backupUsage in deviceObjectBackupUsage:

                if backupUsage['targetComputerId'] == destId:

                    storePointId = backupUsage['storePointId']
                    printValues.extend([str(storePointId)])

                    storePointName = backupUsage['storePointName']
                    printValues.extend([storePointName.encode('utf-8')])

                    serverId = backupUsage['serverId']
                    printValues.extend([str(serverId)])

                    serverName = backupUsage['serverName']
                    printValues.extend([serverName.encode('utf-8')])

                    selectedFiles = backupUsage['selectedFiles']
                    printValues.extend([str(selectedFiles)])

                    selectedBytes = backupUsage['selectedBytes']
                    printValues.extend([str(selectedBytes)])

                    printValues.extend([c42Lib.sizeof_fmt(selectedBytes)])

                    archiveBytes = backupUsage['archiveBytes']
                    printValues.extend([str(archiveBytes)])

                    printValues.extend([c42Lib.sizeof_fmt(archiveBytes)])

                    percentComplete = backupUsage['percentComplete']
                    printValues.extend([str(percentComplete)])

                    lastCompletedBackup = backupUsage['lastCompletedBackup']
                    printValues.extend([str(lastCompletedBackup)])

                    if 'history' in backupUsage:

                        backupHistory = backupUsage['history']

                        if backupHistory:

                            oldestDate = 9999999999999999999
                            # "20130801": 1909986568291,
                            oldestDateBytes = 0
                            newestDate = 0
                            # "20130830": 1932985363857
                            newestDateBytes = 0

                            for singleHistory in backupHistory:
                                # print key, value
                                # print oldestDate, int(key)
                                currDate = singleHistory['date'].replace(
                                    '-', '')

                                currarchiveBytes = singleHistory[
                                    'archiveBytes']

                                if (oldestDate > int(currDate)):
                                    oldestDate = int(currDate)
                                    oldestDateBytes = currarchiveBytes

                                # print newestDate, int(key)
                                if (newestDate <= int(currDate)):
                                    newestDate = int(currDate)
                                    newestDateBytes = currarchiveBytes

                            printValues.extend([str(oldestDate)])
                            printValues.extend([str(oldestDateBytes)])
                            printValues.extend(
                                [c42Lib.sizeof_fmt(oldestDateBytes)])

                            printValues.extend([str(newestDate)])
                            printValues.extend([str(newestDateBytes)])
                            printValues.extend(
                                [c42Lib.sizeof_fmt(newestDateBytes)])

                            pArchiveBytesDeltaMonth = newestDateBytes - oldestDateBytes
                            printValues.extend([str(pArchiveBytesDeltaMonth)])
                            printValues.extend(
                                [c42Lib.sizeof_fmt(pArchiveBytesDeltaMonth)])
                        # else:
                        # printDeviceEmptyBlock(8)
                    # else:
                    # printDeviceEmptyBlock(8)
                # else:
                # 	print("hi")
                # printDeviceEmptyBlock(19)

        # else:
        # print("bye")
        # printDeviceEmptyBlock(19)

        # print ', '.join(printValues)
        logging.info(str(printValues))
        csvDeviceFile.writerow(printValues)