[Fiware-lab-help] CDMI Endpoint & Auth

Kennedy, John M john.m.kennedy at intel.com
Thu Jan 30 19:25:00 CET 2014


Hi.
The python example I have created works for me but is failing for Adriel...and so is the portal...it appears he cannot create a container.

Can someone please check if ac at adrielcafe.com<mailto:ac at adrielcafe.com> and john.m.kennedy at intel.com<mailto:john.m.kennedy at intel.com> have the same permissions? Anyone else have any idea what might be causing such a problem?

Also it would also be interesting to know if the python script works for any of you. It is at https://forge.fi-ware.eu/plugins/mediawiki/wiki/fiware/index.php/Object_Storage_-_User_and_Programmers_Guide.

Thank you.

-          John.

From: Adriel Café [mailto:ac at adrielcafe.com]
Sent: Thursday, January 30, 2014 12:53 PM
To: Kennedy, John M; mcp at tid.es
Subject: RE: [Fiware-lab-help] CDMI Endpoint & Auth

John, thanks a lot for example in python! Is beautiful *-*

I tried to run the script from the command line as you suggest:
cdmi_demo.py <username> <password>

it can run the following commands: check_capabilities and create_container.

But when try to list_container or any other command I get:
ERROR:root:Internal Server Error
Internal Server Error
WARNING:root:An error occurred
An error occurred

I try to create a container in FI-LAB, it returns that has been created but does not appear in the list.
Is this some permission problem? Unfortunately the error message is not clear :(

________________________________
Adriel Café
Mestrando em Ciência da Computação | UFPE
Bacharel em Sistemas de Informação | FAZAG
CV Lattes<http://lattes.cnpq.br/9341145977319933>
(81) 9842-1311

[http://adrielcafe.com/images/logo-adrielcafe1.jpg]<http://adrielcafe.com>


________________________________
From: john.m.kennedy at intel.com<mailto:john.m.kennedy at intel.com>
To: ac at adrielcafe.com<mailto:ac at adrielcafe.com>; mcp at tid.es<mailto:mcp at tid.es>
Subject: RE: [Fiware-lab-help] CDMI Endpoint & Auth
Date: Tue, 28 Jan 2014 13:44:49 +0000
Hello Adriel,
Good to hear you are making progress. I think the issue is that the value required for the cdmi pycurl.URL needs to be modified slightly. It should look like 'AUTH_00000000000000000000000000000150'.

I have significantly updated the user guide at https://forge.fi-ware.eu/plugins/mediawiki/wiki/fiware/index.php/Object_Storage_-_User_and_Programmers_Guide

It now includes comprehensive curl and script examples for authentication and object storage manipulation.

I will try to document similar python examples later on today.

Kind regards,
-          John.



From: Adriel Café [mailto:ac at adrielcafe.com]
Sent: Tuesday, January 28, 2014 4:09 AM
To: Kennedy, John M; mcp at tid.es<mailto:mcp at tid.es>
Subject: RE: [Fiware-lab-help] CDMI Endpoint & Auth

John, many thanks for the sample script!

Now we managed to get the initial token, the tenant and the final token using the PycURL<http://pycurl.sourceforge.net/>:
initial_token: GB1TGwIcqU9cols1Fk_BKajInnrO8vXYVO_CpEhKYzRUUQEgTRfE9N2W6YAv1XKdPhAFZGN_96TtA4e08oAqyg
tenant: 00000000000000000000000000000903
final_token: DG-W7yzAxKmEySYH8qe51jY_jes6TDWWrD_-5aKDpjL2gQ1JKZ21T1jjGsNpegoveYnP7SVkkTE7Qkpps43Biw

But when we tried to access the CDMI commands we get the error 401 (Unauthorized).

We created this script based on your. It should create a new container, but the 401 error occurs.
   str = StringIO.StringIO()
    c = pycurl.Curl()
    c.setopt(pycurl.URL, 'http://130.206.82.9:8080/cdmi/{0}/test123'.format(tenant))
    c.setopt(pycurl.HTTPHEADER, ['Content-Type: application/cdmi-container', 'Accept: application/cdmi-container', 'X-Auth-Token: {0}'.format(final_token)])
    c.setopt(pycurl.PUT, 1)
    c.setopt(pycurl.WRITEFUNCTION, str.write)
    c.perform()

    print str.getvalue()

What are we doing wrong? :(

________________________________
Adriel Café
Mestrando em Ciência da Computação | UFPE
Bacharel em Sistemas de Informação | FAZAG
CV Lattes<http://lattes.cnpq.br/9341145977319933>
(81) 9842-1311

[http://adrielcafe.com/images/logo-adrielcafe1.jpg]<http://adrielcafe.com>


________________________________
From: john.m.kennedy at intel.com<mailto:john.m.kennedy at intel.com>
To: ac at adrielcafe.com<mailto:ac at adrielcafe.com>; mcp at tid.es<mailto:mcp at tid.es>
Subject: RE: [Fiware-lab-help] CDMI Endpoint & Auth
Date: Mon, 27 Jan 2014 09:59:12 +0000
Hi Adriel,
Yes actually I have now prepared a script that demonstrates the various calls - and uploading and downloading an both simple text content and a binary file. It works on Ubuntu 13.10 with curl installed.

I will post it online shortly, but pls find it attached and paste below in case a firewall blocks it.

Hope this helps,
-          John.


#!/bin/bash
#
# Simple script to show some accesses to CD MI on devstack using curl
#
# Basic flow is :
#   Retrieve token
#   Check container 'capabilities'
#   Create a container, check it
#   Put an object in the container, read it, delete it - simple data
#   Put an object in the container, read it, delete it - user supplied data file
#   Delete the container
#
# There are some pauses in case the user wants to check container using the web
# portal
#
#
#-------------------------------------------------------------------------------
#
#
# Begin
username='youremail at organisation.com'
password='yourpassword'
#
node_auth='cloud.lab.fi-ware.eu'
node_cdmi='130.206.82.9'
mycontainer=CDMI_TEST
mydata='HelloWorld.txt'
myobject='CDMI_object_test_data.dat'
myobjectreceived='CDMI_object_test_data_received.dat'
#
# Initialisation check
#
if [ -f $myobject ]
then
    echo "Initialisation check complete"
else
    echo "Please create a file " $myobject " containing some test content."
    exit
fi
#
#
# Note .. assume write access to local directory
#
# Get initial token for a user/password combination
#
curl -d '{"auth": {"passwordCredentials": {"username":"'$username'", "password":"'$password'"}}}' \
     -H 'Content-type: aplication/json' \
     http://$node_auth:4730/v2.0/tokens \
     > auth_token1.dat
#
token1=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                        {if($i~/id\042/)
                          {print $(i+1)}
                        }
                      }' auth_token1.dat | awk -F'"' '{print $2; exit}')
#
# Now get a valid tenantName for this token
#
curl -H 'x-auth-token: '$token1 \
      http://$node_auth:4730/v2.0/tenants \
      > auth_tenant.dat
#
tenantName=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                        {if($i~/id\042/)
                          {print $(i+1)}
                        }
                      }' auth_tenant.dat | awk -F'"' '{print $2; exit}')
#
# Now get valid taken for user/password/tenant combination
#
curl -v \
    -d '{ "auth" :
           { "passwordCredentials" :
             { "username" : "'$username'" , "password" : "'$password'" },
           "tenantName" : "'$tenantName'" }
         }' \
     -H "Content-Type: application/json" \
      http://$node_auth:4730/v2.0/tokens \
      > auth_token2.dat
#
token=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                        {if($i~/id\042/)
                          {print $(i+1)}
                        }
                      }' auth_token2.dat | awk -F'"' '{print $2; exit}')
auth=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                       {if($i~/publicURL\042/)
                         {print $(i+3)}
                       }
                     }' auth_token2.dat | \
   grep  "v1/AUTH" | awk -F'"}]' '{print $1;}' | awk -F"/" '{print $3;}' )
#
# We need these two for any access to the CDMI proxy
#
echo " The TOKEN is : $token"
echo " The AUTH is  : $auth"
export token auth
#
#
echo " "
echo " "
#
# Now use acquired info to enquire the cdmi capabilities
#
echo "*** Enquire CDMI Capabilities"
curl -v \
   & nbsp; -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Accept: application/cdmi-capability' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/cdmi_capabilities/
#
#
echo " "
echo " "
echo "*** Create a new Container"
curl -v -X PUT \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: appli cation/cdmi-container' \
     -H 'Accept: application/cdmi-container' \
     -d '{"metadata": {}}' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/
#
#
echo " "
echo " "
echo "*** Check the 'capabilities' on the container"
curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Accept: application/cdmi-capability' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/cdmi_capabilities/container/$mycontainer/
#
#
echo " "
echo " "
echo "*** Place a Data Object in the container"
curl -v -X PUT \
     -H 'X-Auth-Token: '$token \
     -H 'Accept: application/cdmi-object' \
     -H 'Content-Type: application/cdmi-object' \
     -d '{"mimetype":"text/plain", "metadata":{}, "value" : "Hello CDMI World"}' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$mydata
#
#
echo " "
echo " "
echo "*** List Contents of a container"
curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-container' \
     -H 'Accept: */*' \
    -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/
#
#
echo " "
echo " "
echo -n "There should now be an object in the container. Press Enter to continue."
read
#
#
echo " "
echo " "
echo "*** Read Contents of Data Object"
curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Accept: application/cdmi-object' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$mydata
#
#
echo " "
echo " "
echo "*** Read only the Value of a Data Object"
curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$mydata
#
#
echo " "
echo " "
echo "*** Delete the Data Object"
curl -v \
     -X DELETE \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-object' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$mydata
#
#
echo " "
echo " "
echo "*** List Contents of a container"
curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-container' \
     -H 'Accept: */*' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/
#
#
echo " "
echo " "
echo -n "The container should now be empty. Press Enter to continue."
read
#
#
echo " "
echo " "
echo "*** Copy a file up to the Data Object"
curl -v \
     -X PUT \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/stream-octet' \
     -H 'Accept: */*' \
     --data-binary "@$myobject" \
     http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$myobject
#
#
echo " "
echo " "
echo "*** List Contents of a container"
curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-container' \
     -H 'Accept: */*' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/
#
#
echo " "
echo " "
echo -n "There should now be an object in the container. Press Enter to continue."
read
#
#
echo " "
echo " "
echo "*** Read Data back from Data Object"
curl -X GET \
     -H 'X-Auth-Token: '$token \
     http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$myobject \
      --output $myobjectreceived
#
#
echo " "
echo " "
echo "*** Delete the Data Object, tidy up"
curl -v \
     -X DELETE \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-object' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$myobject
#
#
echo " "
echo " "
echo "*** Delete the Container, tidy up"
curl -v \
    -X DELETE \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-object' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer
#
#
echo " "
echo "*** Done"
exit



-------------------------------------------------------------
Intel Ireland Limited (Branch)
Collinstown Industrial Park, Leixlip, County Kildare, Ireland
Registered Number: E902934
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------------------------------------------------------
Intel Ireland Limited (Branch)
Collinstown Industrial Park, Leixlip, County Kildare, Ireland
Registered Number: E902934
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------------------------------------------------------
Intel Ireland Limited (Branch)
Collinstown Industrial Park, Leixlip, County Kildare, Ireland
Registered Number: E902934

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fiware.org/private/fiware-lab-help/attachments/20140130/8108217a/attachment.html>


More information about the Fiware-lab-help mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy