foreman_azure_rm 2.1.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -15
  3. data/app/controllers/foreman_azure_rm/concerns/compute_resources_controller_extensions.rb +1 -0
  4. data/app/helpers/azure_compute_resource_helper.rb +3 -0
  5. data/app/models/concerns/foreman_azure_rm/vm_extensions/managed_vm.rb +48 -17
  6. data/app/models/foreman_azure_rm/azure_rm.rb +32 -18
  7. data/app/models/foreman_azure_rm/azure_rm_compute.rb +4 -0
  8. data/app/views/api/v2/compute_resources/azurerm.json.rabl +1 -1
  9. data/app/views/compute_resources/form/_azurerm.html.erb +8 -2
  10. data/app/views/compute_resources_vms/form/azurerm/_base.html.erb +10 -0
  11. data/app/views/compute_resources_vms/index/_azurerm.html.erb +12 -12
  12. data/app/views/images/form/_azurerm.html.erb +2 -2
  13. data/lib/foreman_azure_rm/azure_sdk_adapter.rb +54 -13
  14. data/lib/foreman_azure_rm/engine.rb +2 -2
  15. data/lib/foreman_azure_rm/version.rb +1 -1
  16. data/locale/action_names.rb +5 -0
  17. data/locale/ca/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  18. data/locale/ca/foreman_azure_rm.po +185 -0
  19. data/locale/cs_CZ/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  20. data/locale/cs_CZ/foreman_azure_rm.po +189 -0
  21. data/locale/de/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  22. data/locale/de/foreman_azure_rm.po +191 -0
  23. data/locale/en/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  24. data/locale/en/foreman_azure_rm.po +17 -5
  25. data/locale/en_GB/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  26. data/locale/en_GB/foreman_azure_rm.po +187 -0
  27. data/locale/es/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  28. data/locale/es/foreman_azure_rm.po +190 -0
  29. data/locale/foreman_azure_rm.pot +27 -13
  30. data/locale/fr/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  31. data/locale/fr/foreman_azure_rm.po +187 -0
  32. data/locale/gl/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  33. data/locale/gl/foreman_azure_rm.po +185 -0
  34. data/locale/it/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  35. data/locale/it/foreman_azure_rm.po +187 -0
  36. data/locale/ja/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  37. data/locale/ja/foreman_azure_rm.po +187 -0
  38. data/locale/ko/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  39. data/locale/ko/foreman_azure_rm.po +187 -0
  40. data/locale/nl_NL/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  41. data/locale/nl_NL/foreman_azure_rm.po +188 -0
  42. data/locale/pl/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  43. data/locale/pl/foreman_azure_rm.po +189 -0
  44. data/locale/pt_BR/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  45. data/locale/pt_BR/foreman_azure_rm.po +192 -0
  46. data/locale/ru/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  47. data/locale/ru/foreman_azure_rm.po +192 -0
  48. data/locale/sv_SE/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  49. data/locale/sv_SE/foreman_azure_rm.po +187 -0
  50. data/locale/zh_CN/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  51. data/locale/zh_CN/foreman_azure_rm.po +188 -0
  52. data/locale/zh_TW/LC_MESSAGES/foreman_azure_rm.mo +0 -0
  53. data/locale/zh_TW/foreman_azure_rm.po +187 -0
  54. metadata +52 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cca0d2f188d4731dbf29f7875aad1000fc3f176306dda4083caf2d053093f55f
4
- data.tar.gz: d316ee9bb58752babbeb553ab24b9d1e62e496b1596dc0477b7ed839f45d3fc1
3
+ metadata.gz: 03cab7177e77cb36e5e24755b2fadcd0b6934203001667ba89bd194b0d8d97a1
4
+ data.tar.gz: 2ddd6e70ddc620a1a859190f36b65fcd662241d8503b08bda0de606364a8a1df
5
5
  SHA512:
6
- metadata.gz: 9cef189f01b675262daed8b5a42b9a2324ad0952cda775a6484b3d45c45ff89b0742558c4a6f5d166a52bb3d5b749870a40d65d1a8e92de709e9615e2eb693de
7
- data.tar.gz: b7c2a5d6fc6e5bb6b0127eb0a52a307e93abb7fafbd419d09064e8fe15e3c0d7b4e9e4c14fd7c83feff5b55687021084a25d4a6ee74bc581885aa4266ba645fe
6
+ metadata.gz: fc7729cc420203fc3647557f5bdf13f0059a66613ef6e975062440ad75c3494f829c3ec8347470c49aebb35da50003bf8230a94529109debd6f5737d77d85d53
7
+ data.tar.gz: 42db1d9a7f3b210ac202d2c08fcb41fe8e7055c14a2e195facff44cc450dd34a61ef99f0ac8f8d2ea2b0efe676e676bb30cf5f879cf53f75f6643d219550eb15
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,21 +77,17 @@ 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.
@@ -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,4 +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_version
14
+ doc_version = Foreman::Plugin.find(:foreman_azure_rm).version.scan(/\d+\.\d+/).first + '.x'
15
+ end
13
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
@@ -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]
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],
@@ -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 :azure_environment, :tenant, :app_ident, :sub_id, :region
@@ -1,6 +1,12 @@
1
- <%= text_f f, :app_ident, :label => _('Client ID'), :required => true %>
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') %>
2
8
  <%= password_f f, :password, :label => _('Client Secret'), :keep_value => true, :required => true %>
3
9
  <%= text_f f, :user, :label => _('Subscription ID'), :required => true %>
4
10
  <%= text_f f, :uuid, :label => _('Tenant ID'), :required => true %>
5
11
 
6
- <%= regions_list(@compute_resource, f) %>
12
+ <%= regions_list(@compute_resource, f) %>
@@ -154,6 +154,16 @@
154
154
  'false'
155
155
  %>
156
156
 
157
+ <%= number_f f, :os_disk_size_gb,
158
+ {
159
+ :label => _('Override OS Disk Size (GB)'),
160
+ :label_help => _("Leave empty to use default image size"),
161
+ :required => false,
162
+ :min => 1,
163
+ :class => "col-md-2",
164
+ }
165
+ %>
166
+
157
167
  <%= selectable_f f, :os_disk_caching, %w(None ReadOnly ReadWrite),
158
168
  { :include_blank => _("Azure's Default") },
159
169
  {
@@ -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