{"id":255,"date":"2015-11-18T17:45:42","date_gmt":"2015-11-18T17:45:42","guid":{"rendered":"http:\/\/www.haxed.me.uk\/?p=255"},"modified":"2015-11-18T17:45:42","modified_gmt":"2015-11-18T17:45:42","slug":"list-all-cloud-server-details-thru-the-api","status":"publish","type":"post","link":"https:\/\/haxed.me.uk\/index.php\/2015\/11\/18\/list-all-cloud-server-details-thru-the-api\/","title":{"rendered":"List all Cloud Server Details thru the API"},"content":{"rendered":"<p>Well, this one is a bit cheeky because I borrowed it from a colleague of mine David Coon. Thanks David, I appreciate your assistance!<\/p>\n<pre>\r\n#!\/bin\/bash\r\n\r\n\r\nauth() {\r\n    read -p \"What is your Account Number: \" ddi\r\n    read -p \"Whats your username:\" username    \r\n    read -p \"Whats your APIkey:\" APIkey\r\n    read -p \"Which Datacenter are your servers in? \" dc\r\n}\r\n\r\ntoken() {\r\n    \r\n    token=`curl -s https:\/\/identity.api.rackspacecloud.com\/v2.0\/tokens -X POST \\\r\n    -d '{\"auth\":{\"RAX-KSKEY:apiKeyCredentials\":{\"username\":\"'$username'\", \"apiKey\":\"'$APIkey'\"}}}' \\\r\n    -H \"Content-Type: application\/json\" | python -m json.tool  | sed -n '\/expires\/{n;p;}' |sed -e 's\/^.*\"id\": \"\\(.*\\)\",\/\\1\/'`\r\n    echo \"Your API Token is ---->  $token\"\r\n}\r\n\r\nlistservers() {\r\n    curl -s -H \"X-Auth-Token: $token\" \"https:\/\/$dc.servers.api.rackspacecloud.com\/v2\/$ddi\/servers\" | python -m json.tool\r\n}\r\n\r\ngetservers() {\r\n    read -p \"What is the server id?\" id\r\n    curl -s -H \"X-Auth-Token: $token\" \"https:\/\/$dc.servers.api.rackspacecloud.com\/v2\/$ddi\/servers\/$id\" | python -m json.tool\r\n}\r\n\r\nauth\r\ntoken\r\nlistservers\r\ngetservers\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Well, this one is a bit cheeky because I borrowed it from a colleague of mine David Coon. Thanks David, I appreciate your assistance! #!\/bin\/bash auth() { read -p &#8220;What is your Account Number: &#8221; ddi read -p &#8220;Whats your &hellip; <a href=\"https:\/\/haxed.me.uk\/index.php\/2015\/11\/18\/list-all-cloud-server-details-thru-the-api\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,19,15,11,12],"tags":[],"class_list":["post-255","post","type-post","status-publish","format-standard","hentry","category-api","category-bash","category-cloud","category-openstack","category-openstack-api"],"_links":{"self":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":1,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"predecessor-version":[{"id":256,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/255\/revisions\/256"}],"wp:attachment":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}