Exemplo n.º 1
0
 def delete_regions(self, client, params = None):
     if params == None:
         dialog = render_to_string("opensim/delete_region_confirmation.html")
         defer.returnValue({'data':{'dom':{'dialog':dialog}}})
     else:
         deleted_offline = []
         deleted_online = []
         for region_uuid in params:
             region = Regions().get_region(region_uuid)
             queued = Maps.render_cell(region['Location'].split(',')[0],region['Location'].split(',')[1])
             result = yield HWIOS.pb_server.radmin_proxy(region['service_uuid'],'admin_delete_region',{'region_id':region_uuid})
             if 'error' in result and result['error'] == 'SIM_OFFLINE':
                 deleted_offline.append(result['error'])
             elif 'success' in result:
                 deleted_online.append(result['success'])            
         client_response, tpl_params = self._get_regions(client)
         client_response.update({
             'status':{
                 'code':'DELETE_OK',
                 'i18n':_('Deleted: %(online)s online and %(offline)s offline region(s) ') % {'online':len(deleted_online),'offline':len(deleted_offline)},
                 'type': HWIOS.ws_realm._t['notify-info']
             },
         })
         notify_others(client, client_response,'/opensim/regions/modified/', '^/opensim/regions/$', tpl_params)
         publish_activity(client.profile, _('Region deleted'),'/opensim/regions/',[0,0,4,0,0])
         defer.returnValue(client_response)
Exemplo n.º 2
0
 def edit_region(self, client, region_uuid, params = None):
     if params == None:
         region = Regions().get_region(region_uuid)
         data = {'sim_uuid': region['RegionUUID'], 
                 'internal_ip_address':region['InternalAddress'],
                 'internal_ip_port':region['InternalPort'],
                 'external_host_name':region['ExternalHostName'],
                 'object_capacity':15000,
                 'sim_location_x':region['Location'].split(',')[0],
                 'sim_location_y':region['Location'].split(',')[1],
                 'name':region['name'],
                 'owner':None,
                 'service':region['service_uuid']}
         form = RegionForm(initial=data)
         main = render_to_string("opensim/edit_region.html", {'form':form,'region_uuid':region_uuid})
         defer.returnValue({'data':{'dom':{'main':main}}})
     else:        
         response = {'status':{}}
         profile = Profile.objects.get(pk = params['owner'])
         radmin_params = {
         'region_name':params['name'],
         'region_id':region_uuid,
         'region_x':params['sim_location_x'],
         'region_y':params['sim_location_y'],
         'region_master_uuid':profile.uuid,
         'region_master_first':profile.first_name,
         'region_master_last':profile.last_name,
         'region_master_password':'******',
         'public':'true',
         'enable_voice':'true'
         }
         #clean old map-location with an opaque tile
         region_old = Regions().get_region(region_uuid)
         old_xy = [region_old['Location'].split(',')[0],region_old['Location'].split(',')[1]]
         queued = Maps.render_cell(old_xy[0],old_xy[1])
         service_client = yield HWIOS.pb_server.search_service(params['service'])
         #if the service is not online, take the existing image
         tms_config = HWIOS.services['tms'].config
         if tms_config.getboolean('map','osm'): ztop = tms_config.get('map','osm_ztop')
         else: ztop = tms_config.get('map','raw_ztop')
         
         if service_client['service']['status'] == 'OFF':
             if tms_config.getboolean('service','ssl'):
                 image_loc = 'https://%s:%s/tiles/%s/%s/%s.%s' % (HWIOS.config.get('general','uri'),tms_config.getint('service','port'), ztop ,old_xy[0],old_xy[1],tms_config.get('map','format'))
             else:
                 image_loc = 'http://%s:%s/tiles/%s/%s/%s.%s' % (HWIOS.config.get('general','uri'),tms_config.getint('service','port'), ztop ,old_xy[0],old_xy[1],tms_config.get('map','format'))
         else:
             image_loc = 'http://%s:%s/index.php?method=regionImage%s' % (service_client['client'].peer.host, service_client['service']['port'], region_uuid.replace('-', ''))
         queued = Maps.render_cell(params['sim_location_x'],params['sim_location_y'],image_loc)
         pb_client = HWIOS.pb_server.search_client(params['service'])
         watchdog = yield pb_client.switch_watchdog(params['service'],'TRIGGER')            
         result = yield HWIOS.pb_server.radmin_proxy(params['service'],'admin_shutdown',radmin_params)
         client_response, tpl_params = self._get_regions(client)
         if 'error' in result:
             if result['error'] == 'SIM_OFFLINE': 
                 client_response.update({'status': {
                     'code':'REGION_UPDATED',
                     'i18n':_('Updated region in offline simulator!'),
                     'type': HWIOS.ws_realm._t['notify-info']
                     }
                 })
             else: 
                 client_response.update({'status': {
                     'code':result['error'],
                     'i18n':_(result['error']),
                     'type': HWIOS.ws_realm._t['notify-error']
                     }
                 })
         else: 
             client_response.update({'status': {
                 'code':'REGION_UPDATED',
                 'i18n':_('Region updated. Region service restarting with watchdog...'),
                 'type': HWIOS.ws_realm._t['notify-info']
                 }
             })
         notify_others(client, client_response,'/opensim/regions/modified/', '^/opensim/regions/$', tpl_params)
         publish_activity(client.profile, _('Region modified'),'/opensim/regions/',[0,0,4,0,0])
         defer.returnValue(client_response)
Exemplo n.º 3
0
 def _map_cb(params, region_uuid):
     service_client = HWIOS.pb_server.search_service(params['service'])
     image_loc = 'http://%s:%s/index.php?method=regionImage%s' % (service_client['client'].peer.host, service_client['service']['port'], region_uuid.replace('-', ''))
     queued = Maps.render_cell(params['sim_location_x'],params['sim_location_y'],image_loc)