foreman_teamdynamix 2.0.3 → 2.1.1

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: 8bd0004bd162ddf6c9bf3ed6b128fa36087c12201d507a12e4f2a9030d154a70
4
- data.tar.gz: 6624ed1dd1186c419afd646b203668fe65a6f7490bf04697c1e0aa4de130b663
3
+ metadata.gz: 9447f4fafefc51ad87b10340ee0052183a3df64aacfcee1cb4735c2a4d918b96
4
+ data.tar.gz: 5e4332b9a7ff0254c98261b58c18d4f686eba8d6ac780be964eb0e46e45f8e52
5
5
  SHA512:
6
- metadata.gz: 36a98af7c69a9f0891dbfb2bf46522034caa7785029110256fb8079e4675d911d65ebd8747efa3b30d7f6513656ee0e8bef1e4fa29074fe5fa917040febb00bc
7
- data.tar.gz: 4ee608d64ac6f046bb4301d9b9ee49109c28e8973483884bca0ca1cb3a798fca9b4d9e40b73f855c5def5d0c5cd45154b2c5cbada0f0a5c497d77461ac2823ab
6
+ metadata.gz: cd5e99aadeb49cd4ca4c9929fd6849452defb19321885d160227ba0809b5e5ecfecbc780fe62844a0fb73c082e3a58628b38ff791826281eaf95bb6fad421a44
7
+ data.tar.gz: 97aab05ff0bf96d4152114351d30a9128bf68270944a713ecd52ee22762261c75d0cad41ac2eb9522851ef6d57ffee4c844ef85020767e7767d9637181cfaa01
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
@@ -19,8 +19,8 @@ module ForemanTeamdynamix
19
19
  def teamdynamix_asset(search = false)
20
20
  @teamdynamix_asset ||= td_api.get_asset(teamdynamix_asset_uid)
21
21
 
22
- if search && !@teamdynamix_asset
23
- assets = td_api.search_asset(SerialLike: name)
22
+ if search && !@teamdynamix_asset && facts['serialnumber'].present?
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.3'.freeze
2
+ VERSION = '2.1.1'.freeze
3
3
  end
@@ -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.3
4
+ version: 2.1.1
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-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface