foreman_azure_rm 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{lib → app/lib}/foreman_azure_rm/azure_sdk_adapter.rb +24 -25
- data/lib/foreman_azure_rm/engine.rb +13 -19
- data/lib/foreman_azure_rm/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 670bd7e4c753d63c24b4efc5d5f22104fd8ec5400912411cfe6a283bf9e01044
|
4
|
+
data.tar.gz: 19445ca94e173aad6869b27c6691abbab24995046c459e09f2446098e8c0b60c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81c8664096dae3577cbd45d47e1549d4a753edf63baf6a7b189628bbdc9f24980f89877542afd242ca0a7d31d953b008d309350a529ec52ef594ecb358d34f0b
|
7
|
+
data.tar.gz: 1fb422fabc9b0404c7978d798b511ae85a90ef341415cf30c4f4887ddc47eb908c55cdf57498fbe39d82ec52bce1591518fee50674f2cd8ff7a5c1d7000750cc
|
@@ -11,7 +11,7 @@ module ForemanAzureRm
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def resource_client
|
14
|
-
#resource_manager_endpoint_url
|
14
|
+
# resource_manager_endpoint_url
|
15
15
|
@resource_client ||= Resources::Client.new(azure_credentials(@environment_settings.resource_manager_endpoint_url))
|
16
16
|
end
|
17
17
|
|
@@ -33,11 +33,12 @@ module ForemanAzureRm
|
|
33
33
|
|
34
34
|
def azure_credentials(base_url)
|
35
35
|
provider = MsRestAzure::ApplicationTokenProvider.new(
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
@tenant,
|
37
|
+
@app_ident,
|
38
|
+
@secret_key,
|
39
|
+
@ad_settings
|
40
|
+
)
|
41
|
+
|
41
42
|
credentials = MsRest::TokenCredentials.new(provider)
|
42
43
|
|
43
44
|
{
|
@@ -46,7 +47,7 @@ module ForemanAzureRm
|
|
46
47
|
client_id: @app_ident,
|
47
48
|
client_secret: @secret_key,
|
48
49
|
subscription_id: @sub_id,
|
49
|
-
base_url: base_url
|
50
|
+
base_url: base_url,
|
50
51
|
}
|
51
52
|
end
|
52
53
|
|
@@ -91,7 +92,7 @@ module ForemanAzureRm
|
|
91
92
|
end
|
92
93
|
|
93
94
|
def rgs
|
94
|
-
rgs
|
95
|
+
rgs = resource_client.resource_groups.list
|
95
96
|
rgs.map(&:name)
|
96
97
|
end
|
97
98
|
|
@@ -107,7 +108,7 @@ module ForemanAzureRm
|
|
107
108
|
network_client.public_ipaddresses.get(rg_name, pip_name)
|
108
109
|
end
|
109
110
|
|
110
|
-
def vm_nic(rg_name,nic_name)
|
111
|
+
def vm_nic(rg_name, nic_name)
|
111
112
|
network_client.network_interfaces.get(rg_name, nic_name)
|
112
113
|
end
|
113
114
|
|
@@ -120,14 +121,15 @@ module ForemanAzureRm
|
|
120
121
|
end
|
121
122
|
|
122
123
|
def list_vm_sizes(region)
|
123
|
-
return []
|
124
|
+
return [] if region.blank?
|
125
|
+
|
124
126
|
stripped_region = region.gsub(/\s+/, '').downcase
|
125
|
-
compute_client.virtual_machine_sizes.list(stripped_region).value
|
127
|
+
compute_client.virtual_machine_sizes.list(stripped_region).value
|
126
128
|
end
|
127
129
|
|
128
130
|
def list_vms(region)
|
129
131
|
# List all VMs in a resource group
|
130
|
-
|
132
|
+
compute_client.virtual_machines.list_by_location(region)
|
131
133
|
end
|
132
134
|
|
133
135
|
def get_vm(rg_name, vm_name)
|
@@ -166,7 +168,7 @@ module ForemanAzureRm
|
|
166
168
|
compute_client.gallery_image_versions.list_by_gallery_image(rg_name, gallery_name, gallery_image_name)
|
167
169
|
end
|
168
170
|
|
169
|
-
def get_storage_accts
|
171
|
+
def get_storage_accts # rubocop:disable Naming/AccessorMethodName
|
170
172
|
result = storage_client.storage_accounts.list
|
171
173
|
result.value
|
172
174
|
end
|
@@ -177,9 +179,9 @@ module ForemanAzureRm
|
|
177
179
|
|
178
180
|
def create_or_update_vm_extensions(rg_name, vm_name, vm_extension_name, extension_params)
|
179
181
|
compute_client.virtual_machine_extensions.create_or_update(rg_name,
|
180
|
-
|
181
|
-
|
182
|
-
|
182
|
+
vm_name,
|
183
|
+
vm_extension_name,
|
184
|
+
extension_params)
|
183
185
|
end
|
184
186
|
|
185
187
|
def create_or_update_pip(rg_name, pip_name, parameters)
|
@@ -207,7 +209,7 @@ module ForemanAzureRm
|
|
207
209
|
end
|
208
210
|
|
209
211
|
def check_vm_status(rg_name, vm_name)
|
210
|
-
virtual_machine = compute_client.virtual_machines.get(rg_name, vm_name, expand:'instanceView')
|
212
|
+
virtual_machine = compute_client.virtual_machines.get(rg_name, vm_name, expand: 'instanceView')
|
211
213
|
get_status(virtual_machine)
|
212
214
|
end
|
213
215
|
|
@@ -215,9 +217,7 @@ module ForemanAzureRm
|
|
215
217
|
vm_statuses = virtual_machine.instance_view.statuses
|
216
218
|
vm_status = nil
|
217
219
|
vm_statuses.each do |status|
|
218
|
-
if status.code.include? 'PowerState'
|
219
|
-
vm_status = status.code.split('/')[1]
|
220
|
-
end
|
220
|
+
vm_status = status.code.split('/')[1] if status.code.include? 'PowerState'
|
221
221
|
end
|
222
222
|
vm_status
|
223
223
|
end
|
@@ -238,11 +238,10 @@ module ForemanAzureRm
|
|
238
238
|
|
239
239
|
def actual_gallery_image_id(rg_name, image_id)
|
240
240
|
gallery_names = list_galleries.map(&:name)
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
nil
|
241
|
+
return unless (gallery = gallery_names.first)
|
242
|
+
|
243
|
+
gallery_image = list_gallery_images(rg_name, gallery).detect { |image| image.name == image_id }
|
244
|
+
gallery_image&.id
|
246
245
|
end
|
247
246
|
|
248
247
|
def fetch_gallery_image_id(rg_name, image_id)
|
@@ -2,17 +2,19 @@ module ForemanAzureRm
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
engine_name 'foreman_azure_rm'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
config.
|
8
|
-
config.eager_load_paths
|
9
|
-
|
10
|
-
initializer 'foreman_azure_rm.register_plugin', :before => :finisher_hook do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
lib = config.root.join('app', 'lib')
|
6
|
+
|
7
|
+
config.autoload_paths << lib
|
8
|
+
config.eager_load_paths << lib
|
9
|
+
|
10
|
+
initializer 'foreman_azure_rm.register_plugin', :before => :finisher_hook do |app|
|
11
|
+
app.reloader.to_prepare do
|
12
|
+
Foreman::Plugin.register :foreman_azure_rm do
|
13
|
+
requires_foreman '>= 3.13'
|
14
|
+
register_gettext
|
15
|
+
compute_resource ForemanAzureRm::AzureRm
|
16
|
+
parameter_filter ComputeResource, :azure_vm, :tenant, :app_ident, :secret_key, :sub_id, :region, :cloud
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
@@ -29,14 +31,6 @@ module ForemanAzureRm
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
|
-
initializer "foreman_azure_rm.zeitwerk" do
|
33
|
-
Rails.autoloaders.each do |loader|
|
34
|
-
loader.ignore(
|
35
|
-
ForemanAzureRm::Engine.root.join('lib/foreman_azure_rm/version.rb')
|
36
|
-
)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
34
|
config.to_prepare do
|
41
35
|
require 'azure_mgmt_resources'
|
42
36
|
require 'azure_mgmt_network'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_azure_rm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditi Puntambekar
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-12-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: azure_mgmt_resources
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- app/controllers/foreman_azure_rm/concerns/compute_resources_controller_extensions.rb
|
118
118
|
- app/controllers/foreman_azure_rm/concerns/hosts_controller_extensions.rb
|
119
119
|
- app/helpers/azure_compute_resource_helper.rb
|
120
|
+
- app/lib/foreman_azure_rm/azure_sdk_adapter.rb
|
120
121
|
- app/models/concerns/foreman_azure_rm/vm_extensions/managed_vm.rb
|
121
122
|
- app/models/foreman_azure_rm/azure_rm.rb
|
122
123
|
- app/models/foreman_azure_rm/azure_rm_compute.rb
|
@@ -139,7 +140,6 @@ files:
|
|
139
140
|
- db/migrate/20200507103900_fix_image_uuid_prefix.rb
|
140
141
|
- lib/foreman_azure_rm.rake
|
141
142
|
- lib/foreman_azure_rm.rb
|
142
|
-
- lib/foreman_azure_rm/azure_sdk_adapter.rb
|
143
143
|
- lib/foreman_azure_rm/engine.rb
|
144
144
|
- lib/foreman_azure_rm/version.rb
|
145
145
|
- locale/Makefile
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
- !ruby/object:Gem::Version
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
|
-
rubygems_version: 3.
|
205
|
+
rubygems_version: 3.5.22
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: Azure Resource Manager as a compute resource for The Foreman
|