ambari-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yusaku Sako <yus...@hortonworks.com>
Subject Re: Can't require('fs') in ambari-web controllers
Date Wed, 12 Nov 2014 01:37:23 GMT
Tim,

In Install Wizard, we do take user-input and invoke arbitrary commands on
the agent-side.
On the "Confirm Hosts" page, the following call is made to invoke "Host
Checks":

POST http://c6401.ambari.apache.org:8080/api/v1/requests
Form data:
{
   "RequestInfo":{
      "action":"check_host",
      "context":"Check host",
      "parameters":{
         "check_execute_list":"host_resolution_check",
         "jdk_location":"http://c6401.ambari.apache.org:8080/resources/",
         "threshold":"20",
         "hosts":"c6401.ambari.apache.org,c6402.ambari.apache.org,
c6403.ambari.apache.org"
      }
   },
   "Requests/resource_filters":[
      {
         "hosts":"c6401.ambari.apache.org,c6402.ambari.apache.org,
c6403.ambari.apache.org"
      }
   ]
}

You can see that this "check_host" custom action is defined via a file
called system_action_definitions.xml [1].
There's a corresponding "check_host.py" script that gets executed  upon
"action=check_host" API call invocation [2].

I hope this helps.
There's also a feature to allow commands directly on the server without
involving the agent, but this is WIP [3]
For now you can achieve a similar effect by executing commands on the
ambari-agent co-hosted with ambari-server.

[1]
https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/custom_action_definitions/system_action_definitions.xml#L23
[2]
https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/custom_actions/check_host.py
[3] https://issues.apache.org/jira/browse/AMBARI-7985


Yusaku


On Tue, Nov 11, 2014 at 7:01 AM, Tim <timrs2998@gmail.com> wrote:

> Yusaku Sako,
>
> I've been learning about ember and how client side frameworks work only
> recently. We have a script we'd like to run with user input during ambari
> setup in order to prepare the nodes. We have three or four different LANs
> for each node, and the script makes sure we're using the right LAN and
> hostname on each node. This isn't a use case that makes sense for anyone
> but Unisys and our clusters.
>
> So, I've added a step 3.5 to the install wizard in ambari-web which seems
> to work fine. However, it needs to give ambari-server the user input, have
> ambari-server save it to a file, and then wait for ambari-server to invoke
> and finish running the script.
>
> I've tried looking at how the other install wizard steps interact with
> ambari-server, but it doesn't make sense just yet. If you could let me know
> where to look in ambari-server, that would be help a lot.
>
> Thanks,
> Tim Schoenheider
>
> 2014-11-10 18:33 GMT-06:00 Yusaku Sako <yusaku@hortonworks.com>:
>
> > If you can describe your concrete use case, we may be able to help you
> with
> > what kind of changes should be made where.
> >
> > Yusaku
> >
> > On Mon, Nov 10, 2014 at 4:30 PM, Yusaku Sako <yusaku@hortonworks.com>
> > wrote:
> >
> > > Hi Tim,
> > >
> > > Ambari-web code runs on the browser (it's not server-side JavaScript).
> > > Ambari-web communicates with ambari-server over REST and REST only.
> > > So if you want to log stuff on the server, you need to modify
> > > ambari-server code.
> > >
> > > Yusaku
> > >
> > > On Sun, Nov 9, 2014 at 10:31 AM, Tim <timrs2998@gmail.com> wrote:
> > >
> > >> Srimanth Gunturi,
> > >>
> > >> We have a bash script that we'd like to run during the ambari install
> > >> wizard. I'm trying to add another step to the wizard that can invoke
> the
> > >> script. I'm not understanding ember as a client-side framework and how
> > >> ambari does things on the server (such as writing to disk). We
> wouldn't
> > >> submit these changes back to the community since they're oddly
> specific
> > to
> > >> our setup.
> > >>
> > >> Thanks,
> > >> Tim Schoenheider
> > >>
> > >> 2014-11-08 14:01 GMT-06:00 Srimanth Gunturi <srimanth@hortonworks.com
> >:
> > >>
> > >> > Hi Tim,
> > >> > I was hoping if you could elaborate on the use-case of why Ambari
UI
> > >> should
> > >> > access the filesystem?
> > >> > Regards,
> > >> > Srimanth
> > >> >
> > >> >
> > >> > On Sat, Nov 8, 2014 at 11:44 AM, Tim <timrs2998@gmail.com> wrote:
> > >> >
> > >> > > Hello again,
> > >> > >
> > >> > > I'm trying to do something like "var fs = require('fs')" somewhere
> > in
> > >> > > ambari-web so that I can write to a file in a controller. Adding
> it
> > to
> > >> > > "ambari-web\app\controllers\wizard\step3_controller.js", I get
> > >> > >
> > >> > > Uncaught Error: Cannot find module "fs" from
> > >> > > "controllers/wizard/step3_controller"
> > >> > >
> > >> > >
> > >> > > I get similar errors/exceptions when adding to app.js or
> > installer.js
> > >> > too.
> > >> > > My question is, how can I either require this module or write
to a
> > >> file
> > >> > in
> > >> > > one of ambari's controllers?
> > >> > >
> > >> > > Is it likely that something is wrong with my setup/node
> > installation?
> > >> It
> > >> > > seems that this should always work.
> > >> > >
> > >> > > I've tried this on a clean ambari-web without any of my changes,
> > >> > following
> > >> > >
> > >> > >
> > >> >
> > >>
> >
> https://cwiki.apache.org/confluence/display/AMBARI/Coding+Guidelines+for+Ambari
> > >> > > to acquire and build it.
> > >> > >
> > >> > > Thanks,
> > >> > > Tim Schoenheider
> > >> > >
> > >> >
> > >> > --
> > >> > CONFIDENTIALITY NOTICE
> > >> > NOTICE: This message is intended for the use of the individual or
> > >> entity to
> > >> > which it is addressed and may contain information that is
> > confidential,
> > >> > privileged and exempt from disclosure under applicable law. If the
> > >> reader
> > >> > of this message is not the intended recipient, you are hereby
> notified
> > >> that
> > >> > any printing, copying, dissemination, distribution, disclosure or
> > >> > forwarding of this communication is strictly prohibited. If you have
> > >> > received this communication in error, please contact the sender
> > >> immediately
> > >> > and delete it from your system. Thank You.
> > >> >
> > >>
> > >
> > >
> >
> > --
> > CONFIDENTIALITY NOTICE
> > NOTICE: This message is intended for the use of the individual or entity
> to
> > which it is addressed and may contain information that is confidential,
> > privileged and exempt from disclosure under applicable law. If the reader
> > of this message is not the intended recipient, you are hereby notified
> that
> > any printing, copying, dissemination, distribution, disclosure or
> > forwarding of this communication is strictly prohibited. If you have
> > received this communication in error, please contact the sender
> immediately
> > and delete it from your system. Thank You.
> >
>

-- 
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to 
which it is addressed and may contain information that is confidential, 
privileged and exempt from disclosure under applicable law. If the reader 
of this message is not the intended recipient, you are hereby notified that 
any printing, copying, dissemination, distribution, disclosure or 
forwarding of this communication is strictly prohibited. If you have 
received this communication in error, please contact the sender immediately 
and delete it from your system. Thank You.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message