foreman_azure 1.0.2 → 1.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
  SHA1:
3
- metadata.gz: 2eb742a3fe12f6b8d5dc15b70e8bf013882043eb
4
- data.tar.gz: 898eaf3509f80f66122a4cd858d5d6d4d1c4ec7f
3
+ metadata.gz: 2ea76c38a3b8a43fb02dc75f6151da9c33a9e44a
4
+ data.tar.gz: d36db15142dd1e3f71ec94731c83fbc157a47dce
5
5
  SHA512:
6
- metadata.gz: e8462d89f84a66de679117da52a237e307e4a45d6bdbbb6c65799e4e39d448990c454117eed1bb7e622ff7facb25a99cba17c128fab221b98ad5c11f0558c4de
7
- data.tar.gz: f68f09e9099f31a8d8f29a6dcd5d506cd9d079a6fb9af02b20bc825e4e860afefbdf4d38837d0d639ede4f6283d0b5f7f5b941687ab0dc6ca72952db7f89fdef
6
+ metadata.gz: 50deb54b6d1dc4358d8f355555b53f31201d4402e0ec21e770ed66a20b1272c5cffb628b3f227a28d283f28b09e835255d0b8dc27f52f900927645f05a55591a
7
+ data.tar.gz: 9c1f72740bbe9a7aca370a97d393cc05d6e61e658b9422fd778809032e907c038f248996d67623bc6ef9322c569404a45ee3281391e92536459d7cf6f0378e13
@@ -1,6 +1,6 @@
1
1
  function azure_image_selected() {
2
- var url = $('#host_compute_attributes_image').attr('data-url');
3
- var imageId = $('#host_compute_attributes_image').val();
2
+ var url = $('#host_compute_attributes_image_id').attr('data-url');
3
+ var imageId = $('#host_compute_attributes_image_id').val();
4
4
  var azure_locations = $('#azure_locations');
5
5
  var locations_spinner = $('#azure_locations_spinner');
6
6
  tfm.tools.showSpinner();
@@ -10,7 +10,7 @@ function azure_image_selected() {
10
10
  type:'get',
11
11
  url: url,
12
12
  complete: function(){
13
- reloadOnAjaxComplete('#host_compute_attributes_image');
13
+ reloadOnAjaxComplete('#host_compute_attributes_image_id');
14
14
  locations_spinner.addClass('hide');
15
15
  tfm.tools.hideSpinner();
16
16
  },
@@ -2,7 +2,7 @@ module ForemanAzure
2
2
  module Concerns
3
3
  module HostsControllerExtensions
4
4
  def locations
5
- if (azure_resource = Image.find_by_uuid(params[:image_id])).present?
5
+ if (azure_resource = Image.unscoped.find_by_uuid(params[:image_id])).present?
6
6
  render :json => azure_resource.compute_resource.
7
7
  image_locations(params[:image_id])
8
8
  else
@@ -2,7 +2,7 @@ module AzureImagesHelper
2
2
  def select_azure_image(f, images)
3
3
  select_f(
4
4
  f,
5
- :image,
5
+ :image_id,
6
6
  images,
7
7
  :uuid,
8
8
  :name,
@@ -3,6 +3,8 @@ module FogExtensions
3
3
  module Server
4
4
  extend ActiveSupport::Concern
5
5
 
6
+ attr_accessor :image_id
7
+
6
8
  def to_s
7
9
  "#{vm_name}@#{cloud_service_name}"
8
10
  end
@@ -3,16 +3,29 @@ module FogExtensions
3
3
  module Servers
4
4
  extend ActiveSupport::Concern
5
5
 
6
- # Azure servers.all doesn't take any argument, against the fog
7
- # standard, so we override the method.
8
- # https://github.com/fog/fog-azure/pull/25
9
6
  included do
10
7
  alias_method_chain :all, :patched_arguments
8
+ alias_method_chain :get, :cloud_service_patch
11
9
  end
12
10
 
11
+ # Azure servers.all doesn't take any argument, against the fog
12
+ # standard, so we override the method.
13
+ # https://github.com/fog/fog-azure/pull/25
13
14
  def all_with_patched_arguments(_options = {})
14
15
  all_without_patched_arguments
15
16
  end
17
+
18
+ # Azure servers.get takes 2 arguments, the cloud service name and
19
+ # the vm_name. This is against the fog standard, however it's not
20
+ # possible to uniquely find a VM with just one argument. Instead,
21
+ # we try our best (see models/foreman_azure/azure.rb#find_vm_by_uuid
22
+ # for a similar method) to find it.
23
+ def get_with_cloud_service_patch(identity, cloud_service_name = nil)
24
+ cloud_service_name ||= identity
25
+ cloud_service_vm = get_without_cloud_service_patch(identity, cloud_service_name)
26
+ return cloud_service_vm if cloud_service_vm.present?
27
+ find { |vm| vm.vm_name == identity }
28
+ end
16
29
  end
17
30
  end
18
31
  end
@@ -32,15 +32,21 @@ module ForemanAzure
32
32
  client.images
33
33
  end
34
34
 
35
+ def provided_attributes
36
+ super.merge(:ip => :public_ip_address)
37
+ end
38
+
35
39
  def image_locations(image_id)
36
40
  client.images.get(image_id).locations.split(';')
37
41
  end
38
42
 
39
43
  def create_vm(args = {})
44
+ args.delete_if { |_key, value| value.blank? }
40
45
  args[:hostname] = args[:name]
41
46
  args[:vm_name] = args[:name].split('.').first
42
47
  args[:cloud_service_name] ||= args[:vm_name]
43
- args[:vm_user] = Image.find_by_uuid(args[:image]).username
48
+ args[:image] = args[:image_id]
49
+ args[:vm_user] = Image.unscoped.find_by_uuid(args[:image_id]).username
44
50
  args[:private_key_file] = url
45
51
  super(args)
46
52
  end
@@ -0,0 +1,27 @@
1
+ module ForemanAzure
2
+ module Concerns
3
+ module SSHProvisionExtensions
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ alias_method_chain :setSSHWaitForResponse, :use_ssh_keys
8
+ end
9
+
10
+ def setSSHWaitForResponse_with_use_ssh_keys
11
+ if compute_resource.type == "ForemanAzure::Azure"
12
+ self.client = Foreman::Provision::SSH.new(
13
+ provision_ip,
14
+ image.username,
15
+ { :template => template_file.path,
16
+ :uuid => uuid,
17
+ :keys => [compute_resource.certificate_path] })
18
+ else
19
+ setSSHWaitForResponse_without_use_ssh_keys
20
+ end
21
+ rescue => e
22
+ failure _("Failed to login via SSH to %{name}: %{e}") %
23
+ { :name => name, :e => e }, e
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ <% title @vm.name %>
2
+ <div class='col-md-12'>
3
+ <table class="<%= table_css_classes %>">
4
+ <thead>
5
+ <tr><th colspan="2"><%=_('Properties') %></th></tr>
6
+ </thead>
7
+ <tbody>
8
+ <%= prop :vm_name %>
9
+ <%= prop :ipaddress %>
10
+ <%= prop :deployment_status, _('Deployment status') %>
11
+ <%= prop :status %>
12
+ <%= prop :cloud_service_name, _('Cloud service name') %>
13
+ <%= prop :disk_name, _('Disk name') %>
14
+ <%= prop :image %>
15
+ <%= prop :vm_user %>
16
+ <%= prop :vm_size %>
17
+ <%= prop :storage_account_name, _('Storage account name') %>
18
+ </tbody>
19
+ </table>
20
+ </div>
@@ -48,6 +48,8 @@ module ForemanAzure
48
48
 
49
49
  ::HostsController.send :include,
50
50
  ForemanAzure::Concerns::HostsControllerExtensions
51
+ ::Host::Managed.send :include,
52
+ ForemanAzure::Concerns::SSHProvisionExtensions
51
53
  end
52
54
  end
53
55
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanAzure
2
- VERSION = '1.0.2'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_azure
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-03 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-azure
@@ -70,11 +70,13 @@ files:
70
70
  - app/models/concerns/fog_extensions/azure/server.rb
71
71
  - app/models/concerns/fog_extensions/azure/servers.rb
72
72
  - app/models/foreman_azure/azure.rb
73
+ - app/models/foreman_azure/concerns/ssh_provision_extensions.rb
73
74
  - app/overrides/add_image_location_js.rb
74
75
  - app/views/compute_resources/form/_azure.html.erb
75
76
  - app/views/compute_resources/show/_azure.html.erb
76
77
  - app/views/compute_resources_vms/form/azure/_base.html.erb
77
78
  - app/views/compute_resources_vms/index/_azure.html.erb
79
+ - app/views/compute_resources_vms/show/_azure.html.erb
78
80
  - app/views/images/form/_azure.html.erb
79
81
  - config/routes.rb
80
82
  - lib/foreman_azure.rb