OSC / ood_appkit

https://osc.github.io/Open-OnDemand/
MIT License
1 stars 2 forks source link

Add an accessor for node suffix to :ganglia server #19

Closed brianmcmichael closed 8 years ago

brianmcmichael commented 8 years ago

To request ganglia information on a particular node, the url I currently build looks like:

https://cts05.osc.edu/gweb/graph.php?c=Oakley%20nodes&z=small&cs=1468379087&g=cpu_report&h=n0601.ten.osc.edu

To get this to work, the .ten.osc.edu host suffix that appears in &h=n0601.ten.osc.edu at the end of the link is currently hard-coded at https://github.com/AweSim-OSC/osc-jobstatus/blob/master/app/views/pages/index.html.erb#L40

This is because PBS only returns the node numbers and not the full hostnames of the running nodes.

For both ruby and oakley, the suffix is .ten.osc.edu, but obviously at other sites this would change.

Not sure what the best name for this var would be, but it may be best to include it in cluster.servers[:ganglia]

nickjer commented 8 years ago

I generalized the #uri method to use a template:

TEMPLATE = '{+scheme}{host}{/segments*}{?query*}'

I also allow from the config required query parameters and optional query parameters to be specified:

        req_query:
          c: 'Ruby'
        opt_query:
          h: '%{h}.ten.osc.edu'

Optional query parameters are only used if the developer specifies it in the url, and it overrides what the developer used through string interpolation using the query parameters as the context for the interpolation.

A quick and dirty solution to get just the host suffix:

ganglia_server.opt_query[:h] % {h: ""}
#=> ".ten.osc.edu"