foreman_teamdynamix 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c1327eee9c5fff204677de526b4b9193e0ff6718f3fb34b52079e3483170a53
4
- data.tar.gz: 59bef148ded73b39050fc570aaf47d3f9ea6fa5244118a9e4134f8f8c7870592
3
+ metadata.gz: fddc99b0680ebef06e81ae528eafa0fc4b5045d909fd72140d2bd1205ab14ed8
4
+ data.tar.gz: 6cc4f879f662bf784135f8c6f47e13f25e7529264e265f83879bc913fbe664e5
5
5
  SHA512:
6
- metadata.gz: 5d09e2738e360df63c2361fef3b1d0cc668cc8f60db140c32832361d37621a356a16f9753c134def0db7ebbd5e6720c34bece1a61058353fa8e58eb512f9464c
7
- data.tar.gz: 19297ec85baba4c2138b4613279c968da0c8e60d50f25682de256aa9c5051c193d4e95a2c9a189c60d3a74d26dfa07441fb8fd29774315c3406f96c4ad299847
6
+ metadata.gz: b13180c3f09c187be6fec9e8e88b43e7c4759ef4139167fab861f84aac1ce2cdb7761f8fd3fc93ccd530d444f9aee3f36403030ce8f41fde41ce98d45f62e1eb
7
+ data.tar.gz: 7e287d4b1e2971c3ccae8f2884995cdff80fa30b53aa8197948e77aafaeeb49bace98881b22bedd276e1e908cadca6cb3703fc4db5083a886f42d4f0ea2278ec
data/README.md CHANGED
@@ -89,7 +89,7 @@ rake teamdynamix:sync:hosts
89
89
  ```
90
90
  Scans the hosts and sync them with TeamDynamix.
91
91
  * If host has teamdynamix_asset_uid, update the corresponding TeamDynamix asset.
92
- * If host name matches the asset SerialNumber, update the host and the corresponding TeamDynamix asset.
92
+ * If host facts[serialnumber] matches the asset SerialNumber, update the host and the corresponding TeamDynamix asset.
93
93
  * If host has no matching asset, create an asset in TeamDynamix with configured fields.
94
94
 
95
95
  ## Test mode
@@ -32,7 +32,7 @@ module ForemanTeamdynamix
32
32
  def asset_uri(td_pane_fields)
33
33
  if td_pane_fields[:url]
34
34
  uri = "#{td_pane_fields[:url]}/#{@asset['AppID']}/Assets/AssetDet?AssetID=#{@asset['ID']}"
35
- [[_('URI'), link_to(@asset['SerialNumber'], uri, target: '_blank', rel: 'noopener')]]
35
+ [[_('URI'), link_to(@asset['Name'], uri, target: '_blank', rel: 'noopener')]]
36
36
  else
37
37
  []
38
38
  end
@@ -20,7 +20,7 @@ module ForemanTeamdynamix
20
20
  @teamdynamix_asset ||= td_api.get_asset(teamdynamix_asset_uid)
21
21
 
22
22
  if search && !@teamdynamix_asset
23
- assets = td_api.search_asset(SerialLike: name)
23
+ assets = td_api.search_asset(SerialLike: facts['serialnumber'])
24
24
  if assets.length == 1
25
25
  @teamdynamix_asset = td_api.get_asset(assets.first['ID'])
26
26
  self.teamdynamix_asset_uid = teamdynamix_asset['ID']
@@ -110,15 +110,15 @@ class TeamdynamixApi
110
110
  def create_asset_payload(host)
111
111
  ensure_configured_create_params
112
112
  default_attrs = { 'AppID' => APP_ID,
113
- 'SerialNumber' => host.name,
114
- 'Name' => host.fqdn }
113
+ 'SerialNumber' => host.facts['serialnumber'],
114
+ 'Name' => host.name }
115
115
  evaluate_attributes(API_CONFIG[:create], host, default_attrs)
116
116
  end
117
117
 
118
118
  def update_asset_payload(host)
119
119
  default_attrs = { 'AppID' => APP_ID,
120
- 'SerialNumber' => host.name,
121
- 'Name' => host.fqdn }
120
+ 'SerialNumber' => host.facts['serialnumber'],
121
+ 'Name' => host.name }
122
122
  evaluate_attributes(API_CONFIG[:create], host, host.teamdynamix_asset.merge(default_attrs))
123
123
  end
124
124
 
@@ -1,3 +1,3 @@
1
1
  module ForemanTeamdynamix
2
- VERSION = '2.0.2'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
@@ -19,7 +19,7 @@ namespace :teamdynamix do
19
19
  updated_search = 0
20
20
  updated_id = 0
21
21
 
22
- console_user = User.find_by(login: 'foreman_console_admin')
22
+ console_user = User.new(login: 'foreman_console_admin', firstname: 'Console', lastname: 'Admin', admin: true, auth_source_id: 2, lower_login: 'foreman_console_admin', disabled: false)
23
23
  User.current = console_user
24
24
 
25
25
  hosts = Host
@@ -15,7 +15,7 @@
15
15
  "LocationRoomID": 0,
16
16
  "LocationRoomName": "None",
17
17
  "Tag": null,
18
- "SerialNumber": "delete.foreman_teamdynamix.com",
18
+ "SerialNumber": "0123456789",
19
19
  "Name": "delete.foreman_teamdynamix.com",
20
20
  "PurchaseCost": 0,
21
21
  "AcquisitionDate": "0001-01-01T05:00:00Z",
@@ -13,6 +13,7 @@ class TeamdynamixApiTest < ActiveSupport::TestCase
13
13
  end
14
14
  let(:sample_asset) { FakeTeamdynamixApi.new.get_asset }
15
15
  let(:sample_asset_id) { sample_asset['ID'].to_s }
16
+ let(:serial_number) { '0123456789' }
16
17
  let(:host_name) { 'delete.foreman_teamdynamix.com' }
17
18
  let(:get_asset_path) { "#{api_url}/#{app_id}/assets/#{sample_asset_id}" }
18
19
  let(:create_status_id) { 641 }
@@ -23,7 +24,7 @@ class TeamdynamixApiTest < ActiveSupport::TestCase
23
24
  let(:create_path) { "#{api_url}/#{app_id}/assets" }
24
25
  let(:create_payload) do
25
26
  { AppID: app_id,
26
- SerialNumber: host_name,
27
+ SerialNumber: serial_number,
27
28
  Name: host_name,
28
29
  StatusID: create_status_id,
29
30
  Attributes: custom_attributes }
@@ -54,7 +55,7 @@ class TeamdynamixApiTest < ActiveSupport::TestCase
54
55
  end
55
56
  it 'successfully creates an asset and return it' do
56
57
  asset = subject.update_asset(host)
57
- assert_equal(asset['SerialNumber'], host.name)
58
+ assert_equal(asset['SerialNumber'], host.facts['serialnumber'])
58
59
  assert_equal(asset['AppID'].to_s, app_id.to_s)
59
60
  assert_equal(asset['StatusID'], create_status_id)
60
61
  end
@@ -101,7 +102,7 @@ class TeamdynamixApiTest < ActiveSupport::TestCase
101
102
  it 'successfully creates an asset and return it' do
102
103
  asset = subject.create_asset(host)
103
104
  assert_not_nil(asset['ID'])
104
- assert_equal(asset['SerialNumber'], host.name)
105
+ assert_equal(asset['SerialNumber'], host.facts['serialnumber'])
105
106
  assert_equal(asset['AppID'].to_s, app_id.to_s)
106
107
  assert_equal(asset['StatusID'], create_status_id)
107
108
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_teamdynamix
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nipendar Tyagi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-30 00:00:00.000000000 Z
11
+ date: 2023-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface