2019-08-25 20:29:11 +00:00
|
|
|
import main
|
|
|
|
from modules import provision
|
|
|
|
|
|
|
|
class AutoCommand:
|
|
|
|
def __init__(self, *args):
|
|
|
|
self.auto(*args)
|
|
|
|
|
|
|
|
def auto(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
|
|
|
if authed:
|
|
|
|
if length == 3:
|
|
|
|
if not spl[1] in main.network.keys():
|
|
|
|
failure("No such network: %s" % spl[1])
|
|
|
|
return
|
|
|
|
if not spl[2].isdigit():
|
2019-09-29 13:57:36 +00:00
|
|
|
failure("Must be a number, not %s" % spl[2])
|
2019-08-25 20:29:11 +00:00
|
|
|
return
|
2019-09-28 18:46:10 +00:00
|
|
|
relayNum = int(spl[2])
|
2019-09-29 21:45:16 +00:00
|
|
|
num, alias = main.network[spl[1]].add_relay(relayNum)
|
|
|
|
success("Successfully created relay %i on network %s with alias %s" % (num, spl[1], alias))
|
2019-08-25 20:29:11 +00:00
|
|
|
main.saveConf("network")
|
2019-09-28 18:46:10 +00:00
|
|
|
rtrn = provision.provisionRelay(relayNum, spl[1])
|
2019-08-25 20:29:11 +00:00
|
|
|
success("Started provisioning network %s on relay %s for alias %s" % (spl[1], spl[2], rtrn))
|
|
|
|
return
|
2019-09-29 13:57:36 +00:00
|
|
|
elif length == 2:
|
|
|
|
if not spl[1] in main.network.keys():
|
|
|
|
failure("No such network: %s" % spl[1])
|
|
|
|
return
|
2019-10-02 19:26:05 +00:00
|
|
|
for i in main.alias.keys():
|
|
|
|
print("num", i)
|
|
|
|
num, alias = main.network[spl[1]].add_relay(i)
|
|
|
|
success("Successfully created relay %i on network %s with alias %s" % (num, spl[1], alias))
|
|
|
|
rtrn = provision.provisionRelay(num, spl[1])
|
|
|
|
success("Started provisioning network %s on relay %s for alias %s" % (spl[1], num, rtrn))
|
|
|
|
main.saveConf("network")
|
|
|
|
return
|
|
|
|
elif length == 1:
|
|
|
|
for i in main.network.keys():
|
|
|
|
for x in main.alias.keys():
|
|
|
|
num, alias = main.network[i].add_relay(x)
|
|
|
|
success("Successfully created relay %i on network %s with alias %s" % (num, i, alias))
|
|
|
|
rtrn = provision.provisionRelay(num, i)
|
|
|
|
success("Started provisioning network %s on relay %s for alias %s" % (i, num, rtrn))
|
2019-09-29 13:57:36 +00:00
|
|
|
main.saveConf("network")
|
|
|
|
return
|
2019-08-25 20:29:11 +00:00
|
|
|
else:
|
|
|
|
incUsage("auto")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|