{"id":440,"date":"2016-02-12T10:05:45","date_gmt":"2016-02-12T10:05:45","guid":{"rendered":"http:\/\/www.haxed.me.uk\/?p=440"},"modified":"2016-02-12T10:05:59","modified_gmt":"2016-02-12T10:05:59","slug":"creating-rackspace-isolated-cloud-networks","status":"publish","type":"post","link":"https:\/\/haxed.me.uk\/index.php\/2016\/02\/12\/creating-rackspace-isolated-cloud-networks\/","title":{"rendered":"Creating Isolated Cloud Networks thru API in Rackspace Cloud"},"content":{"rendered":"<p>Hey! So, today I was playing around with Cloud Networking API and thought I would document the basic process of creating a network. It&#8217;s simple enough and follows the precise same logic as many of my other tutorials on cloud files, load balancers and etc.<\/p>\n<pre>\r\n#!\/bin\/bash\r\n\r\nUSERNAME='mycloudusername'\r\nAPIKEY='mycloudapikey'\r\nACCOUNT_NUMBER=10010101\r\nAPI_ENDPOINT=\"https:\/\/lon.networks.api.rackspacecloud.com\/v2.0\/\"\r\n\r\nTOKEN=`curl https:\/\/identity.api.rackspacecloud.com\/v2.0\/tokens -X POST -d '{ \"auth\":{\"RAX-KSKEY:apiKeyCredentials\": { \"username\":\"'$USERNAME'\", \"apiKey\": \"'$APIKEY'\" }} }' -H \"Content-type: application\/json\" |  python -mjson.tool | grep -A5 token | grep id | cut -d '\"' -f4`\r\n\r\ncurl -s -v  \\\r\n-H \"X-Auth-Token: $TOKEN\"  \\\r\n-H \"X-Project-Id: $ACCOUNT_NUMBER\" \\\r\n-H \"Accept: application\/json\"  \\\r\n-X POST -d @create-network.json \"$API_ENDPOINT\/networks\" | python -mjson.tool\r\n<\/pre>\n<p>For the above code to create a new network you need to create the create-network.json markup file, it needs to look like and be in this format:<\/p>\n<pre>\r\n{\r\n    \"network\":\r\n    {\r\n        \"name\": \"Isolatednet\",\r\n        \"shared\": false,\r\n        \"tenant_id\": \"10010101\"\r\n    }\r\n}\r\n<\/pre>\n<p>It&#8217;s important to note you need to define the tenant_id, thats your account number that appears in the URL when you login to mycloud control panel.<\/p>\n<p>Output looks like<\/p>\n<pre>\r\n* Connection #0 to host lon.networks.api.rackspacecloud.com left intact\r\n{\r\n    \"network\": {\r\n        \"admin_state_up\": true,\r\n        \"id\": \"ae36972f-5cba-4327-8bff-15d8b05dc3ee\",\r\n        \"name\": \"Isolatednet\",\r\n        \"shared\": false,\r\n        \"status\": \"ACTIVE\",\r\n        \"subnets\": [],\r\n        \"tenant_id\": \"10045567\"\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Hey! So, today I was playing around with Cloud Networking API and thought I would document the basic process of creating a network. It&#8217;s simple enough and follows the precise same logic as many of my other tutorials on cloud &hellip; <a href=\"https:\/\/haxed.me.uk\/index.php\/2016\/02\/12\/creating-rackspace-isolated-cloud-networks\/\">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,4,11,12,3],"tags":[],"class_list":["post-440","post","type-post","status-publish","format-standard","hentry","category-api","category-networking","category-openstack","category-openstack-api","category-security"],"_links":{"self":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/440","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=440"}],"version-history":[{"count":2,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/440\/revisions"}],"predecessor-version":[{"id":442,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/440\/revisions\/442"}],"wp:attachment":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}