Beispiel #1
0
 def OnLogin(self, code, msg):
     if code == "0000":
         logger.info("login success")
     else:
         logger.fatal(f"login fail: {msg}")
         if "3회 오류" in msg:
             logger.critical(f"accouint invalidation warning!")
             input("continue?")
         raise AssertionError("login fail")
csv = csv.reader(sys.stdin)

vc = VIServer()
cur_region = None
host_d = {}
vm_d = {}
for row in csv:
    appid = row[0]
    vm = row[1]

    region = ''
    m = re.match('.*(TOKYO|OSAKA)',appid)
    if(m): 
        region = m.group(1)
    else:
        logger.critical("Invalid appid with no region name %s",appid)

    if(cur_region != region):
        vcip = None
        if(region == 'TOKYO'):
            vcip = '10.1.1.50'
        else:
            vcip = '10.1.8.50'
    
        logger.debug("Trying to connect %s" % vcip)
        vc.connect(vcip,'sbgcf\\svc_report','VMwar3!!')
        cur_region = region

        try:
            host_d = {}
            vm_d = {}
            sys.exit(1)

        logger.debug("Downloaded-MD5:'%s'" % str(_hash.hexdigest()))
        logger.debug("LastUpdate-MD5:'%s'" % str(source.lastMd5))

        if (str(_hash.hexdigest()) != str(source.lastMd5)):
            UpdateLog.objects.create(
                update=update,
                time=datetime.datetime.now(),
                logType=UpdateLog.PROGRESS,
                text="7 Starting to process the download.")
            logger.info("Processing the download")
            try:
                UpdateTasks.runUpdate(filename, source.name, update=update)
            except Exception as e:
                logger.critical("Hit exception while running update: %s" %
                                str(e))
                UpdateLog.objects.create(
                    update=update,
                    time=datetime.datetime.now(),
                    logType=UpdateLog.PROGRESS,
                    text=
                    "100 ERROR: Hit an exception while processing the update.")
                logger.debug("%s" % (traceback.format_exc()))
                source.locked = False
                source.save()
                sys.exit(1)

            logger.info("Storing md5 of this update: %s" % (_hash.hexdigest()))
            source.lastMd5 = _hash.hexdigest()
            source.save()
        else:
Beispiel #4
0
			UpdateLog.objects.create(update=update, time=datetime.datetime.now(), logType=UpdateLog.PROGRESS, text="100 Error during downloading. Check log for details..")
			logger.error("Error during download: %s" % str(e))
			source.locked = False
			source.save()
			sys.exit(1)

		logger.debug("Downloaded-MD5:'%s'" % str(_hash.hexdigest()))
		logger.debug("LastUpdate-MD5:'%s'" % str(source.lastMd5))
	
		if(str(_hash.hexdigest()) != str(source.lastMd5)):
			UpdateLog.objects.create(update=update, time=datetime.datetime.now(), logType=UpdateLog.PROGRESS, text="7 Starting to process the download.")
			logger.info("Processing the download" )
			try:
				UpdateTasks.runUpdate(filename, source.name, update=update)
			except Exception as e:
				logger.critical("Hit exception while running update: %s" % str(e))
				UpdateLog.objects.create(update=update, time=datetime.datetime.now(), logType=UpdateLog.PROGRESS, text="100 ERROR: Hit an exception while processing the update.")
				logger.debug("%s" % (traceback.format_exc()))
				source.locked = False
				source.save()
				sys.exit(1)
		
			logger.info("Storing md5 of this update: %s" % (_hash.hexdigest()))
			source.lastMd5 = _hash.hexdigest()
			source.save()
		else:
			logger.info("The downloaded file has the same md5sum as the last file we updated from. Skipping update.")
			UpdateLog.objects.create(update=update, time=datetime.datetime.now(), logType=UpdateLog.PROGRESS, text="100 Downloaded file is processed earlier. Finishing.")
	else:
		logger.info("We already have the latest version of the %s ruleset. Skipping download." % source.name)
		UpdateLog.objects.create(update=update, time=datetime.datetime.now(), logType=UpdateLog.PROGRESS, text="100 MD5 sum mathces last update. Skipping.")