def __init__(self, hostName, port):
        # Create a socket to the Airavata Server
        transport = TSocket.TSocket(hostName,port)
        # Use Buffered Protocol to speedup over raw sockets
        transport = TTransport.TBufferedTransport(transport)

        # Airavata currently uses Binary Protocol
        protocol = TBinaryProtocol.TBinaryProtocol(transport)

        # Create a Airavata client to use the protocol encoder
        self.airavataClient = Airavata.Client(protocol)

        transport.open()
        
        client_id = r'XXXXXXXXX'
        client_secret = r'XXXXXXXXX'

        client = BackendApplicationClient(client_id=client_id)
        oauth = OAuth2Session(client=client)
        token = oauth.fetch_token(token_url='https://idp.scigap.org:9443/oauth2/token', client_id=client_id, client_secret=client_secret)
        self.authzToken = AuthzToken(token["access_token"])
        
        claimsMap = {"userName":"******","gatewayID": "Ultrascan_Production"}
        self.authzToken.claimsMap = claimsMap

        self.gateWayId = "default"

        print (self.airavataClient.getAPIVersion(self.authzToken))
Beispiel #2
0
def get_airavata_client(transport):
    # Airavata currently uses Binary Protocol
    protocol = TBinaryProtocol.TBinaryProtocol(transport)

    # Create a Airavata client to use the protocol encoder
    airavataClient = Airavata.Client(protocol)
    return airavataClient
Beispiel #3
0
    def __init__(self, config):
        # Read Airavata Client properties
        airavataConfig = ConfigParser.RawConfigParser()
        airavataConfig.read(config)

        self.host = airavataConfig.get('AiravataServer', 'host')
        self.port = airavataConfig.getint('AiravataServer', 'port')
        self.cred = airavataConfig.get('GatewayProperties', 'cred_token_id')
        self.gatewayId = airavataConfig.get('GatewayProperties', 'gateway_id')

        # Create a socket to the Airavata Server
        socket = TSocket.TSocket(self.host, self.port)
        socket.setTimeout(10000)

        # Use Buffered Protocol to speed up over raw sockets
        self.transport = TTransport.TBufferedTransport(socket)

        # Airavata currently uses Binary Protocol
        protocol = TBinaryProtocol.TBinaryProtocol(self.transport)

        # Create a Airavata client to use the protocol encoder
        self.client = Airavata.Client(protocol)

        # Create dummy token
        self.token = AuthzToken("default-token")
Beispiel #4
0
def get_airavata_client(transport):
    """Creates and returns airavata client object

    :param transport: Transport object
    :return: AiravataClient object
    """
    # Airavata currently uses Binary Protocol
    protocol = TBinaryProtocol.TBinaryProtocol(transport)

    # Create a Airavata client to use the protocol encoder
    airavataClient = Airavata.Client(protocol)
    return airavataClient
try:
    # Read Airavata Client properties
    airavataConfig = ConfigParser.RawConfigParser()
    airavataConfig.read('../conf/airavata-client.properties')

    # Create a socket to the Airavata Server
    transport = TSocket.TSocket(airavataConfig.get('AiravataServer', 'host'),
                                airavataConfig.get('AiravataServer', 'port'))

    # Use Buffered Protocol to speedup over raw sockets
    transport = TTransport.TBufferedTransport(transport)

    # Airavata currently uses Binary Protocol
    protocol = TBinaryProtocol.TBinaryProtocol(transport)

    # Create a Airavata client to use the protocol encoder
    airavataClient = Airavata.Client(protocol)

    # Connect to Airavata Server
    transport.open()

    appInterfaceLists = airavataClient.getAllApplicationInterfaces("sdsc")

    print appInterfaceLists

    # Close Connection to Airavata Server
    transport.close()

except Thrift.TException, tx:
    print '%s' % (tx.message)