Difference between revisions of "rOCCI:ROCCI-cli AWS Examples"
Jump to navigation
Jump to search
Line 16: | Line 16: | ||
occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action list --resource os_tpl | occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action list --resource os_tpl | ||
'''Or''' | |||
curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X GET https://awsocci.cesnet.cz:11443/-/ | \ | curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X GET https://awsocci.cesnet.cz:11443/-/ | \ | ||
Line 23: | Line 25: | ||
occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action list --resource resource_tpl | occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action list --resource resource_tpl | ||
'''Or''' | |||
curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X GET https://awsocci.cesnet.cz:11443/-/ | \ | curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X GET https://awsocci.cesnet.cz:11443/-/ | \ | ||
Line 55: | Line 59: | ||
occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action describe --resource ${VMID} | occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action describe --resource ${VMID} | ||
''' | '''Or''' | ||
curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X GET ${VMID} | curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X GET ${VMID} | ||
Line 62: | Line 66: | ||
occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action delete --resource ${VMID} | occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action delete --resource ${VMID} | ||
'''Or''' | |||
curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X DELETE ${VMID} | curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X DELETE ${VMID} |
Revision as of 11:48, 4 May 2017
This page gives simple examples of using the OCCI gateway to Amazon Services as presented at the 2017 EGI Conference and Indigo Summit. You have been probably redirected here through a QR code.
Prerequisites
You need:
- a VOMS proxy certificate. The following examples expect it to be located in file
/tmp/x509up_u`id -u`
- an OCCI client or an HTTP client
- an SSH key pair (in case you really wish to log into your virtual machines). The following examples expect your public key to be located in
~/.ssh/id_rsa.pub
Examples
Listing Available Images
occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action list --resource os_tpl
Or
curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X GET https://awsocci.cesnet.cz:11443/-/ | \ grep 'occi/infrastructure#os_tpl'
Listing Available Resource Sizes
occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action list --resource resource_tpl
Or
curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X GET https://awsocci.cesnet.cz:11443/-/ | \ grep 'occi/infrastructure#resource_tpl'
Creating a Virtual Machine
VMID=$(occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action create --resource compute \ --mixin os_tpl#ami-971238f1 --mixin resource_tpl#t2_micro --attribute occi.core.title="VMby${USER}" \ --context public_key="file://${HOME}/.ssh/id_rsa.pub" --link /network/vpc-e2e4f686)
Or
VMUUID=`uuidgen` LNKUUID=`uuidgen` VMID=$(cat << EOF | curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/plain' --data-binary @- -X POST https://awsocci.cesnet.cz:11443/compute/ | awk '{print $2}' Category: compute; scheme="http://schemas.ogf.org/occi/infrastructure#"; class="kind" Category: t2_micro;scheme="http://schemas.ec2.aws.amazon.com/occi/infrastructure/resource_tpl#";class="mixin" Category: ami-971238f1;scheme="http://occi.awsocci.cesnet.cz/occi/infrastructure/os_tpl#";class="mixin" Category: public_key;scheme="http://schemas.openstack.org/instance/credentials#";class="mixin";location="/mixin/public_key/";title="OS contextualization mixin" X-OCCI-Attribute: occi.core.id="${VMUUID}" X-OCCI-Attribute: occi.core.title="VMby${USER}" X-OCCI-Attribute: occi.compute.hostname="VMby${USER}" X-OCCI-Attribute: org.openstack.credentials.publickey.name="Public SSH key" X-OCCI-Attribute: org.openstack.credentials.publickey.data="`cat ~/.ssh/id_rsa.pub`" Link: </network/vpc-e2e4f686>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/link/networkinterface/${LNKUUID}";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id="${LNKUUID}";occi.core.target="/network/vpc-e2e4f686";occi.core.source="/compute/${VMUUID}" EOF )
Describing a Virtual Machine
occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action describe --resource ${VMID}
Or
curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X GET ${VMID}
Deleting a Virtual Machine
occi --endpoint https://awsocci.cesnet.cz:11443/ --auth x509 --user-cred /tmp/x509up_u`id -u` --voms --action delete --resource ${VMID}
Or
curl --cert /tmp/x509up_u`id -u` --key /tmp/x509up_u`id -u` -H 'Content-Type: text/occi' -X DELETE ${VMID}