Skip to content

Testing with curl

Tom Mitchell edited this page May 17, 2017 · 1 revision

Developers interested in testing the Common Federation APIs at the GENI Clearinghouse can do so using curl, a command line tool that acts as an HTTP client. The Clearinghouse APIs use XML-RPC over HTTPS. It is straightforward to make XML-RPC calls using your GPO Clearinghouse experimenter certificate.

Calling get_version

  1. Use the GENI Portal to access your experimenter certificate. If you don't already have an account on the GPO Clearinghouse, follow the instructions to access the portal or request an account.

  2. Go to the profile page, select the "SSL" tab, and either create or download your certificate.

    1. The downloaded file will contain a private key and a certificate
  3. Create a file called get_version.xml that contains an XML-RPC invocation of the get_version API method which takes no parameters:

    <?xml version="1.0"?>
    <methodCall> 
      <methodName>get_version</methodName>
      <params></params>
    </methodCall>
  4. Use curl to call get_version at the GPO Clearinghouse Slice Authority:

    curl -H "Content-type: text/xml" --cert geni-username.pem --data @get_version.xml https://ch.geni.net/SA
  5. Other authorities also respond to get_version so the same call can be made to the Member Authority by changing the URL:

    curl -H "Content-type: text/xml" --cert geni-username.pem --data @get_version.xml https://ch.geni.net/SA
  6. The Service Registry does not require client authentication so it can be called without an experimenter certificate:

    curl -H "Content-type: text/xml" --data @get_version.xml https://ch.geni.net:8444/SR

Responses

Responses from the Common Federation API always have three values: code, value, and output.

  • code is an integer that indicates the status of the invocation. Zero means success. Any other value is an error code.
  • value holds the actual data of the return if code is zero.
  • output holds a user readable error message if code is non-zero.

Here is the response from the Service Registry to the get_version call after pretty printing:

<?xml version="1.0"?>
<methodResponse>
    <params>
        <param>
            <value>
                <struct>
                    <member>
                        <name>output</name>
                        <value>
                            <nil/>
                        </value>
                    </member>
                    <member>
                        <name>code</name>
                        <value>
                            <int>0</int>
                        </value>
                    </member>
                    <member>
                        <name>value</name>
                        <value>
                            <struct>
                                <member>
                                    <name>API_VERSIONS</name>
                                    <value>
                                        <struct>
                                            <member>
                                                <name>2.0</name>
                                                <value>
                                                    <string>https://ch.geni.net:8444/SR/</string>
                                                </value>
                                            </member>
                                        </struct>
                                    </value>
                                </member>
                                <member>
                                    <name>SERVICE_TYPES</name>
                                    <value>
                                        <array>
                                            <data>
                                                <value>
                                                    <string>IRODS</string>
                                                </value>
                                                <value>
                                                    <string>PROJECT_AUTHORITY</string>
                                                </value>
                                                <value>
                                                    <string>AUTHORIZATION_SERVICE</string>
                                                </value>
                                                <value>
                                                    <string>CERTIFICATE_AUTHORITY</string>
                                                </value>
                                                <value>
                                                    <string>KEY_MANAGER</string>
                                                </value>
                                                <value>
                                                    <string>CREDENTIAL_STORE</string>
                                                </value>
                                                <value>
                                                    <string>MEMBER_AUTHORITY</string>
                                                </value>
                                                <value>
                                                    <string>SLICE_AUTHORITY</string>
                                                </value>
                                                <value>
                                                    <string>PGCH</string>
                                                </value>
                                                <value>
                                                    <string>AGGREGATE_MANAGER</string>
                                                </value>
                                                <value>
                                                    <string>LOGGING_SERVICE</string>
                                                </value>
                                                <value>
                                                    <string>WIMAX_SITE</string>
                                                </value>
                                            </data>
                                        </array>
                                    </value>
                                </member>
                                <member>
                                    <name>IMPLEMENTATION</name>
                                    <value>
                                        <struct>
                                            <member>
                                                <name>code_version</name>
                                                <value>
                                                    <string>360c1c8c63cefac33aed5237bb422e4d9de14ed4</string>
                                                </value>
                                            </member>
                                            <member>
                                                <name>code_url</name>
                                                <value>
                                                    <string>https://github.com/GENI-NSF/geni-ch</string>
                                                </value>
                                            </member>
                                            <member>
                                                <name>site_update_date</name>
                                                <value>
                                                    <string>2014-02-13 12:02:35.590788</string>
                                                </value>
                                            </member>
                                            <member>
                                                <name>code_release_date</name>
                                                <value>
                                                    <string>2014-02-13 12:02:35.590788</string>
                                                </value>
                                            </member>
                                        </struct>
                                    </value>
                                </member>
                                <member>
                                    <name>FIELDS</name>
                                    <value>
                                        <struct>
                                            <member>
                                                <name>_GENI_SERVICE_CERT_FILENAME</name>
                                                <value>
                                                    <struct>
                                                        <member>
                                                            <name>OBJECT</name>
                                                            <value>
                                                                <string>SERVICE</string>
                                                            </value>
                                                        </member>
                                                        <member>
                                                            <name>TYPE</name>
                                                            <value>
                                                                <string>STRING</string>
                                                            </value>
                                                        </member>
                                                    </struct>
                                                </value>
                                            </member>
                                            <member>
                                                <name>_GENI_SERVICE_ID</name>
                                                <value>
                                                    <struct>
                                                        <member>
                                                            <name>OBJECT</name>
                                                            <value>
                                                                <string>SERVICE</string>
                                                            </value>
                                                        </member>
                                                        <member>
                                                            <name>TYPE</name>
                                                            <value>
                                                                <string>INTEGER</string>
                                                            </value>
                                                        </member>
                                                    </struct>
                                                </value>
                                            </member>
                                        </struct>
                                    </value>
                                </member>
                                <member>
                                    <name>VERSION</name>
                                    <value>
                                        <string>2.0</string>
                                    </value>
                                </member>
                                <member>
                                    <name>SERVICES</name>
                                    <value>
                                        <array>
                                            <data>
                                                <value>
                                                    <string>SERVICE</string>
                                                </value>
                                            </data>
                                        </array>
                                    </value>
                                </member>
                            </struct>
                        </value>
                    </member>
                </struct>
            </value>
        </param>
    </params>
</methodResponse>

MA.lookup("Member")...

Here is a more complicated method call:

<?xml version="1.0"?>
<methodCall>
    <methodName>lookup</methodName>
    <params>
        <param>
            <value>
                <string>MEMBER</string>
            </value>
        </param>
        <param>
            <value>
                <array>
                    <data/>
                </array>
            </value>
        </param>
        <param>
            <value>
                <struct>
                    <member>
                        <name>match</name>
                        <value>
                            <struct>
                                <member>
                                    <name>MEMBER_URN</name>
                                    <value>urn:publicid:IDN+ch.geni.net+user+USERNAME</value>
                                </member>
                            </struct>
                        </value>
                    </member>
                </struct>
            </value>
        </param>
    </params>
</methodCall>