def __init__(self, url): VenueClient.__init__(self) print '--------------- SET PROFILE' profile = ClientProfile('userProfile') self.SetProfile(profile) self.profile.Dump() print '\n--------------- CREATE PROXY' try: venueUri = Client.Handle(url).get_proxy().GetDefaultVenue() print 'get url for default venue from server ', url except: venueUri = url print 'venue url: ', url print 'get proxy for venue', venueUri self.client = Client.Handle(venueUri).get_proxy() print '\n--------------- ENTER VENUE' self.EnterVenue(venueUri) print '\n--------------- ADD DATA' self.upload_url = self.client.GetUploadDescriptor() file_list = ['test_Apps.py'] DataStore.GSIHTTPUploadFiles(self.upload_url, file_list, None) print '\n--------------- REMOVE DATA' data = DataDescription3('test_Apps.py') self.client.RemoveData(data) # print '\n--------------- ADD SERVICE' # service = ServiceDescription('serviceName', 'serviceDescription', 'serviceUri',\ # 'serviceIcon', 'serviceStoragetype') # self.client.AddService(service) # print '\n--------------- REMOVE DATA' # self.client.RemoveData(data) # print '\n--------------- REMOVE SERVICE' # self.client.RemoveService(service) nodeUrl = 'http://nodeserviceurl' print '\n--------------- SET NODE SERVICE URL', nodeUrl self.SetNodeServiceUri(nodeUrl) print '--------------- NODE SERVICE URL: ', self.nodeServiceUri print '\n--------------- CHANGE PROFILE' profile2 = ClientProfile('nodeProfile') self.SetProfile(profile2) self.profile.Dump() print '\n--------------- EXIT VENUE' self.ExitVenue()
def createBrowser(venueProxy, clientObj): """ Create a new browser app. Creates the app object, joins to it, and initializes state. Returns a proxy to the application object, and its public and private IDs. """ # # Use the Venue's CreateApplication() method to create a new application instance. # Name it "Shared Browser". # log.debug("creating browser app obj") appHandle = venueProxy.CreateApplication("Shared Browser", "shared web browser") # # Get a web service proxy on that new application # appProxy = Client.Handle(appHandle).GetProxy() # # and ask it for it's unique ID. # id = appProxy.GetId() log.debug("new app has id %s", id) # # Invoke the application's Join method, which returns to us our # public and private identifiers. # (publicId, privateId) = appProxy.Join("myprofile") log.debug("Joined app, pub=%s priv=%s", publicId, privateId) # # Create a new data channel # (channelId, loc) = appProxy.CreateDataChannel(privateId) log.debug("Created channel name=%s location=%s", channelId, loc._aslist) # # And save its identifier in the application data store. # appProxy.SetData(privateId, "channel", channelId) return (appProxy, publicId, privateId)
def BasicTest(appUrl): print "App object url = ", appUrl appProxy = Client.Handle(appUrl).get_proxy() print "-- Join application" (publicToken, privateToken) = appProxy.Join() print "-- Get data channel" (channelId, eventServiceLocation) = appProxy.GetDataChannel(privateToken) print "-- Set data" testKey = "test key" testValue = "test value" appProxy.SetData(privateToken, testKey, testValue) print "-- Get data" retVal = appProxy.GetData(privateToken, testKey) if not retVal == testValue: print "FAILURE: Get data returned different value than was set" print "-- Leave" appProxy.Leave(privateToken)
import sys from AccessGrid.hosting.pyGlobus import Client import socket from AccessGrid.Types import Capability, AGResource from AccessGrid.Descriptions import AGServiceManagerDescription from AccessGrid.Descriptions import StreamDescription from AccessGrid.NetworkLocation import MulticastNetworkLocation host = socket.gethostname() nodeServiceUri = "https://localhost:11000/NodeService" if len(sys.argv) > 1: nodeServiceUri = sys.argv[1] nodesvc = Client.Handle(nodeServiceUri).get_proxy() # query available service managers smlist = Client.Handle(nodeServiceUri).get_proxy().GetServiceManagers().data print "smlist ", smlist if len(smlist) == 0: print "\n------------------ Add a Service Manager" # add known service manager smdesc = AGServiceManagerDescription( "sm1_name", 'https://%s:12000/ServiceManager' % (host)) nodesvc.AddServiceManager(smdesc) smlist = Client.Handle( nodeServiceUri).get_proxy().GetServiceManagers().data if len(smlist) != 1:
def __init__(self, arg, url, log=None): wxApp.__init__(self, arg) """ This is the constructor for the Shared Covise. """ # Initialize state in the shared covise self.url = url self.eventQueue = Queue.Queue(5) self.log = log self.masterId = None self.numSteps = 0 self.hostName = "vision.rus.uni-stuttgart.de" self.serverPort = 31098 self.masterSocket = None # Get a handle to the application object in the venue self.log.debug("Getting application proxy (%s).", url) self.appProxy = Client.Handle(self.url).GetProxy() # Join the application object, get a private ID in response self.log.debug("Joining application.") (self.publicId, self.privateId) = self.appProxy.Join() # Get the information about our Data Channel self.log.debug("Retrieving data channel information.") (self.channelId, esl) = self.appProxy.GetDataChannel(self.privateId) # Connect to the Data Channel, using the EventClient class # The EventClient class is a general Event Channel Client, but since # we use the Event Channel for a Data Channel we can use the # Event Client Class as a Data Client. For more information on the # Event Channel look in AccessGrid\EventService.py # and AccessGrid\EventClient.py self.log.debug("Connecting to data channel.") self.eventClient = EventClient(self.privateId, esl, self.channelId) self.eventClient.start() self.eventClient.Send(ConnectEvent(self.channelId, self.privateId)) # Register callbacks with the Data Channel to handle incoming # events. self.log.debug("Registering for events.") self.eventClient.RegisterCallback(SharedCovEvent.MASTER, self.RecvMaster) self.eventClient.RegisterCallback(SharedCovEvent.CLEAN, self.CleanCovise) self.masterHost = "" self.masterPort = 0 self.masterHost = self.appProxy.GetData(self.privateId, SharedCovKey.MASTERHOST) self.masterPort = self.appProxy.GetData(self.privateId, SharedCovKey.MASTERPORT) self.frame.SetMasterHost(self.masterHost + ":" + str(self.masterPort)) self.log.debug("fit.") self.log.debug("SharedCovise V1.0") # read configueation file userapp = Platform.GetUserAppPath() configFileName = userapp + "\\SharedCovise.config" configFile = None try: configFile = file(configFileName, 'r') except: print "could no open config file" if configFile != None: entry = configFile.readline(200) if entry != "": self.hostName = entry.rstrip("\n") entry = configFile.readline(200) if entry != "": self.serverPort = int(entry) self.frame.SetPort(self.serverPort) self.frame.SetHost(self.hostName) if self.masterHost == self.hostName and self.serverPort == self.serverPort: #connect to our Daemon and find out if covise is still running message = "check" try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) s.send(message) self.masterSocket = s self.appProxy.SetData(self.privateId, SharedCovKey.MASTERHOST, self.hostName) self.appProxy.SetData(self.privateId, SharedCovKey.MASTERPORT, self.serverPort) self.eventClient.Send( Event(SharedCovEvent.MASTER, self.channelId, (self.publicId, self.publicId))) Thread(target=self.monitorMaster).start() except: self.appProxy.SetData(self.privateId, SharedCovKey.MASTERHOST, "") self.appProxy.SetData(self.privateId, SharedCovKey.MASTERPORT, 0) self.eventClient.Send( Event(SharedCovEvent.MASTER, self.channelId, (self.publicId, self.publicId))) print "could not connect to AccessGridDaemon\n"
sys.exit(0) # Initialize logging #debug=1 log = InitLogging(logName, debug) # If we're not passed some url that we can use, bail showing usage if appURL == None and venueURL == None: Usage() sys.exit(0) # If we got a venueURL and not an applicationURL # This is only in the example code. When Applications are integrated # with the Venue Client, the application will only be started with # some applicatoin URL (it will never know about the Venue URL) if appURL == None and venueURL != None: venueProxy = Client.Handle(venueURL).get_proxy() appURL = venueProxy.CreateApplication(SharedCovise.appName, SharedCovise.appDescription, SharedCovise.appMimetype) log.debug("Application URL: %s", appURL) # This is all that really matters! covise = SharedCovise(0, appURL, log) covise.Start() # This is needed because COM shutdown isn't clean yet. # This should be something like: #sys.exit(0) os._exit(0)
testValue = "test value" appProxy.SetData(privateToken, testKey, testValue) print "-- Get data" retVal = appProxy.GetData(privateToken, testKey) if not retVal == testValue: print "FAILURE: Get data returned different value than was set" print "-- Leave" appProxy.Leave(privateToken) venueUrl = "https://localhost:8000/Venues/default" if len(sys.argv) > 1: venueUrl = sys.argv[1] venueProxy = Client.Handle(venueUrl).get_proxy() # # Create an application # print "-- Create application" appUrl = venueProxy.CreateApplication("test app name", "test app description", "test app mimeType") print "-- Test service reachability" try: Client.Handle(appUrl).IsValid() except: print "Application service unreachable; exiting" os._exit(1) # run the basic tests
def browser(clientObj, url): """ Main guts of the shared browser functionality. clientObj is a VenueClient instance for the venue we're connected to. url is the url to that venue. We first try to find a browser app in the venue. If one does not exist, call createBrowser() to set one up. Otherwise join to the one already there. """ prox = Client.Handle(url).GetProxy() app = findBrowser(clientObj) if app is None: appProxy, publicId, privateId = createBrowser(prox, clientObj) else: appProxy = Client.Handle(app.handle).GetProxy() (publicId, privateId) = appProxy.Join("newprof") log.debug("Joined existing app, got pub=%s priv=%s", publicId, privateId) # # Retrieve the channel id. We've stored it in the app object's # data store with a key of "channel". # channelId = appProxy.GetData(privateId, "channel") log.debug("Got channel id %s", channelId) # # Subscribe to the event channel, using the event service # location provided by the app object. # eventServiceLocation = appProxy.GetEventServiceLocation() log.debug("Got event service location=%s", eventServiceLocation._asdict) eventClient = EventClient.EventClient(eventServiceLocation) eventClient.start() eventClient.Send(Events.ConnectEvent(channelId)) # # Register our callback. # # The callback function is invoked with one argument, the data from the call. # We want that code to also have a handle on the current browser ID, so # register a lambda that defaults. # # Yah, it might be excessive language play but it's quite a useful idiom # to be familiar with. # eventClient.RegisterCallback( "browse", lambda data, id=publicId: browseCallback(id, data)) # # Loop reading URLs from the console. This takes the place of # getting actual data back from the browser. # while 1: sys.stdout.write("URL> ") l = sys.stdin.readline() if l == "": break l = l.strip() print "Sending URL ", l # # Send out the event, including our public ID in the message. # eventClient.Send(Events.Event("browse", channelId, (publicId, l))) # # All done. # appProxy.Leave(privateId)
def __init__(self, url): print "\n------------------ CONNECTING TO SERVER" serverHandle = Client.Handle(url) try: serverHandle.IsValid() except: print "Invalid server handle; exiting" sys.exit(1) self.venueServerProxy = serverHandle.get_proxy() print "------------------ CONNECT OK" # # Add a venue # print "\n------------------ INSERT VENUE" # Make a venue description venue = VenueDescription3("test venue", "test venue description") # Set Exits venue.connections["urlExit1"] = ConnectionDescription( "exit1", "test exit1", "") venue.connections["urlExit2"] = ConnectionDescription( "exit2", "test exit2", "") # Set Static Video venue.streams = [] svml = MulticastNetworkLocation("224.2.2.2", 24000, 127) staticVideoCap = Capability3(Capability3.PRODUCER, Capability3.VIDEO) venue.streams.append( StreamDescription3("Static Video", svml, staticVideoCap, 0, None, 1)) # Set Static Audio saml = MulticastNetworkLocation("224.2.2.2", 24002, 127) staticAudioCap = Capability3(Capability3.PRODUCER, Capability3.AUDIO) venue.streams.append( StreamDescription3("Static Audio", saml, staticAudioCap, 0, None, 1)) # Set Encryption venue.encryptMedia = 1 venue.encryptionKey = "1234567890" # Add the venue to the server uri = self.venueServerProxy.AddVenue(venue) self.venueProxy = Client.Handle(uri).GetProxy() # # Check that the venue has been added # print "\n------------------ All venues in server" addedVenue = None venueList = self.venueServerProxy.GetVenues() for v in venueList: print "\n name: " + v['name'] + "\n " + v['description'] if v.uri == uri: addedVenue = v print "\n------------------ Validate added venue" if addedVenue: ret = VenueCompare(addedVenue, venue) if ret[0]: print "venue corrupted on add: ", ret[1] # # Modify the venue # print "\n------------------ Modify The Venue" venue.name = "newName" venue.description = "newDescription" venue.streams = () venue.encryptMedia = 0 venue.encryptionKey = "" self.venueServerProxy.ModifyVenue(uri, venue) venueList = self.venueServerProxy.GetVenues() for v in venueList: if v.uri == uri: modifiedVenue = v ret = VenueCompare(venue, modifiedVenue) if ret[0]: print "venue corrupted on modify: ", ret[1] # # Other venue server tests # dnName = "dnName" print "\n------------------ Add Administrator " + "dn: " + dnName self.venueServerProxy.AddAdministrator(dnName) adminList = self.venueServerProxy.GetAdministrators() if dnName not in adminList: PrintError("AddAdministrator: added admin not in list") print "\n------------------ Remove the administrator" self.venueServerProxy.RemoveAdministrator(dnName) adminList = self.venueServerProxy.GetAdministrators() if dnName in adminList: PrintError("RemoveAdministrator: removed admin still in list") setAddress = "225.224.224.224" print "\n------------------ Set base address: " + setAddress self.venueServerProxy.SetBaseAddress(setAddress) getAddress = self.venueServerProxy.GetBaseAddress() print "\n------------------ Get base address: " + getAddress if not setAddress == getAddress: PrintError("SetBaseAddress/GetBaseAddress asymmetry") setMask = 20 print "\n------------------ Set mask: " + str(setMask) self.venueServerProxy.SetAddressMask(setMask) getMask = self.venueServerProxy.GetAddressMask() print "\n------------------ Get mask: " + str(getMask) if not getMask == setMask: PrintError("SetAddressMask/GetAddressMask asymmetry") setMethod = MulticastAddressAllocator.INTERVAL print "\n------------------ Set allocator = ", setMethod self.venueServerProxy.SetAddressAllocationMethod(setMethod) getMethod = self.venueServerProxy.GetAddressAllocationMethod() print "\n------------------ Get allocator = ", getMethod if not setMethod == getMethod: PrintError( "SetAddressAllocatorMethod/GetAddressAllocatorMethod asymmetry" ) setPath = "/homes/" print "\n------------------ SetStorageLocation: " + setPath self.venueServerProxy.SetStorageLocation(setPath) getPath = self.venueServerProxy.GetStorageLocation() print "\n------------------ GetStorageLocation: " + getPath if not setPath == getPath: PrintError("SetStorageLocation/GetStorageLocation asymmetry") # # Venue tests # exit1 = ConnectionDescription("Exit1", "Exit1 description", "uri exit 1") exit2 = ConnectionDescription("Exit2", "Exit2 description", "uri exit 2") setConnectionList = [exit1, exit2] print "\n------------------ Set connections", str( len(setConnectionList)) self.venueProxy.SetConnections(setConnectionList) getConnectionList = self.venueProxy.GetConnections() print "\n------------------ Get connections", str( len(getConnectionList)) if not len(getConnectionList) == len(setConnectionList): PrintError("SetConnections/GetConnections asymmetry") videoAddress = '111.111.11.111' videoPort = 1000 videoTtl = 1 print "\n------------------ Create static video stream" print '*** Static video stream:' print "host: ", videoAddress print "port: ", videoPort print "time to live: ", videoTtl venue = Client.Handle(uri).get_proxy() location = MulticastNetworkLocation(videoAddress, videoPort, videoTtl) capability = Capability3(Capability3.PRODUCER, Capability3.VIDEO) videoStreamDescription = StreamDescription3("", location, capability) videoStreamDescription.static = 1 venue.AddStream(videoStreamDescription) audioAddress = '222.222.22.222' audioPort = 2000 audioTtl = 2 print "\n------------------ Create static audio stream: " print '*** Static audio stream:' print "host: ", audioAddress print "port: ", audioPort print "time to live: ", audioTtl location = MulticastNetworkLocation(audioAddress, audioPort, audioTtl) capability = Capability3(Capability3.PRODUCER, Capability3.AUDIO) audioStreamDescription = StreamDescription3("", location, capability) audioStreamDescription.static = 1 venue.AddStream(audioStreamDescription) print "\n------------------ Get static streams" streamList = venue.GetStaticStreams() for stream in streamList: if (stream.capability.type == Capability.VIDEO): print "*** Static video stream:" print 'host: ', stream.location.host print 'port: ', stream.location.port print 'time to live: ', stream.location.ttl if not stream.location.host == videoStreamDescription.location.host: PrintError("video stream host mismatch") if not stream.location.port == videoStreamDescription.location.port: PrintError("video stream port mismatch") if not stream.location.ttl == videoStreamDescription.location.ttl: PrintError("video stream ttl mismatch") elif (stream.capability.type == Capability.AUDIO): print "\n*** Static audio stream:" print 'host: ', stream.location.host print 'port: ', stream.location.port print 'time to live: ', stream.location.ttl if not stream.location.host == audioStreamDescription.location.host: PrintError("video stream host mismatch") if not stream.location.port == audioStreamDescription.location.port: PrintError("video stream port mismatch") if not stream.location.ttl == audioStreamDescription.location.ttl: PrintError("video stream ttl mismatch") print "\n------------------ Remove static streams" streamList = venue.GetStaticStreams() for stream in streamList: venue.RemoveStream(stream) print "\n------------------ Get static streams" streamList = venue.GetStaticStreams() if len(streamList) > 0: PrintError("Streams remain after removal") encryptMedia = 1 print "\n------------------ Set venue server encryption to 1" self.venueServerProxy.SetEncryptAllMedia(encryptMedia) value = self.venueServerProxy.GetEncryptAllMedia() print "\n------------------ Get venue server encryption " + str(value) if not value == encryptMedia: PrintError("SetEncryptAllMedia/GetEncryptAllMedia asymmetry") setEncryptionKey = "123456" print "\n------------------ Set venue encryption with key = ", setEncryptionKey self.venueProxy.SetEncryptMedia(1, setEncryptionKey) getEncryptionKey = self.venueProxy.GetEncryptMedia() print "\n------------------ Get venue encryption key = " + getEncryptionKey if not setEncryptionKey == getEncryptionKey: PrintError("SetEncryptMedia/GetEncryptMedia asymmetry") print "\n------------------ Remove the venue" self.venueServerProxy.RemoveVenue(uri) self.venueServerProxy.GetVenues() print "\n------------------ All venues in server" removedVenue = None venueList = self.venueServerProxy.GetVenues() for v in venueList: print "\n name: " + v.name + "\n " + v.description if v.uri == uri: removedVenue = v if removedVenue: PrintError("RemoveVenue failed to remove venue")
# RCS-ID: # Copyright: (c) 2002-2003 # Licence: See COPYING.txt #----------------------------------------------------------------------------- from AccessGrid.hosting.pyGlobus import Client import sys """ All arguments for this test should be service urls. If there are no arguments, this test assumes a default venue server is running and checks the Version at the default location for VenueServer and Venue. """ if __name__ == "__main__": url_list = [] for arg in sys.argv[1:]: url_list.append(arg) if len(url_list) < 1: url_list = [ "https://localhost:8000/VenueServer", "https://localhost:8000/Venues/default" ] for url in url_list: proxy = Client.Handle(url).get_proxy() ver = proxy.GetAGTkVersion() print "Version:", ver, " for ", url