foreman_azure_rm 2.1.3 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56702d3d39f9bc9753e04e4681b4607d073cc913c1625835dda252a8a575cb6a
4
- data.tar.gz: 59999cc6458945958f13933a0a9c1b08b63d8ddad0cb6ece337b86e367948190
3
+ metadata.gz: 29c728e81ac2e3c154212c1111ce0b0fa018ebfe33ae4e449c456c3a08013dca
4
+ data.tar.gz: fa67a435918ba3580f4fe0d74b493626d130b3a67d0eabf140de5103590afe09
5
5
  SHA512:
6
- metadata.gz: beb3b60d5c7790ff3063c67634d749fa5ca13148bde4197e40f0d5014ec3bdab94956688b5a6de21fa13ee40e0edf76bccd7ce2fa6e1ebcd6be7fafb9f79057a
7
- data.tar.gz: c4e0e9857dfe71bc31d09275c012ed263dde09e25d98ea5d32c75a8be812f8a325a0d5f2e9880f6a84109c9f8a6f2ff3ee5db0e1079b969c27102cd84fc2d54e
6
+ metadata.gz: 305ea84bed5a5fff7313fc02febfbfff7407c9b0f7588670fef97065e8c78cb2d5e34b8932ee324b3052f06d97fd6455e8d2e5890c5f8322fc6530bd12f5905b
7
+ data.tar.gz: 07ed5bc2005637ba507ea057625794c082a40a19e083792b92de224318e9f477973a8c9df71cd6587af805b913a91c9f544f4527ffb5d883bcb1eac3d6701a2a
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  ```foreman_azure_rm``` adds [Microsoft Azure Resource Manager](http://azure.com/) as a compute resource for The Foreman
5
5
 
6
6
  * Website: [TheForeman.org](http://theforeman.org)
7
+ * ForemanAzureRm: [Plugin manual](https://theforeman.org/plugins/foreman_azure)
7
8
  * Support: [Foreman support](http://theforeman.org/support.html)
8
9
 
9
10
  ## Installation
@@ -12,25 +13,25 @@
12
13
 
13
14
  Add the following to bundler.d/Gemfile.local.rb in your Foreman installation directory (/usr/share/foreman by default)
14
15
 
15
- ```bash
16
+ ```console
16
17
  $ gem 'foreman_azure_rm'
17
18
  ```
18
19
 
19
20
  Or simply:
20
21
 
21
- ```bash
22
+ ```console
22
23
  $ echo "gem 'foreman_azure_rm'" > /usr/share/foreman/bundler.d/Gemfile.local.rb
23
24
  ```
24
25
 
25
26
  Then run `bundle install` from the same directory
26
27
 
27
28
  ### Package
28
- ```
29
+ ```console
29
30
  # yum install tfm-rubygem-foreman_azure_rm
30
31
  ```
31
32
 
32
33
  ### Foreman Installer
33
- ```
34
+ ```console
34
35
  # foreman-installer --enable-foreman-plugin-azure
35
36
  ```
36
37
 
@@ -44,7 +45,7 @@ git clone https://github.com/theforeman/foreman_azure_rm.git
44
45
  Add the following to bundler.d/Gemfile.local.rb in your Foreman development directory
45
46
 
46
47
  ```ruby
47
- $ gem 'foreman_azure_rm', :path => 'path to foreman_azure_rm directory'
48
+ gem 'foreman_azure_rm', :path => 'path to foreman_azure_rm directory'
48
49
  ```
49
50
 
50
51
  Then run `bundle install` from the same directory
@@ -54,14 +55,19 @@ Then run `bundle install` from the same directory
54
55
  * VM creation
55
56
  * Provisions using Finish and User data templates from Foreman
56
57
  * Supports cloud-config provisioning
57
- * Currently supports single NIC
58
- * Currently supports single default OS Disk
59
58
  * Currently supports only provisioning of Linux platforms
60
59
  * Provisioning using [Public Images](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage)
60
+ * Provision using custom images
61
+ * Provision using shared image galleries
62
+ * Provision using RHEL byos images
63
+ * Multiple NICs support
64
+ * Support to add multiple data disks/volumes (standard or premium)
65
+ * VM Extension with Custom Script and File URIs support
61
66
  * Static or dynamic addresses on a per NIC basis
62
67
  * Limited extension support
63
68
  * Microsoft's custom script extension
64
69
  * Puppet Lab's Puppet agent extension for Windows
70
+ * Azure Gov Cloud Support
65
71
 
66
72
  ## Configuration
67
73
  Go to **Infrastructure > Compute Resources** and click on "New Compute Resource".
@@ -71,25 +77,20 @@ Choose the **Azure Resource Manager provider**, and fill in all the fields. You
71
77
  That's it. You're now ready to create and manage Azure resources in your new Azure Resource Manager compute resource. You should see something like this in the Compute Resource page:
72
78
 
73
79
 
74
- ![](https://i.imgur.com/4ClZhTP.png)
80
+ ![](https://i.imgur.com/vsamP4G.png)
75
81
 
76
82
 
77
- ![](https://i.imgur.com/eFHucdb.png)
83
+ ![](https://i.imgur.com/Ag9tH55.png)
78
84
 
79
85
 
80
- ![](https://i.imgur.com/YjlRQIE.png)
86
+ ![](https://i.imgur.com/fNjlFci.png)
81
87
 
82
88
 
83
89
  ## Planned Features
84
- * Multiple NICs support
85
- * Support to add multiple data disks (standard or premium)
86
- * Provision using custom images
87
- * Provision using shared image galleries
88
- * Improved extension support
90
+ * Support for http_proxy
89
91
 
90
92
  ## Known Limitations
91
93
  * Please note that currently username is expected to be the same on both Virtual Machine tab for Host creation and during Image creation for Compute Resource. The password field for Image creation is optional.
92
- * Unable to provision using Windows Images
93
94
 
94
95
  ## Links
95
96
  * [Issue tracker](https://projects.theforeman.org/projects/azurerm)
@@ -10,6 +10,7 @@ module ForemanAzureRm
10
10
  param :app_ident, String, :desc => N_("Client ID for AzureRm")
11
11
  param :secret_key, String, :desc => N_("Client Secret for AzureRm")
12
12
  param :sub_id, String, :desc => N_("Subscription ID for AzureRm")
13
+ param :cloud, String, :desc => N_("Cloud")
13
14
  end
14
15
  end
15
16
 
@@ -10,8 +10,7 @@ module AzureComputeResourceHelper
10
10
  end
11
11
  selectable_f(f, :url, regions, {}, {:label => _('Azure Region'), :disabled => regions.empty?, :required => true, :help_inline_permanent => load_button_f(f, regions.present?, _("Load Regions")) })
12
12
  end
13
- def azure_doc_url
13
+ def azure_doc_version
14
14
  doc_version = Foreman::Plugin.find(:foreman_azure_rm).version.scan(/\d+\.\d+/).first + '.x'
15
- "https://theforeman.org/plugins/foreman_azure/#{doc_version}"
16
15
  end
17
16
  end
@@ -4,7 +4,7 @@ module ForemanAzureRm
4
4
  module ManagedVM
5
5
  extend ActiveSupport::Concern
6
6
 
7
- def define_managed_storage_profile(vm_name, os_disk_caching, platform, premium_os_disk)
7
+ def define_managed_storage_profile(vm_name, os_disk_caching, platform, premium_os_disk, os_disk_size_gb)
8
8
  storage_profile = ComputeModels::StorageProfile.new
9
9
  os_disk = ComputeModels::OSDisk.new
10
10
  managed_disk_params = ComputeModels::ManagedDiskParameters.new
@@ -12,6 +12,7 @@ module ForemanAzureRm
12
12
  # Create OS disk
13
13
  os_disk.name = "#{vm_name}-osdisk"
14
14
  os_disk.os_type = platform
15
+ os_disk.disk_size_gb = os_disk_size_gb
15
16
  os_disk.create_option = ComputeModels::DiskCreateOptionTypes::FromImage
16
17
  os_disk.caching = disk_caching(os_disk_caching)
17
18
  managed_disk_params.storage_account_type = if premium_os_disk == 'true'
@@ -59,6 +60,21 @@ module ForemanAzureRm
59
60
  end
60
61
  end
61
62
 
63
+ def marketplace_image_plan(image)
64
+ image_type, image_id = image.split('://')
65
+ return nil unless image_type == 'marketplace' && image_id.include?('byos')
66
+ urn = image_id.split(':')
67
+ publisher = urn[0]
68
+ offer = urn[1]
69
+ sku = urn[2]
70
+ version = urn[3]
71
+ image_plan = ComputeModels::PurchasePlan.new
72
+ image_plan.publisher = publisher.downcase
73
+ image_plan.name = sku.downcase
74
+ image_plan.product = offer.downcase
75
+ image_plan
76
+ end
77
+
62
78
  def marketplace_image_reference(publisher, offer, sku, version)
63
79
  image_reference = ComputeModels::ImageReference.new
64
80
  image_reference.publisher = publisher
@@ -107,7 +123,7 @@ module ForemanAzureRm
107
123
  def create_nics(region, args = {})
108
124
  nics = []
109
125
  args[:interfaces_attributes].each do |nic, attrs|
110
- private_ip = (attrs[:private_ip] == 'false') ? false : true
126
+ private_ip = Foreman::Cast.to_bool(attrs[:private_ip])
111
127
  priv_ip_alloc = if private_ip
112
128
  NetworkModels::IPAllocationMethod::Static
113
129
  else
@@ -172,21 +188,23 @@ module ForemanAzureRm
172
188
  os_profile.admin_password = vm_hash[:password]
173
189
 
174
190
  # Adding the ssh-key support for authentication
175
- os_profile.linux_configuration = ComputeModels::LinuxConfiguration.new.tap do |linux|
176
- linux.disable_password_authentication = vm_hash[:disable_password_authentication]
177
- linux.ssh = ComputeModels::SshConfiguration.new.tap do |ssh_config|
178
- ssh_config.public_keys = [
179
- ComputeModels::SshPublicKey.new.tap do |foreman_key|
180
- foreman_key.key_data = key_pair.public
181
- foreman_key.path = "/home/#{vm_hash[:username]}/.ssh/authorized_keys"
191
+ if vm_hash[:platform] == 'Linux'
192
+ os_profile.linux_configuration = ComputeModels::LinuxConfiguration.new.tap do |linux|
193
+ linux.disable_password_authentication = vm_hash[:disable_password_authentication]
194
+ linux.ssh = ComputeModels::SshConfiguration.new.tap do |ssh_config|
195
+ ssh_config.public_keys = [
196
+ ComputeModels::SshPublicKey.new.tap do |foreman_key|
197
+ foreman_key.key_data = key_pair.public
198
+ foreman_key.path = "/home/#{vm_hash[:username]}/.ssh/authorized_keys"
199
+ end
200
+ ]
201
+ if vm_hash[:ssh_key_data].present?
202
+ key_data = vm_hash[:ssh_key_data]
203
+ pub_key = ComputeModels::SshPublicKey.new
204
+ pub_key.key_data = key_data
205
+ pub_key.path = "/home/#{vm_hash[:username]}/.ssh/authorized_keys"
206
+ ssh_config.public_keys << pub_key
182
207
  end
183
- ]
184
- if vm_hash[:ssh_key_data].present?
185
- key_data = vm_hash[:ssh_key_data]
186
- pub_key = ComputeModels::SshPublicKey.new
187
- pub_key.key_data = key_data
188
- pub_key.path = "/home/#{vm_hash[:username]}/.ssh/authorized_keys"
189
- ssh_config.public_keys << pub_key
190
208
  end
191
209
  end
192
210
  end
@@ -197,7 +215,8 @@ module ForemanAzureRm
197
215
  vm_hash[:name],
198
216
  vm_hash[:os_disk_caching],
199
217
  vm_hash[:platform],
200
- vm_hash[:premium_os_disk]
218
+ vm_hash[:premium_os_disk],
219
+ vm_hash[:os_disk_size_gb]
201
220
  )
202
221
  vm.hardware_profile = ComputeModels::HardwareProfile.new.tap do |hw_profile|
203
222
  hw_profile.vm_size = vm_hash[:vm_size]
@@ -209,6 +228,7 @@ module ForemanAzureRm
209
228
 
210
229
  def create_managed_virtual_machine(vm_hash)
211
230
  vm_params = initialize_vm(vm_hash)
231
+ vm_params.plan = marketplace_image_plan(vm_hash[:image_id])
212
232
  vm_params.network_profile = define_network_profile(vm_hash[:network_interface_card_ids])
213
233
  vm_params.storage_profile.image_reference = define_image(vm_hash[:resource_group], vm_hash[:image_id])
214
234
  vm_params.storage_profile.data_disks = define_data_disks(vm_hash[:name], vm_hash[:data_disks])
@@ -219,11 +239,22 @@ module ForemanAzureRm
219
239
  if args[:script_command].present? || args[:script_uris].present?
220
240
  args[:script_uris] ||= args[:script_uris].to_s
221
241
  extension = ComputeModels::VirtualMachineExtension.new
222
- if args[:platform] == 'Linux'
242
+
243
+ case args[:platform]
244
+ # https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-linux
245
+ when 'Linux'
223
246
  extension.publisher = 'Microsoft.Azure.Extensions'
224
247
  extension.virtual_machine_extension_type = 'CustomScript'
225
248
  extension.type_handler_version = '2.0'
249
+ # https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows
250
+ when 'Windows'
251
+ extension.publisher = 'Microsoft.Compute'
252
+ extension.virtual_machine_extension_type = 'CustomScriptExtension'
253
+ extension.type_handler_version = '1.10'
254
+ else
255
+ raise RuntimeError, "Unsupported platform #{args[:platform]}"
226
256
  end
257
+
227
258
  extension.auto_upgrade_minor_version = true
228
259
  extension.location = region
229
260
  extension.settings = {
@@ -11,6 +11,7 @@ module ForemanAzureRm
11
11
  alias_attribute :secret_key, :password
12
12
  alias_attribute :region, :url
13
13
  alias_attribute :tenant, :uuid
14
+ alias_attribute :azure_environment, :cloud
14
15
 
15
16
  validates :user, :password, :uuid, :app_ident, :presence => true
16
17
 
@@ -41,8 +42,16 @@ module ForemanAzureRm
41
42
  attrs[:app_ident] = name
42
43
  end
43
44
 
45
+ def cloud
46
+ attrs[:cloud] || 'azure'
47
+ end
48
+
49
+ def cloud=(name)
50
+ attrs[:cloud] = name
51
+ end
52
+
44
53
  def sdk
45
- @sdk ||= ForemanAzureRm::AzureSdkAdapter.new(tenant, app_ident, secret_key, sub_id)
54
+ @sdk ||= ForemanAzureRm::AzureSdkAdapter.new(tenant, app_ident, secret_key, sub_id, azure_environment)
46
55
  end
47
56
 
48
57
  def to_label
@@ -81,7 +90,7 @@ module ForemanAzureRm
81
90
 
82
91
  def test_connection(options = {})
83
92
  super
84
- errors[:user].empty? && errors[:password].empty? && errors[:uuid].empty? && errors[:app_ident].empty? && regions
93
+ errors[:user].empty? && errors[:password].empty? && errors[:uuid].empty? && errors[:app_ident].empty? && errors[:cloud].empty? && regions
85
94
  rescue StandardError => e
86
95
  errors[:base] << e.message
87
96
  rescue Excon::Error::Socket => e
@@ -106,7 +115,8 @@ module ForemanAzureRm
106
115
  platform: opts[:platform],
107
116
  ssh_key_data: opts[:ssh_key_data],
108
117
  os_disk_caching: opts[:os_disk_caching],
109
- premium_os_disk: opts[:premium_os_disk]
118
+ premium_os_disk: opts[:premium_os_disk],
119
+ os_disk_size_gb: opts[:os_disk_size_gb]
110
120
  )
111
121
  if opts[:interfaces].present?
112
122
  ifaces = []
@@ -259,23 +269,26 @@ module ForemanAzureRm
259
269
  args = args.to_h.deep_symbolize_keys
260
270
  args[:vm_name] = args[:name].split('.')[0]
261
271
  nics = create_nics(region, args)
262
- if args[:password].present? && !args[:ssh_key_data].present?
263
- # Any change to sudoers_cmd and formation of new
264
- # args[:script_command] must be accordingly changed
265
- # in script_command method in AzureRmCompute class
266
- sudoers_cmd = "$echo #{args[:password]} | sudo -S echo '\"#{args[:username]}\" ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/waagent"
267
- if args[:script_command].present?
268
- # to run the script_cmd given through form as username
269
- user_command = args[:script_command]
270
- args[:script_command] = sudoers_cmd + " ; su - \"#{args[:username]}\" -c \"#{user_command}\""
272
+
273
+ if args[:platform] == 'Linux'
274
+ if args[:password].present? && !args[:ssh_key_data].present?
275
+ # Any change to sudoers_cmd and formation of new
276
+ # args[:script_command] must be accordingly changed
277
+ # in script_command method in AzureRmCompute class
278
+ sudoers_cmd = "$echo #{args[:password]} | sudo -S echo '\"#{args[:username]}\" ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/waagent"
279
+ if args[:script_command].present?
280
+ # to run the script_cmd given through form as username
281
+ user_command = args[:script_command]
282
+ args[:script_command] = sudoers_cmd + " ; su - \"#{args[:username]}\" -c \"#{user_command}\""
283
+ else
284
+ args[:script_command] = sudoers_cmd
285
+ end
286
+ disable_password_auth = false
287
+ elsif args[:ssh_key_data].present? && !args[:password].present?
288
+ disable_password_auth = true
271
289
  else
272
- args[:script_command] = sudoers_cmd
290
+ disable_password_auth = false
273
291
  end
274
- disable_password_auth = false
275
- elsif args[:ssh_key_data].present? && !args[:password].present?
276
- disable_password_auth = true
277
- else
278
- disable_password_auth = false
279
292
  end
280
293
 
281
294
  vm = create_managed_virtual_machine(
@@ -292,6 +305,7 @@ module ForemanAzureRm
292
305
  image_id: args[:image_id],
293
306
  os_disk_caching: args[:os_disk_caching],
294
307
  premium_os_disk: args[:premium_os_disk],
308
+ os_disk_size_gb: args[:os_disk_size_gb],
295
309
  data_disks: args[:volumes_attributes],
296
310
  custom_data: args[:user_data],
297
311
  script_command: args[:script_command],
@@ -10,7 +10,7 @@ module ForemanAzureRm
10
10
  delegate :name, to: :azure_vm, allow_nil: true
11
11
 
12
12
  def initialize(azure_vm: ComputeModels::VirtualMachine.new,
13
- sdk: sdk,
13
+ sdk: nil,
14
14
  resource_group: azure_vm.resource_group,
15
15
  nics: [],
16
16
  volumes: [],
@@ -179,6 +179,10 @@ module ForemanAzureRm
179
179
  @azure_vm.storage_profile.os_disk.managed_disk.storage_account_type
180
180
  end
181
181
 
182
+ def os_disk_size_gb
183
+ @azure_vm.storage_profile.os_disk.disk_size_gb
184
+ end
185
+
182
186
  def os_disk_caching
183
187
  @azure_vm.storage_profile.os_disk.caching
184
188
  end
@@ -1 +1 @@
1
- attributes :tenant, :app_ident, :sub_id, :secret_key, :region
1
+ attributes :cloud, :tenant, :app_ident, :sub_id, :region
@@ -1,5 +1,10 @@
1
- <%= text_f f, :app_ident, :label => _('Client ID'), :required => true, :help_inline => link_to(icon_text('help', _('Documentation'), :kind => 'pficon'),
2
- azure_doc_url, :rel => 'external', :class => 'btn btn-default btn-docs', :target => '_blank') %>
1
+ <%= selectable_f f, :cloud, [
2
+ ['Public / Standard', 'azure'],
3
+ ['US Government', 'azureusgovernment'],
4
+ ['China', 'azurechina'],
5
+ ['Germany', 'azuregermancloud'],
6
+ ], {}, { :label => _('Cloud'), :required => true } %>
7
+ <%= text_f f, :app_ident, :label => _('Client ID'), :required => true, :help_inline => link_to('Documentation', external_link_path(type: 'plugin_manual', name: 'foreman_azure', version: azure_doc_version), :kind => 'pficon', :rel => 'external', :class => 'btn btn-default btn-docs', :target => '_blank') %>
3
8
  <%= password_f f, :password, :label => _('Client Secret'), :keep_value => true, :required => true %>
4
9
  <%= text_f f, :user, :label => _('Subscription ID'), :required => true %>
5
10
  <%= text_f f, :uuid, :label => _('Tenant ID'), :required => true %>
@@ -132,7 +132,6 @@
132
132
  <%= password_f f, :password,
133
133
  {
134
134
  :label => _('Password'),
135
- :required => true,
136
135
  :placeholder => "********",
137
136
  :value => f.object.password
138
137
 
@@ -154,6 +153,16 @@
154
153
  'false'
155
154
  %>
156
155
 
156
+ <%= number_f f, :os_disk_size_gb,
157
+ {
158
+ :label => _('Override OS Disk Size (GB)'),
159
+ :label_help => _("Leave empty to use default image size"),
160
+ :required => false,
161
+ :min => 1,
162
+ :class => "col-md-2",
163
+ }
164
+ %>
165
+
157
166
  <%= selectable_f f, :os_disk_caching, %w(None ReadOnly ReadWrite),
158
167
  { :include_blank => _("Azure's Default") },
159
168
  {
@@ -1,14 +1,14 @@
1
- <table class="table table-bordered" data-table="inline">
2
- <thead>
3
- <tr>
4
- <th><%= _('Name') %></th>
5
- <th><%= _('Size') %></th>
6
- <th><%= _('Resource Group') %></th>
7
- <th><%= _('Region') %></th>
8
- <th><%= _('State') %></th>
9
- <th><%= _('Actions') %></th>
10
- </tr>
11
- </thead>
1
+ <thead>
2
+ <tr>
3
+ <th><%= _('Name') %></th>
4
+ <th><%= _('Size') %></th>
5
+ <th><%= _('Resource Group') %></th>
6
+ <th><%= _('Region') %></th>
7
+ <th><%= _('State') %></th>
8
+ <th><%= _('Actions') %></th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
12
  <% @vms.each do |vm| %>
13
13
  <tr>
14
14
  <td><%= link_to_if_authorized vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.identity).merge(:auth_object => @compute_resource) %></td>
@@ -27,4 +27,4 @@
27
27
  </td>
28
28
  </tr>
29
29
  <% end %>
30
- </table>
30
+ </tbody>
@@ -2,5 +2,5 @@
2
2
  :help_inline => _("The user that will be used to SSH into the VM for completion")
3
3
  %>
4
4
  <%= password_f f, :password, :keep_value => true, :help_inline => _("Password to authenticate with - used for SSH finish step.") %>
5
- <%= image_field(f, :label => _("Azure Image Name"), :help_inline => _("For custom or shared gallery image prefix the uuid with 'custom://' or 'gallery://'. For public image, prefix the uuid with 'marketplace://'.' (e.g. 'marketplace://OpenLogic:CentOS:7.5:latest' or 'custom://image-name')")) %>
6
- <%= checkbox_f f, :user_data, :help_inline => _("Does this image support user data input?") %>
5
+ <%= image_field(f, :label => _("Azure Image Name"), :help_inline => _("For custom or shared gallery image, use prefix 'custom://' or 'gallery://'. For public and RHEL-byos images, prefix the uuid with 'marketplace://'. (e.g. 'marketplace://OpenLogic:CentOS:7.5:latest' or 'custom://image-name')")) %>
6
+ <%= checkbox_f f, :user_data, :help_inline => _("Does this image support user data input?") %>
@@ -1,46 +1,87 @@
1
1
  module ForemanAzureRm
2
2
  class AzureSdkAdapter
3
- def initialize(tenant, app_ident, secret_key, sub_id)
4
- @tenant = tenant
5
- @app_ident = app_ident
6
- @secret_key = secret_key
7
- @sub_id = sub_id
3
+ def initialize(tenant, app_ident, secret_key, sub_id, azure_environment)
4
+ @tenant = tenant
5
+ @app_ident = app_ident
6
+ @secret_key = secret_key
7
+ @sub_id = sub_id
8
+ @azure_environment = azure_environment
9
+ @ad_settings = ad_environment_settings(azure_environment)
10
+ @environment_settings = environment_settings(azure_environment)
8
11
  end
9
12
 
10
13
  def resource_client
11
- @resource_client ||= Resources::Client.new(azure_credentials)
14
+ #resource_manager_endpoint_url
15
+ @resource_client ||= Resources::Client.new(azure_credentials(@environment_settings.resource_manager_endpoint_url))
12
16
  end
13
17
 
14
18
  def compute_client
15
- @compute_client ||= Compute::Client.new(azure_credentials)
19
+ @compute_client ||= Compute::Client.new(azure_credentials(@environment_settings.resource_manager_endpoint_url))
16
20
  end
17
21
 
18
22
  def network_client
19
- @network_client ||= Network::Client.new(azure_credentials)
23
+ @network_client ||= Network::Client.new(azure_credentials(@environment_settings.resource_manager_endpoint_url))
20
24
  end
21
25
 
22
26
  def storage_client
23
- @storage_client ||= Storage::Client.new(azure_credentials)
27
+ @storage_client ||= Storage::Client.new(azure_credentials(@environment_settings.resource_manager_endpoint_url))
24
28
  end
25
29
 
26
30
  def subscription_client
27
- @subscription_client ||= Subscriptions::Client.new(azure_credentials)
31
+ @subscription_client ||= Subscriptions::Client.new(azure_credentials(@environment_settings.resource_manager_endpoint_url))
28
32
  end
29
33
 
30
- def azure_credentials
34
+ def azure_credentials(base_url)
31
35
  provider = MsRestAzure::ApplicationTokenProvider.new(
32
36
  @tenant,
33
37
  @app_ident,
34
- @secret_key)
38
+ @secret_key,
39
+ @ad_settings)
35
40
 
36
41
  credentials = MsRest::TokenCredentials.new(provider)
37
42
 
38
43
  {
39
44
  credentials: credentials,
40
- subscription_id: @sub_id
45
+ tenant_id: @tenant,
46
+ client_id: @app_ident,
47
+ client_secret: @secret_key,
48
+ subscription_id: @sub_id,
49
+ base_url: base_url
41
50
  }
42
51
  end
43
52
 
53
+ # https://github.com/Azure/azure-sdk-for-ruby/issues/850
54
+ # Retrieves a [MsRestAzure::ActiveDirectoryServiceSettings] object representing the settings for the given cloud.
55
+ # @param azure_environment [String] The Azure environment to retrieve settings for.
56
+ #
57
+ # @return [MsRestAzure::ActiveDirectoryServiceSettings] Settings to be used for subsequent requests
58
+ #
59
+ def ad_environment_settings(azure_environment)
60
+ case azure_environment.downcase
61
+ when 'azureusgovernment'
62
+ MsRestAzure::ActiveDirectoryServiceSettings.get_azure_us_government_settings
63
+ when 'azurechina'
64
+ MsRestAzure::ActiveDirectoryServiceSettings.get_azure_china_settings
65
+ when 'azuregermancloud'
66
+ MsRestAzure::ActiveDirectoryServiceSettings.get_azure_german_settings
67
+ when 'azure'
68
+ MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
69
+ end
70
+ end
71
+
72
+ def environment_settings(azure_environment)
73
+ case azure_environment.downcase
74
+ when 'azureusgovernment'
75
+ MsRestAzure::AzureEnvironments::AzureUSGovernment
76
+ when 'azurechina'
77
+ MsRestAzure::AzureEnvironments::AzureChinaCloud
78
+ when 'azuregermancloud'
79
+ MsRestAzure::AzureEnvironments::AzureGermanCloud
80
+ when 'azure'
81
+ MsRestAzure::AzureEnvironments::AzureCloud
82
+ end
83
+ end
84
+
44
85
  def list_regions(subscription_id)
45
86
  subscription_client.subscriptions.list_locations(subscription_id)
46
87
  end
@@ -11,7 +11,7 @@ module ForemanAzureRm
11
11
  Foreman::Plugin.register :foreman_azure_rm do
12
12
  requires_foreman '>= 1.17'
13
13
  compute_resource ForemanAzureRm::AzureRm
14
- parameter_filter ComputeResource, :azure_vm, :tenant, :app_ident, :secret_key, :sub_id, :region
14
+ parameter_filter ComputeResource, :azure_vm, :tenant, :app_ident, :secret_key, :sub_id, :region, :cloud
15
15
  end
16
16
  end
17
17
 
@@ -42,7 +42,7 @@ module ForemanAzureRm
42
42
  require 'azure_mgmt_subscriptions'
43
43
 
44
44
  # Add format validation for azure images
45
- ::Image.validates :uuid, format: { with: /\A((marketplace|custom|gallery):\/\/)[^:]+(:[^:]+:[^:]+:[^:]+)?\z/,
45
+ ::Image.validates :uuid, uniqueness: { scope: :compute_resource_id, case_sensitive: false }, format: { with: /\A((marketplace|custom|gallery):\/\/)[^:]+(:[^:]+:[^:]+:[^:]+)?\z/,
46
46
  message: "Incorrect UUID format" }, if: -> (image){ image.compute_resource.is_a? ForemanAzureRm::AzureRm }
47
47
 
48
48
  # Use excon as default so that HTTP Proxy settings of foreman works
@@ -1,3 +1,3 @@
1
1
  module ForemanAzureRm
2
- VERSION = '2.1.3'.freeze
2
+ VERSION = '2.2.4'.freeze
3
3
  end
@@ -7,9 +7,10 @@
7
7
  # 0868a4d1af5275b3f70b0a6dac4c99a4, 2020
8
8
  # Bryan Kearney <bryan.kearney@gmail.com>, 2020
9
9
  #
10
+ #, fuzzy
10
11
  msgid ""
11
12
  msgstr ""
12
- "Project-Id-Version: foreman_azure_rm 2.0.8\n"
13
+ "Project-Id-Version: foreman_azure_rm 2.1.1\n"
13
14
  "Report-Msgid-Bugs-To: \n"
14
15
  "PO-Revision-Date: 2020-04-21 13:58+0000\n"
15
16
  "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>, 2020\n"
@@ -24,7 +25,7 @@ msgid "%{vm_size} VM Size"
24
25
  msgstr ""
25
26
 
26
27
  msgid "Action with sub plans"
27
- msgstr ""
28
+ msgstr "하위 계획이 있는 작업"
28
29
 
29
30
  msgid "Actions"
30
31
  msgstr "동작 "
@@ -78,13 +79,13 @@ msgid "Image"
78
79
  msgstr "이미지 "
79
80
 
80
81
  msgid "Import Puppet classes"
81
- msgstr ""
82
+ msgstr "Puppet 클래스 가져오기"
82
83
 
83
84
  msgid "Import facts"
84
- msgstr ""
85
+ msgstr "팩트 불러오기"
85
86
 
86
87
  msgid "Load Regions"
87
- msgstr ""
88
+ msgstr "지역 로드 "
88
89
 
89
90
  msgid "Marketplace Image URN"
90
91
  msgstr ""
@@ -132,7 +133,7 @@ msgid "Reload Images, Sizes, vNets"
132
133
  msgstr ""
133
134
 
134
135
  msgid "Remote action:"
135
- msgstr ""
136
+ msgstr "원격 작업:"
136
137
 
137
138
  msgid "Resource Group"
138
139
  msgstr ""
@@ -7,9 +7,10 @@
7
7
  # Maxim Burgerhout <maxim@wzzrd.com>, 2020
8
8
  # EmielK <emiel@kremers.us>, 2020
9
9
  #
10
+ #, fuzzy
10
11
  msgid ""
11
12
  msgstr ""
12
- "Project-Id-Version: foreman_azure_rm 2.0.8\n"
13
+ "Project-Id-Version: foreman_azure_rm 2.1.1\n"
13
14
  "Report-Msgid-Bugs-To: \n"
14
15
  "PO-Revision-Date: 2020-04-21 13:58+0000\n"
15
16
  "Last-Translator: EmielK <emiel@kremers.us>, 2020\n"
@@ -7,9 +7,10 @@
7
7
  # sziolkow <sziolkow@gmail.com>, 2020
8
8
  # Michał Foryt <michal.foryt@gmail.com>, 2020
9
9
  #
10
+ #, fuzzy
10
11
  msgid ""
11
12
  msgstr ""
12
- "Project-Id-Version: foreman_azure_rm 2.0.8\n"
13
+ "Project-Id-Version: foreman_azure_rm 2.1.1\n"
13
14
  "Report-Msgid-Bugs-To: \n"
14
15
  "PO-Revision-Date: 2020-04-21 13:58+0000\n"
15
16
  "Last-Translator: Michał Foryt <michal.foryt@gmail.com>, 2020\n"
@@ -86,7 +87,7 @@ msgid "Import facts"
86
87
  msgstr ""
87
88
 
88
89
  msgid "Load Regions"
89
- msgstr ""
90
+ msgstr "Załaduj regiony"
90
91
 
91
92
  msgid "Marketplace Image URN"
92
93
  msgstr ""
@@ -4,18 +4,20 @@
4
4
  # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
5
  #
6
6
  # Translators:
7
- # Flamarion Jorge <jorge.flamarion@gmail.com>, 2020
8
7
  # 0868a4d1af5275b3f70b0a6dac4c99a4, 2020
8
+ # Bruno Emanuel Silva <bemanuel.pe@gmail.com>, 2020
9
+ # Flamarion Jorge <jorge.flamarion@gmail.com>, 2020
9
10
  # Bryan Kearney <bryan.kearney@gmail.com>, 2020
10
11
  # Luiz Henrique Vasconcelos <luizvasconceloss@yahoo.com.br>, 2020
11
- # Bruno Emanuel Silva <bemanuel.pe@gmail.com>, 2020
12
12
  #
13
+ #, fuzzy
13
14
  msgid ""
14
15
  msgstr ""
15
- "Project-Id-Version: foreman_azure_rm 2.0.8\n"
16
+ "Project-Id-Version: foreman_azure_rm 2.1.1\n"
16
17
  "Report-Msgid-Bugs-To: \n"
17
18
  "PO-Revision-Date: 2020-04-21 13:58+0000\n"
18
- "Last-Translator: Bruno Emanuel Silva <bemanuel.pe@gmail.com>, 2020\n"
19
+ "Last-Translator: Luiz Henrique Vasconcelos <luizvasconceloss@yahoo.com.br>, 20"
20
+ "20\n"
19
21
  "Language-Team: Portuguese (Brazil) (https://www.transifex.com/foreman/teams/11"
20
22
  "4/pt_BR/)\n"
21
23
  "MIME-Version: 1.0\n"
@@ -28,7 +30,7 @@ msgid "%{vm_size} VM Size"
28
30
  msgstr ""
29
31
 
30
32
  msgid "Action with sub plans"
31
- msgstr ""
33
+ msgstr "Ação com subplanos"
32
34
 
33
35
  msgid "Actions"
34
36
  msgstr "Ações"
@@ -82,13 +84,13 @@ msgid "Image"
82
84
  msgstr "Imagem"
83
85
 
84
86
  msgid "Import Puppet classes"
85
- msgstr ""
87
+ msgstr "Importar classes de Puppet"
86
88
 
87
89
  msgid "Import facts"
88
- msgstr ""
90
+ msgstr "Importar fatos"
89
91
 
90
92
  msgid "Load Regions"
91
- msgstr ""
93
+ msgstr "Carregar regiões"
92
94
 
93
95
  msgid "Marketplace Image URN"
94
96
  msgstr ""
@@ -136,7 +138,7 @@ msgid "Reload Images, Sizes, vNets"
136
138
  msgstr ""
137
139
 
138
140
  msgid "Remote action:"
139
- msgstr ""
141
+ msgstr "Ação remota:"
140
142
 
141
143
  msgid "Resource Group"
142
144
  msgstr ""
@@ -4,17 +4,19 @@
4
4
  # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
5
  #
6
6
  # Translators:
7
- # 0868a4d1af5275b3f70b0a6dac4c99a4, 2020
8
7
  # Andrei Burd <burdandrei@gmail.com>, 2020
9
- # Bryan Kearney <bryan.kearney@gmail.com>, 2020
10
8
  # Vladimir Pavlov <v.pavlov@i-teco.ru>, 2020
9
+ # Yulia <yulia.poyarkova@redhat.com>, 2020
10
+ # 0868a4d1af5275b3f70b0a6dac4c99a4, 2020
11
+ # Bryan Kearney <bryan.kearney@gmail.com>, 2020
11
12
  #
13
+ #, fuzzy
12
14
  msgid ""
13
15
  msgstr ""
14
- "Project-Id-Version: foreman_azure_rm 2.0.8\n"
16
+ "Project-Id-Version: foreman_azure_rm 2.1.1\n"
15
17
  "Report-Msgid-Bugs-To: \n"
16
18
  "PO-Revision-Date: 2020-04-21 13:58+0000\n"
17
- "Last-Translator: Vladimir Pavlov <v.pavlov@i-teco.ru>, 2020\n"
19
+ "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>, 2020\n"
18
20
  "Language-Team: Russian (https://www.transifex.com/foreman/teams/114/ru/)\n"
19
21
  "MIME-Version: 1.0\n"
20
22
  "Content-Type: text/plain; charset=UTF-8\n"
@@ -28,7 +30,7 @@ msgid "%{vm_size} VM Size"
28
30
  msgstr ""
29
31
 
30
32
  msgid "Action with sub plans"
31
- msgstr ""
33
+ msgstr "Действия с подпланами"
32
34
 
33
35
  msgid "Actions"
34
36
  msgstr "Действия"
@@ -82,13 +84,13 @@ msgid "Image"
82
84
  msgstr "Образ"
83
85
 
84
86
  msgid "Import Puppet classes"
85
- msgstr ""
87
+ msgstr "Импорт классов Puppet"
86
88
 
87
89
  msgid "Import facts"
88
- msgstr ""
90
+ msgstr "Импорт фактов"
89
91
 
90
92
  msgid "Load Regions"
91
- msgstr ""
93
+ msgstr "Загрузить регионы"
92
94
 
93
95
  msgid "Marketplace Image URN"
94
96
  msgstr ""
@@ -136,7 +138,7 @@ msgid "Reload Images, Sizes, vNets"
136
138
  msgstr ""
137
139
 
138
140
  msgid "Remote action:"
139
- msgstr ""
141
+ msgstr "Удаленное действие:"
140
142
 
141
143
  msgid "Resource Group"
142
144
  msgstr ""
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: 2.1.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aditi Puntambekar
@@ -10,92 +10,78 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-03-10 00:00:00.000000000 Z
13
+ date: 2021-05-12 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: deface
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "<"
20
- - !ruby/object:Gem::Version
21
- version: '2.0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - "<"
27
- - !ruby/object:Gem::Version
28
- version: '2.0'
29
15
  - !ruby/object:Gem::Dependency
30
16
  name: azure_mgmt_resources
31
17
  requirement: !ruby/object:Gem::Requirement
32
18
  requirements:
33
19
  - - "~>"
34
20
  - !ruby/object:Gem::Version
35
- version: 0.17.6
21
+ version: 0.18.1
36
22
  type: :runtime
37
23
  prerelease: false
38
24
  version_requirements: !ruby/object:Gem::Requirement
39
25
  requirements:
40
26
  - - "~>"
41
27
  - !ruby/object:Gem::Version
42
- version: 0.17.6
28
+ version: 0.18.1
43
29
  - !ruby/object:Gem::Dependency
44
30
  name: azure_mgmt_network
45
31
  requirement: !ruby/object:Gem::Requirement
46
32
  requirements:
47
33
  - - "~>"
48
34
  - !ruby/object:Gem::Version
49
- version: 0.19.0
35
+ version: 0.26.1
50
36
  type: :runtime
51
37
  prerelease: false
52
38
  version_requirements: !ruby/object:Gem::Requirement
53
39
  requirements:
54
40
  - - "~>"
55
41
  - !ruby/object:Gem::Version
56
- version: 0.19.0
42
+ version: 0.26.1
57
43
  - !ruby/object:Gem::Dependency
58
44
  name: azure_mgmt_storage
59
45
  requirement: !ruby/object:Gem::Requirement
60
46
  requirements:
61
47
  - - "~>"
62
48
  - !ruby/object:Gem::Version
63
- version: 0.17.10
49
+ version: 0.23.0
64
50
  type: :runtime
65
51
  prerelease: false
66
52
  version_requirements: !ruby/object:Gem::Requirement
67
53
  requirements:
68
54
  - - "~>"
69
55
  - !ruby/object:Gem::Version
70
- version: 0.17.10
56
+ version: 0.23.0
71
57
  - !ruby/object:Gem::Dependency
72
58
  name: azure_mgmt_compute
73
59
  requirement: !ruby/object:Gem::Requirement
74
60
  requirements:
75
61
  - - "~>"
76
62
  - !ruby/object:Gem::Version
77
- version: 0.18.7
63
+ version: 0.22.0
78
64
  type: :runtime
79
65
  prerelease: false
80
66
  version_requirements: !ruby/object:Gem::Requirement
81
67
  requirements:
82
68
  - - "~>"
83
69
  - !ruby/object:Gem::Version
84
- version: 0.18.7
70
+ version: 0.22.0
85
71
  - !ruby/object:Gem::Dependency
86
72
  name: azure_mgmt_subscriptions
87
73
  requirement: !ruby/object:Gem::Requirement
88
74
  requirements:
89
75
  - - "~>"
90
76
  - !ruby/object:Gem::Version
91
- version: 0.18.1
77
+ version: 0.18.5
92
78
  type: :runtime
93
79
  prerelease: false
94
80
  version_requirements: !ruby/object:Gem::Requirement
95
81
  requirements:
96
82
  - - "~>"
97
83
  - !ruby/object:Gem::Version
98
- version: 0.18.1
84
+ version: 0.18.5
99
85
  - !ruby/object:Gem::Dependency
100
86
  name: rubocop
101
87
  requirement: !ruby/object:Gem::Requirement
@@ -230,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
216
  - !ruby/object:Gem::Version
231
217
  version: '0'
232
218
  requirements: []
233
- rubygems_version: 3.1.4
219
+ rubygems_version: 3.1.2
234
220
  signing_key:
235
221
  specification_version: 4
236
222
  summary: Azure Resource Manager as a compute resource for The Foreman