Skip to content
Tom Rothe edited this page May 17, 2013 · 5 revisions

Clients

GENI AM API v3

In order to connect to other AMs there is an example implementation of a GENI AM API v3 client. Please see the test/client/ folder.

The main class needed is: GENI3Client. This class encapsulates a connection to a GENI AM API v3 server. It implements all methods of the API and manages the interaction regarding the client certificate.

If you need an Aggregate Manager to test with, you can use an AMsoil instance.

Please find more documentation in the actual class. Example code:

    # get the right paths together
    local_path = os.path.normpath(os.path.dirname(__file__))
    key_path = os.path.join(local_path, "test-key.pem")  # make sure the CA of the AM is the same which issued this certificate (e.g. copy certificates from omni)
    cert_path = os.path.join(local_path, "test-cert.pem")
    
    # instanciate the client
    client = GENI3Client('127.0.0.1', 8001, key_path, cert_path)
    
    # method calls
    print client.listResources([TEST_CREDENTIAL], True, False)
    print client.allocate(TEST_SLICE_URN, [TEST_SLICE_CREDENTIAL], TEST_REQUEST_RSPEC, datetime.now())
    print client.provision([TEST_SLICE_URN], [TEST_SLICE_CREDENTIAL], best_effort=True, end_time=datetime.now())
    
    # simple error handling
    response = client.shutdown([TEST_SLICE_URN], [TEST_SLICE_CREDENTIAL])
    client.raiseIfError(response)
    # or catch the error
    try:
       response = client.shutdown([TEST_SLICE_URN], [TEST_SLICE_CREDENTIAL])
       client.raiseIfError(response)
    except GENI3ClientError as e:
       print str(e)

Please note

  • Please find the meaning of the actual methods [geniv3rpc] GENIv3DelegateBase.
  • For all the methods on GENI3Client (e.g. listResources, describe) the given options (e.g. compress) have the default value None. This means if the caller does not change the value the client will not send this option and hence force the server to use the default. If true or false are given the options are set accordingly.
  • If a time is given (e.g. end_time), please provide the method call with a Python datetime object, the RPC-conversion will then be done for you.

Plugin The client is currently not in a plugin. If you need this please add a manifest and register it as a service.

GENI AM API v2

We also added a GENI AM API version 2 client. Please see the test/client/ folder.

The usage is very similar to the version 3 client (please read the section above).

If you need an Aggregate Manager to test with, you can use the one supplied by the gcf (e.g. call gcf$ python src/gcf-am.py).

Please find more documentation and example code in the file.

Clone this wiki locally