OpenStack CURL API Commands

I have recently worked with OpenStack and used the OpenStack API to create/delete container and upload objects.

In this post, I am going to give the commands used for that.

You would need to get an auth token first to use the Openstack API’s. To get the Auth token you again need an API call but for which you would need to pass username and password. I am not going to give that API call here. If you want, please refer the openstack documentation. Same goes for getting the OPENSTACK_OBJECT_STORE_URL. The Openstack auth token response header contains both the auth token and object store(Swift) public URL. Get those details and replace it in the below command.

Creating a container


curl -X PUT ${OPENSTACK_OBJECT_STORE_URL}/${CONTAINER_NAME} -H "X-Auth-Token: ${OPENSTACK_AUTH_TOKEN}"

Deleting a container


curl -X DELETE ${OPENSTACK_OBJECT_STORE_URL}/${CONTAINER_NAME} -H "X-Auth-Token: ${OPENSTACK_AUTH_TOKEN}"

 

Uploading an object


curl -X PUT \
"${OPENSTACK_OBJECT_STORE_URL}/${CONTAINER_NAME}/${FILE_NAME}" \
-H "X-Auth-Token: ${OPENSTACK_AUTH_TOKEN}" \
--data-binary "@${LOCAL_FILE_PATH}/${FILE_NAME}"
 

Deleting an object


curl -X DELETE \
"${OPENSTACK_OBJECT_STORE_URL}/${CONTAINER_NAME}/${FILE_NAME}" \
-H "X-Auth-Token: ${OPENSTACK_AUTH_TOKEN}" 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s