{"id":10867,"date":"2024-04-06T22:07:00","date_gmt":"2024-04-07T03:07:00","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=10867"},"modified":"2024-04-03T21:52:24","modified_gmt":"2024-04-04T02:52:24","slug":"elasticsearch-to-opensearch-migration-creating-tenants","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=10867","title":{"rendered":"ElasticSearch to OpenSearch Migration: Creating Tenants"},"content":{"rendered":"\n<p>Finally, create the tenants &#8230; we&#8217;re using OAUTH for Kibana authentication, so I wasn&#8217;t able to use the API to export &#8220;saved objects&#8221;. Fortunately, we don&#8217;t have many tenants &#8230; and exporting\/importing those saved objects manually isn&#8217;t an onerous task. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport requests\nfrom requests.auth import HTTPBasicAuth\n\ndef createTenant(strTenantName, strDescription):\n        jsonAddTenant = {  &quot;description&quot;: strDescription }\n        r2 = requests.put(f&quot;https:\/\/opensearch.example.com:9200\/_opendistro\/_security\/api\/tenants\/{strTenantName}&quot;, json=jsonAddTenant, auth = HTTPBasicAuth(&#039;something&#039;, &#039;something&#039;), verify=False)\n        print(r2.text)\n        print(r2.status_code)\n\n#  Get all tenants from ES\nr = requests.get(f&quot;https:\/\/elasticsearch.example.com:9200\/_opendistro\/_security\/api\/tenants&quot;, auth = HTTPBasicAuth(&#039;something&#039;, &#039;something&#039;), verify=False)\n\ndictAllTenants = r.json()\n\nfor item in dictAllTenants.items():\n        if item&#x5B;1].get(&#039;reserved&#039;) == False:\n                createTenant(item&#x5B;0], item&#x5B;1].get(&#039;description&#039;))\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Finally, create the tenants &#8230; we&#8217;re using OAUTH for Kibana authentication, so I wasn&#8217;t able to use the API to export &#8220;saved objects&#8221;. Fortunately, we don&#8217;t have many tenants &#8230; and exporting\/importing those saved objects manually isn&#8217;t an onerous task.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1588],"tags":[1590,2001,1740],"class_list":["post-10867","post","type-post","status-publish","format-standard","hentry","category-elk","tag-elasticsearch","tag-elasticsearch-to-opensearch-migration","tag-opensearch"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/10867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10867"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/10867\/revisions"}],"predecessor-version":[{"id":10868,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/10867\/revisions\/10868"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}