|
@ -101,87 +101,13 @@ def find_existing_instances( **kwargs ): |
|
|
if v > 1: |
|
|
if v > 1: |
|
|
print "Successfully connected to Murmur via connection string %s, using %s." % ( dbusName, ctl.method ) |
|
|
print "Successfully connected to Murmur via connection string %s, using %s." % ( dbusName, ctl.method ) |
|
|
|
|
|
|
|
|
servIDs = ctl.getAllServers() |
|
|
|
|
|
unseen_ids = [rec["srvid"] for rec in Mumble.objects.values( "srvid" )] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
meta = MumbleServer.objects.get( dbus=dbusName ) |
|
|
meta = MumbleServer.objects.get( dbus=dbusName ) |
|
|
except MumbleServer.DoesNotExist: |
|
|
except MumbleServer.DoesNotExist: |
|
|
meta = MumbleServer( dbus=dbusName ) |
|
|
meta = MumbleServer( dbus=dbusName ) |
|
|
finally: |
|
|
finally: |
|
|
meta.secret = icesecret |
|
|
meta.secret = icesecret |
|
|
meta.save() |
|
|
|
|
|
|
|
|
|
|
|
for id in servIDs: |
|
|
|
|
|
if id in unseen_ids: |
|
|
|
|
|
unseen_ids.remove(id) |
|
|
|
|
|
if v > 1: |
|
|
|
|
|
print "Checking Murmur instance with id %d." % id |
|
|
|
|
|
# first check that the server has not yet been inserted into the DB |
|
|
|
|
|
try: |
|
|
|
|
|
instance = Mumble.objects.get( server=meta, srvid=id ) |
|
|
|
|
|
except Mumble.DoesNotExist: |
|
|
|
|
|
values = { |
|
|
|
|
|
"server": meta, |
|
|
|
|
|
"srvid": id, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if v: |
|
|
|
|
|
print "Found new Murmur instance %d on bus '%s'... " % ( id, dbusName ) |
|
|
|
|
|
|
|
|
|
|
|
# now create a model for the record set. |
|
|
|
|
|
instance = Mumble( **values ) |
|
|
|
|
|
else: |
|
|
|
|
|
if v: |
|
|
|
|
|
print "Syncing Murmur instance %d: '%s'... " % ( instance.id, instance.name ) |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
instance.configureFromMurmur() |
|
|
|
|
|
except DatabaseError, err: |
|
|
|
|
|
try: |
|
|
|
|
|
# Find instances with the same address/port |
|
|
|
|
|
dup = Mumble.objects.get( addr=instance.addr, port=instance.port ) |
|
|
|
|
|
except Mumble.DoesNotExist: |
|
|
|
|
|
# None exist - this must've been something else. |
|
|
|
|
|
print "Server ID / Name: %d / %s" % ( instance.srvid, instance.name ) |
|
|
|
|
|
raise err |
|
|
|
|
|
else: |
|
|
|
|
|
print "ERROR: There is already another server instance registered" |
|
|
|
|
|
print " on the same address and port." |
|
|
|
|
|
print " -------------" |
|
|
|
|
|
print " New Server ID:", instance.srvid, |
|
|
|
|
|
print " New Server Name:", instance.name |
|
|
|
|
|
print " Address:", instance.addr |
|
|
|
|
|
print " Port:", instance.port |
|
|
|
|
|
print " Connection string:", instance.server.dbus |
|
|
|
|
|
print " -------------" |
|
|
|
|
|
print " Duplicate Server ID:", dup.srvid, |
|
|
|
|
|
print "Duplicate Server Name:", dup.name |
|
|
|
|
|
print " Address:", dup.addr |
|
|
|
|
|
print " Port:", dup.port |
|
|
|
|
|
print " Connection string:", dup.server.dbus |
|
|
|
|
|
return False |
|
|
|
|
|
except Exception, err: |
|
|
|
|
|
print "Server ID / Name: %d / %s" % ( instance.srvid, instance.name ) |
|
|
|
|
|
raise err |
|
|
|
|
|
|
|
|
|
|
|
# Now search for players on this server that have not yet been registered |
|
|
|
|
|
if instance.booted: |
|
|
|
|
|
if v > 1: |
|
|
|
|
|
print "Looking for registered Players on Server id %d." % id |
|
|
|
|
|
instance.readUsersFromMurmur( verbose=v ) |
|
|
|
|
|
elif v: |
|
|
|
|
|
print "This server is not running, can't sync players." |
|
|
|
|
|
|
|
|
|
|
|
signals.pre_delete.disconnect( Mumble.pre_delete_listener, sender=Mumble ) |
|
|
|
|
|
|
|
|
|
|
|
for srvid in unseen_ids: |
|
|
|
|
|
mm = Mumble.objects.get( srvid=srvid ) |
|
|
|
|
|
if v: |
|
|
|
|
|
print 'Found stale Mumble instance "%s".' % mm.name |
|
|
|
|
|
mm.delete() |
|
|
|
|
|
|
|
|
|
|
|
signals.pre_delete.connect( Mumble.pre_delete_listener, sender=Mumble ) |
|
|
|
|
|
|
|
|
meta.save(run_detection=True, verbosity=v) |
|
|
|
|
|
|
|
|
print "Successfully finished Servers and Players detection." |
|
|
print "Successfully finished Servers and Players detection." |
|
|
print "To add more servers, run this command again." |
|
|
print "To add more servers, run this command again." |
|
|