Implement additional error checking for provisioning instances and parsing messages, and prevent ZNC from auto-connecting an instance if ConnectOnCreate is off
This commit is contained in:
parent
8926cb76ec
commit
a4b7bd50b1
|
@ -29,10 +29,11 @@ class Provision:
|
||||||
|
|
||||||
rtrn = provision.provisionRelayForNetwork(spl[1], spl[2], spl[3])
|
rtrn = provision.provisionRelayForNetwork(spl[1], spl[2], spl[3])
|
||||||
if rtrn == "PROVISIONED":
|
if rtrn == "PROVISIONED":
|
||||||
failure("Relay %s already provisioned for network %s" % (spl[1], spl[3]))
|
failure("Relay %s already provisioned for alias %s on network %s" % (spl[1], spl[2], spl[3]))
|
||||||
return
|
return
|
||||||
elif rtrn == "DUPLICATE":
|
elif rtrn == "DUPLICATE":
|
||||||
failure("Instance with relay %s and alias %s already exists for network %s" % (spl[1], spl[2], spl[3]))
|
failure("Instance with relay %s and alias %s already exists for network %s" % (spl[1], spl[2], spl[3]))
|
||||||
|
return
|
||||||
elif rtrn:
|
elif rtrn:
|
||||||
success("Started provisioning network %s on relay %s for alias %s" % (spl[3], spl[1], spl[2]))
|
success("Started provisioning network %s on relay %s for alias %s" % (spl[3], spl[1], spl[2]))
|
||||||
info("Instance name is %s" % rtrn)
|
info("Instance name is %s" % rtrn)
|
||||||
|
|
|
@ -121,7 +121,11 @@ class IRCBot(IRCClient):
|
||||||
nick = step[0]
|
nick = step[0]
|
||||||
if len(step) == 2:
|
if len(step) == 2:
|
||||||
step2 = step[1].split("@")
|
step2 = step[1].split("@")
|
||||||
ident, host = step2
|
if len(step2) == 2:
|
||||||
|
ident, host = step2
|
||||||
|
else:
|
||||||
|
ident = nick
|
||||||
|
host = nick
|
||||||
else:
|
else:
|
||||||
ident = nick
|
ident = nick
|
||||||
host = nick
|
host = nick
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Server(Protocol):
|
||||||
|
|
||||||
def connectionMade(self):
|
def connectionMade(self):
|
||||||
log("Connection from %s:%s" % (self.addr.host, self.addr.port))
|
log("Connection from %s:%s" % (self.addr.host, self.addr.port))
|
||||||
self.send("Hello.")
|
self.send("Greetings.")
|
||||||
|
|
||||||
def connectionLost(self, reason):
|
def connectionLost(self, reason):
|
||||||
self.authed = False
|
self.authed = False
|
||||||
|
|
|
@ -54,8 +54,8 @@ def provisionRelayForAlias(relay, alias):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def provisionRelayForNetwork(relay, alias, network):
|
def provisionRelayForNetwork(relay, alias, network):
|
||||||
if "networks" in main.relay[relay].keys():
|
if all([x in ["users", "networks"] for x in main.relay[relay].keys() if x in ["users", "networks"]]):
|
||||||
if network in main.relay[relay]["networks"]:
|
if network in main.relay[relay]["networks"] and alias in main.relay[relay]["users"]:
|
||||||
return "PROVISIONED"
|
return "PROVISIONED"
|
||||||
else:
|
else:
|
||||||
main.relay[relay]["networks"] = []
|
main.relay[relay]["networks"] = []
|
||||||
|
@ -87,5 +87,8 @@ def provisionRelayForNetwork(relay, alias, network):
|
||||||
main.saveConf("pool")
|
main.saveConf("pool")
|
||||||
if main.config["ConnectOnCreate"]:
|
if main.config["ConnectOnCreate"]:
|
||||||
startBot(network+i)
|
startBot(network+i)
|
||||||
|
else:
|
||||||
|
deliverRelayCommands(relay, {"status": ["Disconnect"]}, user=alias+"/"+network)
|
||||||
|
|
||||||
storedNetwork = True
|
storedNetwork = True
|
||||||
return network+i
|
return network+i
|
||||||
|
|
Loading…
Reference in New Issue