Giter Club home page Giter Club logo

foreman_teamdynamix's Introduction

foreman_teamdynamix

A Foreman Plugin for TeamDynamix. It manages a host's life cycle as a corresponding Asset in TeamDynamix.

Installation

To install foreman_teamdynamix require it in your gem file by adding the line.

gem 'foreman_teamdynamix'

Then update foreman to include the gem with the command.

bundle update foreman_teamdynamix

Configuration

To setup the configuration file create a new file named 'foreman_teamdynamix.yaml' at the location /etc/foreman/plugins/

If there is no configuration file then the tab should not appear on the detailed hosts screen, but if there is one and it is empty then it will appear without any fields.

Example Configuration

---
:teamdynamix:
  :api:
    :url: https://miamioh.teamdynamix.com/SBTDWebApi/api
    :appId: 741
    :username: 'xxxxxx'
    :password: 'xxxxxx'
    :create:
      StatusID: 641
      AcquisitionDate: host.created_at
      OwningCustomerName: "'foreman_teamdynamix_plugin_test'"
      Attributes:
      - Name: mu.ci.Lifecycle Status
        ID: 11634
        Value: 26190
      - Name: mu.ci.Description
        ID: 11632
        Value: >-
          "created by ForemanTeamdynamix plugin, owner is #{host.owner_id}"
      - Name: Ticket Routing Details
        ID: 11636
        Value: >-
          "Asset for host running on OS #{host.operatingsystem_id}"
    :delete:
      StatusId: 642
  :fields:
    :url: https://miamioh.teamdynamix.com/SBTDNext/Apps
    Asset ID: ID
    Owner: OwningCustomerName
    Parent Asset: ParentID
    mu.ci.Description: Attributes.mu.ci.Description
    Ticket Routing Details: Attributes.Ticket Routing Details
    mu.ci.Lifecycle Status: Attributes.mu.ci.Lifecycle Status

[:api][:create] or [:delete]

  • All attributes are passed to the TeamDynamix API as is, while creating or deleting a TeamDynamix Asset.
  • An asset gets created or deleted with the Foreman Host create or delete life cycle event.

[:api][:create][Attributes]

  • To configure any Custom Attributes for the asset.
  • It must contain expected value for 'Name', 'ID' and 'Value' fields.
  • Notice the case of 'Name', 'ID' and 'Value', this must match for correct merging.
  • rest of the fields are optional, check the Custom Attribute's definition for what other fields are updatable.
  • Code evaluation is supported for custom attribute's value.

[:fields]

  • The keys are the display title and the values are the methods that are actually called to produce the value.
  • A link to the asset in Teamdynamix is displayed, if url is specified, as first field labeled as URI.
  • Nested attributes i.e custom attributes can be configured as mentioned in example configuration.
  • If an attribute or nested attribute does not exist or is not found, it would simply not be displayed.

Add additional host attribute

rake db:migrate

Verify the TeamDynamix Tab is loaded

Navigate to /hosts/, click on one of the listed host. There should be tabs: 'Properties', 'Metrics', 'Templates', 'NICs' and 'teamdynamix.title or Team Dynamix Tab'

Development mode

foreman running locally (i.e not installed via rpm/debian package) does not use settings from /etc/foreman/plugins/ Add the teamdynamix config to <foreman_repo>/config/settings.yaml

Rake Task

rake teamdynamix:sync:hosts

Scans the hosts and sync them with TeamDynamix.

  • If host has teamdynamix_asset_uid, update the corresponding TeamDynamix asset.
  • If host facts[serialnumber] matches the asset SerialNumber, update the host and the corresponding TeamDynamix asset.
  • If host has no matching asset, create an asset in TeamDynamix with configured fields.

Test mode

gem install foreman_teamdynamix --dev
rake test:foreman_teamdynamix

foreman_teamdynamix's People

Contributors

edestecd avatar farlerac avatar kobybr avatar luoymu avatar mooresm1 avatar nipendar avatar wimmeldj avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

nipendar

foreman_teamdynamix's Issues

Error when cloning existing host

Could not create the asset for the host in TeamDynamix: {"status":"400","msg":"Bad Request","body":{"ID":-1,"Message":"Name or serial number must be provided for asset records."}}

Don't hardcode ids for TeamDynamix

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.

Make a rake task to sync with TeamDynamix

What sync means:

Go through all hosts in Foreman and search for a matching Asset in TD.
If found, update the fields in the TD asset.
If not found, create a TD asset with desired fields.

We should be able to run this rake task in a cron job on regular intervals.

TeamDynamix API Search is not working or we can't figure it out

Figure out how to use this: https://miamioh.teamdynamix.com/SBTDWebApi/Home/section/Assets#POSTapi/{appId}/assets/search

So we can improve the rake task here: https://github.com/MiamiOH/foreman_teamdynamix/blob/master/lib/tasks/sync_hosts_with_teamdynamix.rake#L14

We want something like this:

Host.all.each do |h|
  # if there is a TD asset with h.teamdynamix_asset_id update it and next

  # if there is a TD asset with name or serialNumber of host.name then update it and set host.teamdynamix_asset_id and next

  # if there is not an asset then create one and set host.teamdynamix_asset_id
end

Re-use TD api auth token

In order to reuse the authentication token to TeamDynamix Api

  • set the auth token in an encrypted session
  • or reuse via singleton dependency injection

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.