Merge branch 'master' into datarestructure
This commit is contained in:
23
commands/all.py
Normal file
23
commands/all.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import main
|
||||
from core.bot import deliverRelayCommands
|
||||
|
||||
class All:
|
||||
def __init__(self, *args):
|
||||
self.all(*args)
|
||||
|
||||
def all(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length > 2:
|
||||
for i in main.pool.keys():
|
||||
relay = main.pool[i]["relay"]
|
||||
network = main.pool[i]["network"]
|
||||
alias = main.pool[i]["alias"]
|
||||
commands = {spl[1]: [" ".join(spl[2:])]}
|
||||
success("Sending commands to relay %s as user %s" % (relay, alias+"/"+network))
|
||||
deliverRelayCommands(relay, commands, user=alias+"/"+network)
|
||||
return
|
||||
else:
|
||||
incUsage("all")
|
||||
return
|
||||
else:
|
||||
incUsage(None)
|
||||
46
commands/allc.py
Normal file
46
commands/allc.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import main
|
||||
from core.bot import deliverRelayCommands
|
||||
|
||||
class Allc:
|
||||
def __init__(self, *args):
|
||||
self.allc(*args)
|
||||
|
||||
def allc(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length > 4:
|
||||
targets = []
|
||||
if spl[1] == "network":
|
||||
if spl[2] in main.network.keys():
|
||||
for i in main.pool.keys():
|
||||
if main.pool[i]["network"] == spl[2]:
|
||||
targets.append(i)
|
||||
else:
|
||||
failure("No such network: %s" % spl[2])
|
||||
return
|
||||
elif spl[1] == "alias":
|
||||
if spl[2] in main.alias.keys():
|
||||
for i in main.pool.keys():
|
||||
if main.pool[i]["alias"] == spl[2]:
|
||||
targets.append(i)
|
||||
else:
|
||||
failure("No such alias: %s" % spl[2])
|
||||
return
|
||||
else:
|
||||
incUsage("allc")
|
||||
return
|
||||
if len(targets) == 0:
|
||||
failure("No matches found: %s" % spl[2])
|
||||
return
|
||||
for i in targets:
|
||||
relay = main.pool[i]["relay"]
|
||||
network = main.pool[i]["network"]
|
||||
alias = main.pool[i]["alias"]
|
||||
commands = {spl[3]: [" ".join(spl[4:])]}
|
||||
success("Sending commands to relay %s as user %s" % (relay, alias+"/"+network))
|
||||
deliverRelayCommands(relay, commands, user=alias+"/"+network)
|
||||
return
|
||||
else:
|
||||
incUsage("allc")
|
||||
return
|
||||
else:
|
||||
incUsage(None)
|
||||
@@ -19,22 +19,22 @@ class ProvisionCommand:
|
||||
failure("No such network: %s" % spl[3])
|
||||
return
|
||||
|
||||
if "users" in main.relay[spl[1]]:
|
||||
if not spl[2] in main.relay[spl[1]]["users"]:
|
||||
failure("Relay %s not provisioned for alias %s" % (spl[1], spl[2]))
|
||||
return
|
||||
else:
|
||||
failure("Relay %s not provisioned for alias %s" % (spl[1], spl[2]))
|
||||
return
|
||||
#if "users" in main.relay[spl[1]]:
|
||||
# if not spl[2] in main.relay[spl[1]]["users"]:
|
||||
# failure("Relay %s not provisioned for alias %s" % (spl[1], spl[2]))
|
||||
# return
|
||||
#else:
|
||||
# failure("Relay %s not provisioned for alias %s" % (spl[1], spl[2]))
|
||||
# return
|
||||
|
||||
rtrn = provision.provisionRelayForNetwork(spl[1], spl[2], spl[3])
|
||||
if rtrn == "PROVISIONED":
|
||||
failure("Relay %s already provisioned for alias %s on network %s" % (spl[1], spl[2], spl[3]))
|
||||
return
|
||||
elif rtrn == "DUPLICATE":
|
||||
failure("Instance with relay %s and alias %s already exists for network %s" % (spl[1], spl[2], spl[3]))
|
||||
return
|
||||
elif rtrn:
|
||||
#if rtrn == "PROVISIONED":
|
||||
# failure("Relay %s already provisioned for alias %s on network %s" % (spl[1], spl[2], spl[3]))
|
||||
# return
|
||||
#elif rtrn == "DUPLICATE":
|
||||
# failure("Instance with relay %s and alias %s already exists for network %s" % (spl[1], spl[2], spl[3]))
|
||||
# return
|
||||
if rtrn:
|
||||
success("Started provisioning network %s on relay %s for alias %s" % (spl[3], spl[1], spl[2]))
|
||||
info("Instance name is %s" % rtrn)
|
||||
return
|
||||
@@ -43,10 +43,10 @@ class ProvisionCommand:
|
||||
return
|
||||
if length == 3: # provision for relay and alias only
|
||||
rtrn = provision.provisionRelayForAlias(spl[1], spl[2])
|
||||
if rtrn == "PROVISIONED":
|
||||
failure("Relay %s already provisioned for alias %s" % (spl[1], spl[2]))
|
||||
return
|
||||
elif rtrn:
|
||||
#if rtrn == "PROVISIONED":
|
||||
# failure("Relay %s already provisioned for alias %s" % (spl[1], spl[2]))
|
||||
# return
|
||||
if rtrn:
|
||||
success("Started provisioning relay %s for alias %s" % (spl[1], spl[2]))
|
||||
return
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user