mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Add --validate option. Do not refreshShapers if validation fails, unless first boot
This commit is contained in:
parent
7fe9537be4
commit
aa4c6b5125
@ -214,15 +214,23 @@ def refreshShapers():
|
||||
networkJSONfile = 'network.json'
|
||||
|
||||
# Check validation
|
||||
safeToRunRefresh = False
|
||||
if (validateNetworkAndDevices() == True):
|
||||
shutil.copyfile('ShapedDevices.csv', 'lastGoodConfig.csv')
|
||||
shutil.copyfile('network.json', 'lastGoodConfig.json')
|
||||
print("Backed up good config as lastGoodConfig.csv and lastGoodConfig.json")
|
||||
safeToRunRefresh = True
|
||||
else:
|
||||
warnings.warn("Validation failed - pulling from last good conifg")
|
||||
if (isThisFirstRunSinceBoot == False):
|
||||
warnings.warn("Validation failed. Because this is not the first run since boot - will exit.")
|
||||
safeToRunRefresh = False
|
||||
else:
|
||||
warnings.warn("Validation failed. However - because this is the first run since boot - will load queues from last good config")
|
||||
shapedDevicesFile = 'lastGoodConfig.csv'
|
||||
networkJSONfile = 'lastGoodConfig.json'
|
||||
safeToRunRefresh = True
|
||||
|
||||
if safeToRunRefresh == True:
|
||||
# Load Subscriber Circuits & Devices
|
||||
subscriberCircuits = []
|
||||
knownCircuitIDs = []
|
||||
@ -571,8 +579,17 @@ if __name__ == '__main__':
|
||||
help="Be verbose",
|
||||
action="store_const", dest="loglevel", const=logging.INFO,
|
||||
)
|
||||
parser.add_argument(
|
||||
'--validate',
|
||||
help="Just validate network.json and ShapedDevices.csv",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
)
|
||||
args = parser.parse_args()
|
||||
logging.basicConfig(level=args.loglevel)
|
||||
|
||||
if args.validate:
|
||||
status = validateNetworkAndDevices()
|
||||
else:
|
||||
# Starting
|
||||
print("refreshShapers starting at " + datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
# Refresh and/or set up queues
|
||||
|
Loading…
Reference in New Issue
Block a user