def GetSlotBaseDir(): global slotBaseDir try: slotBaseDir except: slotBaseDir = DefaultProperties.instance().getValue("basedir") return slotBaseDir
def CreateNewEstate(estate_name, owner_uuid): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) # starting at ParentEstateID cursor = cnx.cursor() query = \ "INSERT INTO estate_settings " + \ "(EstateName, AbuseEmailToEstateOwner, DenyAnonymous, ResetHomeOnTeleport, " + \ "FixedSun, DenyTransacted, BlockDwell, DenyIdentified, AllowVoice, " + \ "UseGlobalTime, PricePerMeter, TaxFree, AllowDirectTeleport, RedirectGridX, " + \ "RedirectGridY, ParentEstateID, SunPosition, EstateSkipScripts, BillableFactor, " + \ "PublicAccess, AbuseEmail, EstateOwner, DenyMinors) " + \ "VALUES " + \ "(%s, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, " + \ "100, 0, 0, 0, 1, '', %s, 0)" cursor.execute(query, (estate_name, owner_uuid)) estate_id = cursor.lastrowid cursor.close() cursor = cnx.cursor() #also set the parent of the new estate to itself query = \ "UPDATE estate_settings SET ParentEstateID = %s WHERE EstateID = %s;" cursor.execute(query, (estate_id, estate_id)) cnx.commit() cnx.close() return estate_id
def CreateNewEstate(estate_name, owner_uuid): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) # starting at ParentEstateID cursor = cnx.cursor() query = \ "INSERT INTO estate_settings " + \ "(EstateName, AbuseEmailToEstateOwner, DenyAnonymous, ResetHomeOnTeleport, " + \ "FixedSun, DenyTransacted, BlockDwell, DenyIdentified, AllowVoice, " + \ "UseGlobalTime, PricePerMeter, TaxFree, AllowDirectTeleport, RedirectGridX, " + \ "RedirectGridY, ParentEstateID, SunPosition, EstateSkipScripts, BillableFactor, " + \ "PublicAccess, AbuseEmail, EstateOwner, DenyMinors) " + \ "VALUES " + \ "(%s, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, " + \ "100, 0, 0, 0, 1, '', %s, 0)" cursor.execute(query, (estate_name, owner_uuid)) estate_id = cursor.lastrowid cursor.close() cursor = cnx.cursor() #also set the parent of the new estate to itself query = \ "UPDATE estate_settings SET ParentEstateID = %s WHERE EstateID = %s;" cursor.execute(query, (estate_id, estate_id)) cnx.commit() cnx.close() return estate_id
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() self.estate_owner = record.get('estate_owner') self.estate_name = record.get('estate_name') self.estate_id = record.get('estate_id') self.parent_estate_id = record.get('parent_estate_id')
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() self.estate_owner = record.get('estate_owner') self.estate_name = record.get('estate_name') self.estate_id = record.get('estate_id') self.parent_estate_id = record.get('parent_estate_id')
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() dbconfig = self.props.getCoreDbConfig() self.exe_name = "OpenSim.exe" # self.exe_args = "--console rest" self.exe_args = "" if ((not 'sim_name' in record) or (not 'sim_location_x' in record) or (not 'sim_location_y' in record) or (not 'estate_id' in record) or (not 'master_avatar_uuid' in record)): raise ServiceError("Region: Invalid Region Information provided") self.regionEntry = None self.sim_uuid = uuid self.estate_id = record['estate_id'] self.syncEstateInfoToEstateId() self.master_avatar_uuid = record['master_avatar_uuid'] self.syncOwnerInfoToMasterAvatarId() self.sim_name = record.get("sim_name") self.set_sim_location(record.get("sim_location_x"), record.get("sim_location_y")) if ('slot_number' in record): self.slot_number = int(record.get('slot_number')) self.slot_directory = provision.GetSlotDirectory(self.slot_number) else: raise ServiceError("Create failed. No Slot Number Specified") rdbHost = GetRdbHost(dbconfig, uuid) if not rdbHost: # no info? that's ok in this case we assign print "RDB server not assigned for {0}, assigning new slot".format(uuid) rdbHost = AssignBestRdbHost(dbconfig, uuid) from inworldz.maestro.RegionHost import RegionHost self.regionHost = RegionHost.instance() self.set_external_host_name(record.get('external_host_name')) self.set_outside_ip(record.get('outside_ip')) self.set_internal_ip_address(record.get('internal_ip_address')) self.set_internal_ip_port(record.get('internal_ip_port')) self.set_allow_alternate_ports(record.get('allow_alternate_ports')) self.set_lastmap_uuid(record.get("lastmap_uuid")) self.set_lastmap_refresh(record.get("lastmap_refresh")) self.set_nonphysical_prim_max(record.get("nonphysical_prim_max")) self.set_physical_prim_max(record.get("physical_prim_max")) self.set_clamp_prim_size(record.get("clamp_prim_size")) self.set_object_capacity(record.get("object_capacity")) self.set_region_product(record.get("region_product")) self.set_remoteadmin_url(record.get("remoteadmin_url")) self.remoteadmin_session = Session(self.get_remoteadmin_url()) self.remoteadmin_sessionid = None
def GetMaxRegionSlots(): global maxRegionSlots try: maxRegionSlots except: maxRegionSlots = DefaultProperties.instance().getInteger( "max_region_slots") return maxRegionSlots
def LinkRegionToExistingEstate(sim_uuid, estate_id): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = "INSERT INTO estate_map(RegionID, EstateID) VALUES(%s, %s)" args = (sim_uuid, estate_id) cursor.execute(sql, args) cnx.commit() cursor.close() cnx.close()
def LinkRegionToExistingEstate(sim_uuid, estate_id): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = "INSERT INTO estate_map(RegionID, EstateID) VALUES(%s, %s)" args = (sim_uuid, estate_id) cursor.execute(sql, args) cnx.commit() cursor.close() cnx.close()
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() if ('user_id' in record): self.user_id = str(record.get('user_id')) else: raise ServiceError("Create failed. No user id specified") self.first_name = str(record['first_name'] if 'first_name' in record else "") self.last_name = str(record['last_name'] if 'last_name' in record else "")
def LookupEstateIds(): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = "SELECT EstateID FROM estate_settings" cursor.execute(sql) result = [] for (EstateID, ) in cursor: result.append(str(EstateID)) cursor.close() return result
def LookupEstateIds(): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = "SELECT EstateID FROM estate_settings" cursor.execute(sql) result = [] for (EstateID, ) in cursor: result.append(str(EstateID)) cursor.close() return result
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() if ('user_id' in record): self.user_id = str(record.get('user_id')) else: raise ServiceError("Create failed. No user id specified") self.first_name = str(record['first_name'] if 'first_name' in record else "") self.last_name = str(record['last_name'] if 'last_name' in record else "")
def GetAvailableReleases(cls): try: props = DefaultProperties.instance() gridshare_path = props.getValue("gridshare_path") (username, password) = props.getGridShareCredentials() ConnectUNCShare(gridshare_path, username, password) return (provision.GetRevisions(gridshare_path)) except: import traceback exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) raise ServiceError(exc_value)
def FindEstateIDForRegion(sim_uuid): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = \ "SELECT estate_map.RegionID, estate_map.EstateID FROM estate_map " + \ "WHERE estate_map.RegionID = %s" cursor.execute(sql, (sim_uuid,)) estate_id = None for (RegionID, EstateID) in cursor: estate_id = str(EstateID) cursor.close() return estate_id
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() self.exe_name = "unknown" self.exe_args = "" self.remoteadmin_url = None self.remoteadmin_session = None self.remoteadmin_sessionid = None from inworldz.maestro.RegionHost import RegionHost self.regionHost = RegionHost.instance() self.service_basedir = provision.GetServiceBaseDir() self.shouldBeRunning = True
def __init__(self, auth, host = "localhost", port = DEFAULT_PORT, hosts_allowed = None): SimpleXMLRPCServer.__init__(self, (host, port), logRequests=False) self.auth = auth self.port = port self.host = host self.hosts_allowed = hosts_allowed self.ready = False self.running = True self.api = MaestroAPI(auth) or None self.props = DefaultProperties.instance()
def FindEstateIDForRegion(sim_uuid): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = \ "SELECT estate_map.RegionID, estate_map.EstateID FROM estate_map " + \ "WHERE estate_map.RegionID = %s" cursor.execute(sql, (sim_uuid, )) estate_id = None for (RegionID, EstateID) in cursor: estate_id = str(EstateID) cursor.close() return estate_id
def LookupUserIdByName(firstname, lastname): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = "SELECT UUID from users WHERE userName = %s AND lastName = %s" args = (firstname, lastname) cursor.execute(sql, args) userid = None for (user_uuid,) in cursor: userid = user_uuid cursor.close() return str(userid)
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() self.exe_name = "unknown" self.exe_args = "" self.remoteadmin_url = None self.remoteadmin_session = None self.remoteadmin_sessionid = None from inworldz.maestro.RegionHost import RegionHost self.regionHost = RegionHost.instance() self.service_basedir = provision.GetServiceBaseDir() self.shouldBeRunning = True
def GetAvailableReleases(cls): try: props = DefaultProperties.instance() gridshare_path = props.getValue("gridshare_path") (username, password) = props.getGridShareCredentials() ConnectUNCShare(gridshare_path, username, password) return (provision.GetRevisions(gridshare_path)) except: import traceback exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) raise ServiceError(exc_value)
def LookupEstateById(estate_id): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = \ "SELECT estate_settings.EstateID, estate_settings.EstateName, estate_settings.EstateOwner, estate_settings.ParentEstateID " + \ "FROM estate_settings " + \ "WHERE estate_settings.EstateID = %s" cursor.execute(sql, (estate_id,)) result = None for (EstateID, EstateName, EstateOwner, ParentEstateID) in cursor: result = (str(EstateID), str(EstateName), str(EstateOwner), str(ParentEstateID)) cursor.close() return result
def LookupUserNameById(userid): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = \ "SELECT users.userName, users.lastName FROM users " + \ "WHERE users.UUID = '" + str(userid) + "'" cursor.execute(sql, ()) result = None for (userName, lastName) in cursor: result = (str(userName), str(lastName)) cursor.close() return result
def LookupEstateById(estate_id): props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = \ "SELECT estate_settings.EstateID, estate_settings.EstateName, estate_settings.EstateOwner, estate_settings.ParentEstateID " + \ "FROM estate_settings " + \ "WHERE estate_settings.EstateID = %s" cursor.execute(sql, (estate_id, )) result = None for (EstateID, EstateName, EstateOwner, ParentEstateID) in cursor: result = (str(EstateID), str(EstateName), str(EstateOwner), str(ParentEstateID)) cursor.close() return result
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() self.set_maintenance_mode(record.get('maintenance_mode')) self.host_memory = Memory(genuuid.createString()) self.host_disk = Disk(genuuid.createString()) self.host_cpu = Cpu(genuuid.createString()) self.process = Process(genuuid.createString()) self.maxRegionSlots = provision.GetMaxRegionSlots() self.slotBaseDir = provision.GetSlotBaseDir() self.serviceBaseDir = provision.GetServiceBaseDir() self.regions = [] self.regions_lock = threading.RLock()
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() self.set_maintenance_mode(record.get('maintenance_mode')) self.host_memory = Memory(genuuid.createString()) self.host_disk = Disk(genuuid.createString()) self.host_cpu = Cpu(genuuid.createString()) self.process = Process(genuuid.createString()) self.maxRegionSlots = provision.GetMaxRegionSlots() self.slotBaseDir = provision.GetSlotBaseDir() self.serviceBaseDir = provision.GetServiceBaseDir() self.regions = [] self.regions_lock = threading.RLock()
def GetSlotDirectory(slotnum): global regionLeafBase try: regionLeafBase except: regionLeafBase = DefaultProperties.instance().getValue( "region_leaf_base") # Calculate the base directory if ((slotnum < 0) or (slotnum > GetMaxRegionSlots())): raise Exception( "GetSlotDirectory: Invalid Slot specified - {0}".format(slotnum)) elif (slotnum == 0): return (os.path.join(GetSlotBaseDir(), regionLeafBase)) else: return (os.path.join(GetSlotBaseDir(), regionLeafBase + " - " + str(slotnum)))
def starting(self): try: self.appdata = getCurrentUsersAppDataPath() self.propfile = os.path.join(self.appdata, product_name(), "maestro.config") self.address = "0.0.0.0" self.port = 12089 self.props = DefaultProperties.instance() self.props.loadConfiguration(self.propfile) self.server = MaestroServer(AUTH_WINDOWS, self.address, self.port, self.propfile) self.thread = Thread(target = self.server.run, args = ()) self.thread.start() return True except Exception, e: import traceback exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) return False
def __init__(self, auth, host="localhost", port=DEFAULT_PORT, hosts_allowed=None): SimpleXMLRPCServer.__init__(self, (host, port), logRequests=False) self.auth = auth self.port = port self.host = host self.hosts_allowed = hosts_allowed self.ready = False self.running = True self.api = MaestroAPI(auth) or None self.props = DefaultProperties.instance()
def starting(self): try: self.appdata = getCurrentUsersAppDataPath() self.propfile = os.path.join(self.appdata, product_name(), "maestro.config") self.address = "0.0.0.0" self.port = 12089 self.props = DefaultProperties.instance() self.props.loadConfiguration(self.propfile) self.server = MaestroServer(AUTH_WINDOWS, self.address, self.port, self.propfile) self.thread = Thread(target=self.server.run, args=()) self.thread.start() return True except Exception, e: import traceback exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) return False
def main(argv=None): '''Command line options.''' program_name = os.path.basename(sys.argv[0]) program_version = "v0.8" program_build_date = "%s" % __updated__ program_version_string = '%%prog %s (%s)' % (program_version, program_build_date) #program_usage = '''usage: spam two eggs''' # optional - will be autogenerated by optparse program_longdesc = '''''' # optional - give further explanation about what the program does program_license = "Copyright (c) 2015 InWorldz Inc. All Rights Reserved. Released under the Apache 2.0 License" if argv is None: argv = sys.argv[1:] try: # setup option parser parser = OptionParser(version=program_version_string, epilog=program_longdesc, description=program_license) parser.add_option("-a", "--address", dest="address", help="set the address to bind to when starting the server instance [default: %default]") parser.add_option("-p", "--port", dest="port", help="set the port to bind to when starting the server instance [default: %default]") parser.add_option("-f", "--propfile", dest="propfile", help="specify a properties file to use to define runtime properties [default: %default]") parser.add_option("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %default]") # set defaults appdata = getCurrentUsersAppDataPath() propfile = os.path.join(appdata, product_name(), "maestro.config") parser.set_defaults(address="0.0.0.0", port=DEFAULT_PORT, verbose=1, propfile=propfile) # process options (opts, args) = parser.parse_args(argv) print sys.argv[0] if opts.verbose > 0: print("verbosity level = %d" % opts.verbose) if opts.address and opts.verbose > 0: print("address = %s" % opts.address) if opts.port and opts.verbose > 0: print("port = %s" % opts.port) if opts.propfile and opts.verbose > 0: print("propfile = %s" % opts.propfile) # Load Default Properties props = DefaultProperties.instance() if (opts.propfile != None): props.loadConfiguration(propfile) #set encryption key CredentialCrypt.SECRET = props.getValue("credential_crypt_secret") CredentialCrypt.IV = props.getValue("credential_crypt_iv") # Create our server and start this up server = MaestroServer(AUTH_WINDOWS, opts.address, opts.port, opts.propfile) print "The Maestro service is ready and accepting requests." print "To stop the service simply close the console." # This will not return until exiting server.run() except Exception, e: sys.stderr.write(traceback.format_exc()) sys.stderr.write("for help use --help") return 2
props = DefaultProperties.instance() cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = \ "SELECT estate_map.RegionID, estate_map.EstateID FROM estate_map " + \ "WHERE estate_map.RegionID = %s" cursor.execute(sql, (sim_uuid, )) estate_id = None for (RegionID, EstateID) in cursor: estate_id = str(EstateID) cursor.close() return estate_id if __name__ == "__main__": import os from inworldz.util.filesystem import getCurrentUsersAppDataPath from inworldz.util.user import LookupUserIdByName from inworldz.maestro.version import product_name appdata = getCurrentUsersAppDataPath() propfile = os.path.join(appdata, product_name(), "maestro.config") props = DefaultProperties.instance() props.loadConfiguration(propfile) userid = LookupUserIdByName("Mike", "Chase") print userid estate_id = CreateNewEstate("The Rift", userid) print estate_id print LookupEstateById(estate_id) print LookupEstateIds()
cnx = mysql.connector.connect(**props.getCoreDbConfig()) cursor = cnx.cursor() sql = \ "SELECT estate_map.RegionID, estate_map.EstateID FROM estate_map " + \ "WHERE estate_map.RegionID = %s" cursor.execute(sql, (sim_uuid,)) estate_id = None for (RegionID, EstateID) in cursor: estate_id = str(EstateID) cursor.close() return estate_id if __name__ == "__main__": import os from inworldz.util.filesystem import getCurrentUsersAppDataPath from inworldz.util.user import LookupUserIdByName from inworldz.maestro.version import product_name appdata = getCurrentUsersAppDataPath() propfile = os.path.join(appdata, product_name(), "maestro.config") props = DefaultProperties.instance() props.loadConfiguration(propfile) userid = LookupUserIdByName("Mike", "Chase") print userid estate_id = CreateNewEstate("The Rift", userid) print estate_id print LookupEstateById(estate_id) print LookupEstateIds()
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() self.thisHost = RegionHost.instance() """ Should lookup and init a proxy for other hosts here also """
def __init__(self, uuid, record={}): ServiceBase.__init__(self, uuid, record) self.props = DefaultProperties.instance() self.thisHost = RegionHost.instance() """ Should lookup and init a proxy for other hosts here also """