MiamiOH / foreman_teamdynamix

A Foreman Plugin for TeamDynamix
GNU General Public License v3.0
1 stars 1 forks source link

Don't hardcode ids for TeamDynamix #20

Closed edestecd closed 6 years ago

edestecd commented 6 years ago

Offending code: https://github.com/MiamiOH/foreman_teamdynamix/blob/master/lib/teamdynamix_api.rb#L109 https://github.com/MiamiOH/foreman_teamdynamix/blob/master/lib/teamdynamix_api.rb#L114

https://github.com/MiamiOH/foreman_teamdynamix/blob/master/lib/teamdynamix_api.rb#L122

These should at minimum be read from the yaml config file with good instructions in the README on how to obtain them. Any non technical person should be able to find them.

It would be even better if API calls could be made in the plugin to obtain them.

These are probably not the same in our production / sandbox environments and Rails.env is not a good indicator of these. All our foreman environments run with Rails.env == production, b/c the rpm install is setup that way. We don't install from source.

nipendar commented 6 years ago

@edestecd All this information for readme is only visible to admin.

I can look into getting them through api, let me know which one you prefer.

edestecd commented 6 years ago

Fetching them through the api would be preferable, as it requires less configuration from the end user.

nipendar commented 6 years ago

After revisiting I realized that the first thing we should consider in regards to these mandatory attributes like 'mu.ci.Description' and 'mu.ci.Lifecycle Status' is that they are not common attributes but rather custom attributes specific to Miami University.

We can not predict what type of custom attribute(s) a particular user's TeamDynamix API requires. So supporting dynamism for the fields (ID, Value, etc) of those attributes through API calls or any other way will not be a very robust solution.

I think in order to make this gem really usable for others:

  1. We should let the user specify all mandatory custom attributes for a create operation via configuration.
  2. We should also restrict these attributes to have static values i.e ID and Value both need to be configured via yaml.

We can set the user expectations by adding a note about custom mandatory attributes and add an example for "How to get ID, Value etc of a custom attribute via Web UI".

edestecd commented 6 years ago

Can we have the user just set the Name of the attribute (example: 'mu.ci.Description'), then do an api call to get the ID?

edestecd commented 6 years ago

I agree these attributes, to set on create, should come from yaml. I thought you were already doing that.

nipendar commented 6 years ago

I wil have to see if there is an api call to fetch attrbutes. I figured based on existing assets. Anyways, even if we find out ID, what do we do about Value?

On Jan 30, 2018 7:44 AM, "Chris Edester" notifications@github.com wrote:

Can we have the user just set the Name of the attribute (example: 'mu.ci.Description'), then do an api call to get the ID?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MiamiOH/foreman_teamdynamix/issues/20#issuecomment-361597096, or mute the thread https://github.com/notifications/unsubscribe-auth/ABk_w1o4KEFi8aF1oeYk9KDWlLh_DQflks5tPxy7gaJpZM4Rwk25 .

nipendar commented 6 years ago

one of these may provide attribute ID from name, need to try it https://miamioh.teamdynamix.com/SBTDWebApi/Home/section/Attributes

edestecd commented 6 years ago

What is value? Can you give an example? Name: ID: Value:

nipendar commented 6 years ago

here, https://github.com/MiamiOH/foreman_teamdynamix/blob/d5c18cd23f148af8a086bef1044b989449e8b69b/lib/teamdynamix_api.rb#L116

edestecd commented 6 years ago

Oh, you meant the value to set. You could read that from yaml also and run it through eval or send to run any code.

edestecd commented 6 years ago

The yaml config file would contain exactly: Name: 'mu.ci.Description', Value: "Foreman host #{host.fqdn} created by ForemanTeamdynamix plugin"

nipendar commented 6 years ago

and ID if we can not get it through API, yet to try that

nipendar commented 6 years ago

https://miamioh.teamdynamix.com/SBTDWebApi/Home/section/Attributes This action can only be performed by special key-based administrative accounts and not standard TeamDynamix users.

This section of the api has restricted access, so I can not find out if we can get ID from attribute names or not.

edestecd commented 6 years ago

OK, we can look int making the plugin work with either admin tokens or user/pass later.