{"id":10541,"date":"2017-10-19T15:29:30","date_gmt":"2017-10-19T13:29:30","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/"},"modified":"2017-10-19T15:29:30","modified_gmt":"2017-10-19T13:29:30","slug":"managing-oracle-big-data-cloud-ce-with-rest-api","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/","title":{"rendered":"Managing Oracle Big Data Cloud &#8211; CE with REST API"},"content":{"rendered":"<p>In this blog post, we will see how to manage Oracle Public Cloud Big Data service Compute Edition with REST API. Scheduling the start\/stop\/restart of a metered PaaS in the Oracle Cloud can be interesting for managing efficiently the consumption of your cloud credits.<\/p>\n<p>We\u00a0should first have a look\u00a0at\u00a0the official documentation so as to understand what the API is composed of. <a title=\"https:\/\/docs.oracle.com\/en\/cloud\/paas\/big-data-compute-cloud\/csbdp\/QuickStart.html\" href=\"https:\/\/docs.oracle.com\/en\/cloud\/paas\/big-data-compute-cloud\/csbdp\/QuickStart.html\">https:\/\/docs.oracle.com\/en\/cloud\/paas\/big-data-compute-cloud\/csbdp\/QuickStart.html\u00a0 <\/a><\/p>\n<p>Use the following URL composition to get access to REST endpoint:<br \/>\n<strong>https:\/\/<span class=\"italic\">region-prefix<\/span>.oraclecloud.com\/<span class=\"italic\">resource-path<\/span><\/strong><\/p>\n<p>According to Oracle documentation, the following information should be taken into account.<\/p>\n<p><span style=\"text-decoration: underline\">Connection Information:<\/span><\/p>\n<ul>\n<li>Identity Domain: axxxxxx<\/li>\n<li>REstFull URL: https:\/\/psm.europe.oraclecloud.com\/<\/li>\n<li>username -password<\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline\">Terminology:<\/span><\/p>\n<ul>\n<li>{instanceName} = Name of the BDCS-CE service (= Cluster Name)<\/li>\n<li>{identityDomainId} = &#8220;X-ID-TENANT-NAME: axxxxxx&#8221;<\/li>\n<li>{function} = start, stop, restart<\/li>\n<li>{allServiceHosts} = the entire cluster VMs (all instances which composed the cluster)<\/li>\n<li>&#8220;Accept: &lt;value&gt;&#8221; = Media Type (default value = application\/json)<\/li>\n<\/ul>\n<p>Before starting an automation script to manage your Big Data cluster, execute single GET\/POST commands to understand how the API is working.<\/p>\n<h5>GET request: View all Service BDCS-CE instances<\/h5>\n<p><strong>\/paas\/api\/v1.1\/instancemgmt\/{identityDomainId}\/services\/BDCSCE\/instances<\/strong><\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">curl -i -X GET \n        -u \"username:password\" \n        -H \"X-ID-TENANT-NAME: axxxxxx\" \n        -H \"Accept: application\/json\" \n        \"https:\/\/psm.europe.oraclecloud.com\/paas\/api\/v1.1\/instancemgmt\/axxxxxx\/services\/BDCSCE\/instances\"<\/pre>\n<p>Result:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">HTTP\/1.1 200 OK\nServer: Oracle-Application-Server-11g\nStrict-Transport-Security: max-age=31536000;includeSubDomains\nContent-Language: en\n...\n\n{\"services\":{\"cluster-iot\":{\"...<\/pre>\n<p>According to the <a title=\"HTTP status code\" href=\"https:\/\/docs.oracle.com\/en\/cloud\/paas\/big-data-compute-cloud\/csbdp\/Status%20Codes.html\">HTTP status code<\/a>, the command was successful.<\/p>\n<h5>GET request: View a specific Service BDCS-CE instances<\/h5>\n<p>Add the instance name to get the status of a specific cluster. Note that a BDCS-CE instance is your Big Data cluster.<\/p>\n<p><strong>\/paas\/api\/v1.1\/instancemgmt\/{identityDomainId}\/services\/BDCSCE\/instances\/{instanceName}<\/strong><\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">curl -i -X GET \n        -u \"username:password\" \n        -H \"X-ID-TENANT-NAME: axxxxxx\" \n        -H \"Accept: application\/json\" \n        \"https:\/\/psm.europe.oraclecloud.com\/paas\/api\/v1.1\/instancemgmt\/axxxxxx\/services\/BDCSCE\/instances\/cluster-iot\"<\/pre>\n<p>Then use the same requests structure to start\/stop\/restart your Big Data cluster.<\/p>\n<h5>POST request: Start \/ Stop \/ Restart Service Instances BDCS-CE: cluster-iot<\/h5>\n<p><strong>\/paas\/api\/v1.1\/instancemgmt\/{identityDomainId}\/services\/BDCSCE\/instances\/{instanceName}\/hosts\/{function}<\/strong><\/p>\n<p>As it&#8217;s specified in the documentation, you need to change the media type to <strong>application\/vnd.com.oracle.oracloud.provisioning.Service+json<\/strong> and use a <strong>body parameter<\/strong> to specify which hosts you want to manage. In our case, we want to manage all cluster hosts.<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">curl -i -X POST -u \"username:password\" \n-H \"X-ID-TENANT-NAME: axxxxxx\" \n-H \"Content-Type: application\/vnd.com.oracle.oracloud.provisioning.Service+json\" \n-d '{\"allServiceHosts\":\"true\"}' \"https:\/\/psm.europe.oraclecloud.com\/paas\/api\/v1.1\/instancemgmt\/axxxxxx\/services\/BDCSCE\/instances\/cluster-iot\/hosts\/stop\"<\/pre>\n<p>You can now, start to develop an automation script to manage your Oracle Big Data Compute Edition cluster.<\/p>\n<p>Python prerequisites:<\/p>\n<p>Install Python-PIP before:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">dbi@host:~\/$ sudo apt-get install python-pip<\/pre>\n<p>Install Requests module with PIP:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">dbi@host:~\/$ sudo pip install requests<\/pre>\n<p>Code:<\/p>\n<pre class=\"brush: python; gutter: true; first-line: 1\">#!\/usr\/bin\/env python\n# -*- coding: utf-8 -*-\n\"\"\"\n__author__ = \"Mehdi Bada\"\n__company__= dbi services sa\n__version__ = \"1.0\"\n__maintainer__ = \"Mehdi Bada\"\n__email__ = \"\"\n__status__ = \"Dev\"\n\n\"\"\"\n\nimport os, sys, getopt\nimport requests\nimport simplejson\nimport json\n\n# Variables defintion.\n\nidentityDomainId=\"axxxxxx\"\ninstanceName=\"cluster-iot\"\nserver = \"https:\/\/psm.europe.oraclecloud.com\"\ncommands = ['start', 'stop', 'restart']\n\n\ndef usage():\n    print \"nScript Usage n\"\n    print \"Usage:\", sys.argv[0], \"-c [start|stop|restart] | -h n\"\n\nif len(sys.argv) &lt; 3:\n    usage()\n    sys.exit(2)\n\ntry:\n    opts, args = getopt.getopt(sys.argv[1:], \"ch\", [\"command\", \"help\"])\nexcept getopt.GetoptError:\n    usage()\n    sys.exit(2)\n\nfor opt, arg in opts:\n    if opt in (\"-h\", \"--help\"):\n        usage()\n        sys.exit()\n    elif opt in (\"-c\", \"--command\"):\n        icommand=sys.argv[2]\n        if icommand in commands:\n                icommand=sys.argv[2]\n        else:\n                usage()\n                sys.exit(2)\n\n\nurl = server + \"\/paas\/api\/v1.1\/instancemgmt\/%s\/services\/BDCSCE\/instances\/%s\/hosts\/%s\" % (identityDomainId,instanceName,icommand)\n\npayload = \"{\"allServiceHosts\":\"true\"}\"\n\nheaders = {\n    'x-id-tenant-name': \"%s\" %(identityDomainId),\n    'accept': \"application\/vnd.com.oracle.oracloud.provisioning.Service+json\",\n    'content-type': \"application\/json\",\n    'authorization': \" \",\n    }\n\nresponse = requests.request(\"POST\", url, data=payload, headers=headers)\n\n# Print the status code of the response.\nprint(\"n\")\nprint(response.status_code)\n\n# Json Parsing\ncontent=response.content\nj = simplejson.loads(content)\nprint (j['details']['message'])<\/pre>\n<p>Usage:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">dbi@host:~\/$ .\/bdcsce_start_stop_test.py -h\n\nScript Usage\n\nUsage: .\/bdcsce_start_stop_test.py -c [start|stop|restart] | -h<\/pre>\n<p>&nbsp;<\/p>\n<h5>Conclusion<\/h5>\n<p>Oracle REST API is not very well documented, that&#8217;s why multiple tests should be performed before understanding how it works.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, we will see how to manage Oracle Public Cloud Big Data service Compute Edition with REST API. Scheduling the start\/stop\/restart of a metered PaaS in the Oracle Cloud can be interesting for managing efficiently the consumption of your cloud credits. We\u00a0should first have a look\u00a0at\u00a0the official documentation so as to understand [&hellip;]<\/p>\n","protected":false},"author":109,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1183,955,59],"tags":[399,135,96],"type_dbi":[],"class_list":["post-10541","post","type-post","status-publish","format-standard","hentry","category-big-data","category-cloud","category-oracle","tag-big-data","tag-cloud","tag-oracle"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Managing Oracle Big Data Cloud - CE with REST API - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Managing Oracle Big Data Cloud - CE with REST API\" \/>\n<meta property=\"og:description\" content=\"In this blog post, we will see how to manage Oracle Public Cloud Big Data service Compute Edition with REST API. Scheduling the start\/stop\/restart of a metered PaaS in the Oracle Cloud can be interesting for managing efficiently the consumption of your cloud credits. We\u00a0should first have a look\u00a0at\u00a0the official documentation so as to understand [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-10-19T13:29:30+00:00\" \/>\n<meta name=\"author\" content=\"DevOps\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DevOps\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/\"},\"author\":{\"name\":\"DevOps\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735\"},\"headline\":\"Managing Oracle Big Data Cloud &#8211; CE with REST API\",\"datePublished\":\"2017-10-19T13:29:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/\"},\"wordCount\":387,\"commentCount\":0,\"keywords\":[\"Big Data\",\"Cloud\",\"Oracle\"],\"articleSection\":[\"Big Data\",\"Cloud\",\"Oracle\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/\",\"name\":\"Managing Oracle Big Data Cloud - CE with REST API - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2017-10-19T13:29:30+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Managing Oracle Big Data Cloud &#8211; CE with REST API\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735\",\"name\":\"DevOps\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g\",\"caption\":\"DevOps\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/devops\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Managing Oracle Big Data Cloud - CE with REST API - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/","og_locale":"en_US","og_type":"article","og_title":"Managing Oracle Big Data Cloud - CE with REST API","og_description":"In this blog post, we will see how to manage Oracle Public Cloud Big Data service Compute Edition with REST API. Scheduling the start\/stop\/restart of a metered PaaS in the Oracle Cloud can be interesting for managing efficiently the consumption of your cloud credits. We\u00a0should first have a look\u00a0at\u00a0the official documentation so as to understand [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/","og_site_name":"dbi Blog","article_published_time":"2017-10-19T13:29:30+00:00","author":"DevOps","twitter_card":"summary_large_image","twitter_misc":{"Written by":"DevOps","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/"},"author":{"name":"DevOps","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735"},"headline":"Managing Oracle Big Data Cloud &#8211; CE with REST API","datePublished":"2017-10-19T13:29:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/"},"wordCount":387,"commentCount":0,"keywords":["Big Data","Cloud","Oracle"],"articleSection":["Big Data","Cloud","Oracle"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/","url":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/","name":"Managing Oracle Big Data Cloud - CE with REST API - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2017-10-19T13:29:30+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/managing-oracle-big-data-cloud-ce-with-rest-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Managing Oracle Big Data Cloud &#8211; CE with REST API"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735","name":"DevOps","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g","caption":"DevOps"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/devops\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/10541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/109"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=10541"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/10541\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=10541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=10541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=10541"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=10541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}