<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Cloudera 5.4.x Oozie Custom Action python to configure classes and xml schema in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Cloudera-5-4-x-Oozie-Custom-Action-python-to-configure/m-p/30050#M6702</link>
    <description>&lt;P&gt;I'm not sure when I need to access the configuration from a role (or a group) as opposed to &amp;nbsp;using the service directly, but based on a separate communication I used the role. &amp;nbsp; &amp;nbsp;The snippet of code below is based on &amp;nbsp;a working version &amp;nbsp;(on a quickstart vm), and looks like:&lt;/P&gt;&lt;PRE&gt;# peforms the post install oozie service management for the red orbit module
def main():
    cmhost  = 'quickstart.cloudera'
    theUserName = "admin"
    thePassword = "admin"
    apiResource = ApiResource(cmhost, username=theUserName, password=thePassword)
    # A kludgey way of specifying the cluster, but there is only one here
    clusters = apiResource.get_all_clusters()
    # TODO: This is a kludge to resolve the cluster
    if (len(clusters) != 1):
        print "There should  one cluster, but there are " + repr(len(clusters)) + " clusters"
        sys.exit(1)
    cluster = clusters[0]
    # TODO: These parameters are appropriate for the quick start vm, are they right for our deployment?
    hueServiceName = "hue"
    oozieServiceName = "oozie"
    oozieServiceRoleName = 'oozie-OOZIE_SERVER'
    oozieService = cluster.get_service(oozieServiceName)
    hueService =   cluster.get_service(hueServiceName)

    oozieServiceRole = oozieService.get_role(oozieServiceRoleName)

    # TODO: Is this always going tobe the oozie service role's name?  We may need to use the Role Type to be safe
    originalOozieConfig = oozieServiceRole.get_config(view='full') 

    oozieConfigUpdates = { "oozie_executor_extension_classes" : "org.apache.oozie.action.hadoop.MyCustomActionExecutor",
                           "oozie_workflow_extension_schemas" : "my-custom-action-0.1.xsd" }
    for configUpdateKey in oozieConfigUpdates:
        if (configUpdateKey in originalOozieConfig):
            print  repr(configUpdateKey) + " before update has oozie configured value = " + str(originalOozieConfig[configUpdateKey])
        else:
            print repr(configUpdateKey) + " not previously configured in oozie"
    
    # stop the oozie service after stoping any services depending on oozie (i.e. hue)
    for service in [hueService, oozieService]:
        print "stopping service " + repr(service.name)
        service.stop().wait() # synchronous stop
        print "service " + repr(service.name) + " stopped"
    
    # update the configuration while the servers are quiescent
    
    updatedOozieConfig = oozieServiceRole.update_config(oozieConfigUpdates)

    print "updatedOozieConfig = " + repr(updatedOozieConfig)
    
    
    for configUpdateKey in oozieConfigUpdates:
        print 'Config after update for key = ' + repr(configUpdateKey) + " has value = " + repr(updatedOozieConfig[configUpdateKey])

    # restart the oozie service before restarting any services depending on oozie (i.e. hue)
    for service in [oozieService, hueService]:
        print "retarting service " + repr(service.name)
        service.restart().wait() # synchronous restart
        print "service " + repr(service.name) + " restarted"

    # Done!
    return&lt;/PRE&gt;</description>
    <pubDate>Sat, 25 Jul 2015 02:18:10 GMT</pubDate>
    <dc:creator>BillM.</dc:creator>
    <dc:date>2015-07-25T02:18:10Z</dc:date>
    <item>
      <title>Cloudera 5.4.x Oozie Custom Action python to configure classes and xml schema</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Cloudera-5-4-x-Oozie-Custom-Action-python-to-configure/m-p/29952#M6700</link>
      <description>&lt;P&gt;I am creating a script to automate the deployment of an oozie custom action via the cloudera manager usingthe cloudera supployed python API as seen at&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://cloudera.github.io/cm_api/docs/python-client/," target="_blank"&gt;http://cloudera.github.io/cm_api/docs/python-client/,&lt;/A&gt; but am considering the python requests library as a fallback option if needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However after reviewing the supplied documentation, it is still unclear to me how to use the interface to do the updates for the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Oozie ActionService Executor Extension Classes, and&lt;/LI&gt;&lt;LI&gt;Oozie SchemaService Workflow Extension Schemas&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I happen to test using the Quick Start VM’s, where the parameters can be seen at &lt;A href="http://quickstart.cloudera:7180/cmf/services/2/config," target="_blank"&gt;http://quickstart.cloudera:7180/cmf/services/2/config,&lt;/A&gt; if you use the Category filters on the left of the browser, selecting “Advanced” will make it easier to find the parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the python interface for both reading and writiing these parameters?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With best regards:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bill M.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 09:35:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Cloudera-5-4-x-Oozie-Custom-Action-python-to-configure/m-p/29952#M6700</guid>
      <dc:creator>BillM.</dc:creator>
      <dc:date>2022-09-16T09:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cloudera 5.4.x Oozie Custom Action python to configure classes and xml schema</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Cloudera-5-4-x-Oozie-Custom-Action-python-to-configure/m-p/29973#M6701</link>
      <description>&lt;P&gt;We carry a page in our regular documentation that maps every field you see in CM to their CM API variant names. This page can be found, for the Oozie service for example, at &lt;A href="http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/cm_props_cdh540_oozie.html" target="_blank"&gt;http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/cm_props_cdh540_oozie.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your specific two&amp;nbsp;properties, the name mapping can be found by looking at the above page as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;&lt;SPAN class="search-term"&gt;Oozie&lt;/SPAN&gt;&lt;SPAN&gt;ActionService Executor Extension Classes =&amp;gt;&amp;nbsp;&lt;SPAN class="search-term"&gt;oozie&lt;/SPAN&gt;&lt;SPAN&gt;_executor_extension_classes&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;&lt;SPAN class="search-term"&gt;Oozie&lt;/SPAN&gt;&lt;SPAN&gt;SchemaService Workflow Extension Schemas =&amp;gt;&amp;nbsp;&lt;SPAN class="search-term"&gt;oozie&lt;/SPAN&gt;&lt;SPAN&gt;_workflow_extension_schemas&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, following the updating config example at &lt;A href="http://cloudera.github.io/cm_api/docs/python-client/#configuring-services-and-roles," target="_blank"&gt;http://cloudera.github.io/cm_api/docs/python-client/#configuring-services-and-roles,&lt;/A&gt; but applying for your Oozie properties, the code would roughly look like the below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;# Get a handle to the API client
from cm_api.api_client import ApiResource

cm_host = "cm-host"
api = ApiResource(cm_host, username="admin", password="admin")

# Get cluster
cdh = None
for c in api.get_all_clusters():
  print c.name
  if c.version == "CDH5":
    cdh = c

# Get service
oozie = None
for s in cdh.get_all_services():
  print s
  if s.type == "OOZIE":
    oozie = s

oozie.update_config({'oozie_executor_extension_classes': 'com.mycompany.MyClass', 'oozie_workflow_extension_schemas': 'my-class.xsd'})&lt;/PRE&gt;&lt;P&gt;Does this help?&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jul 2015 02:05:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Cloudera-5-4-x-Oozie-Custom-Action-python-to-configure/m-p/29973#M6701</guid>
      <dc:creator>Harsh J</dc:creator>
      <dc:date>2015-07-25T02:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Cloudera 5.4.x Oozie Custom Action python to configure classes and xml schema</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Cloudera-5-4-x-Oozie-Custom-Action-python-to-configure/m-p/30050#M6702</link>
      <description>&lt;P&gt;I'm not sure when I need to access the configuration from a role (or a group) as opposed to &amp;nbsp;using the service directly, but based on a separate communication I used the role. &amp;nbsp; &amp;nbsp;The snippet of code below is based on &amp;nbsp;a working version &amp;nbsp;(on a quickstart vm), and looks like:&lt;/P&gt;&lt;PRE&gt;# peforms the post install oozie service management for the red orbit module
def main():
    cmhost  = 'quickstart.cloudera'
    theUserName = "admin"
    thePassword = "admin"
    apiResource = ApiResource(cmhost, username=theUserName, password=thePassword)
    # A kludgey way of specifying the cluster, but there is only one here
    clusters = apiResource.get_all_clusters()
    # TODO: This is a kludge to resolve the cluster
    if (len(clusters) != 1):
        print "There should  one cluster, but there are " + repr(len(clusters)) + " clusters"
        sys.exit(1)
    cluster = clusters[0]
    # TODO: These parameters are appropriate for the quick start vm, are they right for our deployment?
    hueServiceName = "hue"
    oozieServiceName = "oozie"
    oozieServiceRoleName = 'oozie-OOZIE_SERVER'
    oozieService = cluster.get_service(oozieServiceName)
    hueService =   cluster.get_service(hueServiceName)

    oozieServiceRole = oozieService.get_role(oozieServiceRoleName)

    # TODO: Is this always going tobe the oozie service role's name?  We may need to use the Role Type to be safe
    originalOozieConfig = oozieServiceRole.get_config(view='full') 

    oozieConfigUpdates = { "oozie_executor_extension_classes" : "org.apache.oozie.action.hadoop.MyCustomActionExecutor",
                           "oozie_workflow_extension_schemas" : "my-custom-action-0.1.xsd" }
    for configUpdateKey in oozieConfigUpdates:
        if (configUpdateKey in originalOozieConfig):
            print  repr(configUpdateKey) + " before update has oozie configured value = " + str(originalOozieConfig[configUpdateKey])
        else:
            print repr(configUpdateKey) + " not previously configured in oozie"
    
    # stop the oozie service after stoping any services depending on oozie (i.e. hue)
    for service in [hueService, oozieService]:
        print "stopping service " + repr(service.name)
        service.stop().wait() # synchronous stop
        print "service " + repr(service.name) + " stopped"
    
    # update the configuration while the servers are quiescent
    
    updatedOozieConfig = oozieServiceRole.update_config(oozieConfigUpdates)

    print "updatedOozieConfig = " + repr(updatedOozieConfig)
    
    
    for configUpdateKey in oozieConfigUpdates:
        print 'Config after update for key = ' + repr(configUpdateKey) + " has value = " + repr(updatedOozieConfig[configUpdateKey])

    # restart the oozie service before restarting any services depending on oozie (i.e. hue)
    for service in [oozieService, hueService]:
        print "retarting service " + repr(service.name)
        service.restart().wait() # synchronous restart
        print "service " + repr(service.name) + " restarted"

    # Done!
    return&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Jul 2015 02:18:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Cloudera-5-4-x-Oozie-Custom-Action-python-to-configure/m-p/30050#M6702</guid>
      <dc:creator>BillM.</dc:creator>
      <dc:date>2015-07-25T02:18:10Z</dc:date>
    </item>
  </channel>
</rss>

