foreman_hyperv 0.0.3 → 0.0.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
- SHA1:
3
- metadata.gz: fb57dc6dd0bcc2a285337c23b89ed22a80a503fa
4
- data.tar.gz: 3aac593cc35eb225047ca473c5bc3f7f0bc4a334
2
+ SHA256:
3
+ metadata.gz: 656e65f4adac7c822917eb7db0a43c4cfb00925448f314fcf4237a5a447b4b15
4
+ data.tar.gz: 39dc334e97cb77a6478b62f053e08164499f43f4cf0a1b765a1569ca2605dac7
5
5
  SHA512:
6
- metadata.gz: c8dea6446ab0ef7359678fd49e02bce16eb9930195f95005d21100472d98d8ce282b9225e1a1f5dc186e402f5f7a15c52ed3eded0da2ce02293666416b6c663e
7
- data.tar.gz: e77ff169aaa0c97f0db2f40658ea66fb579b75967e466cb553075d269099f098b747618070764bda6bdfcf72b9ba930675ab745c2d237a1186ca90f8d04ae42e
6
+ metadata.gz: 94b74fbae8688e6cf3a61d8215f351dba23d188a97b3064a5d65450528552b7931e3b08bc9cee7c2ced1ab4c4386f97de481f2bc27d4ebec7fb5b43c3f550d69
7
+ data.tar.gz: '040623999a84a2baace36ba43c1e29f18072bb833bf0b18d1adaf5ad93bc6f5a5994f2e6fbf984849820fd31cc10b260ef9c935a20b44daffc9ddb5650b7ae47'
@@ -1,3 +1,11 @@
1
+ ## v0.0.4 2018-04-06
2
+
3
+ - Allow setting a VM-wide VLAN value
4
+ - Default to using the first available cluster if one exists
5
+ - This allows the use of clustered machines, as long as all machines are set up with identical switch configurations
6
+ - Support the creation of legacy NICs for BIOS
7
+ - Requires fog-hyperv 0.0.8 / d4bf0fcdef691573c25744c3f3930961d5f767d6
8
+
1
9
  ## v0.0.3 2018-01-15
2
10
 
3
11
  - Fix association of VMs by MAC address (case issue)
data/README.md CHANGED
@@ -4,7 +4,11 @@
4
4
 
5
5
  Microsoft Hyper-V compute resource for Foreman
6
6
 
7
- Uses the in-development `fog-hyperv` gem found [here](https://github.com/ace13/fog-hyperv).
7
+ Uses the in-development `fog-hyperv` gem found [here](https://github.com/ananace/fog-hyperv).
8
+
9
+ ## Nota Bene
10
+
11
+ Currently the plugin only supports Hyper-V hosts where the names are well defined in DNS and in connection strings, avoid using IP addresses for now.
8
12
 
9
13
  ## Testing/Installing
10
14
 
@@ -16,7 +20,7 @@ Do bear in mind that this is still very early in development, so plenty of issue
16
20
 
17
21
  ## Contributing
18
22
 
19
- Bug reports and pull requests are welcome on GitHub at https://github.com/ace13/foreman_hyperv.
23
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ananace/foreman_hyperv.
20
24
 
21
25
  ## License
22
26
 
@@ -24,6 +24,14 @@ module FogExtensions
24
24
  def network=(net)
25
25
  self.switch_name = net
26
26
  end
27
+
28
+ def type
29
+ is_legacy
30
+ end
31
+
32
+ def type=(type)
33
+ self.is_legacy = type
34
+ end
27
35
  end
28
36
  end
29
37
  end
@@ -34,10 +34,16 @@ module FogExtensions
34
34
  identity.present?
35
35
  end
36
36
 
37
- def interfaces_attributes=(_attributes); end
37
+ def interfaces_attributes=(_attributes)
38
+ true
39
+ end
38
40
 
39
41
  def volumes_attributes=(_attributes); end
40
42
 
43
+ def vlan; end
44
+
45
+ def vlan=(_vlan); end
46
+
41
47
  def secure_boot_enabled=(enabled)
42
48
  @secure_boot = enabled
43
49
  return unless persisted?
@@ -56,6 +62,10 @@ module FogExtensions
56
62
  restart(force: true)
57
63
  end
58
64
 
65
+ def state
66
+ attributes[:state].to_s.upcase
67
+ end
68
+
59
69
  def stop
60
70
  requires :name, :computer_name
61
71
  service.stop_vm options.merge(
@@ -55,8 +55,11 @@ module ForemanHyperv
55
55
  args = vm_instance_defaults.merge(args.to_hash.deep_symbolize_keys)
56
56
  client.logger.debug "Creating a VM with arguments; #{args}"
57
57
 
58
+ args[:computer_name] = args[:computer_name].presence || '.'
59
+
58
60
  pre_create = {
59
61
  boot_device: 'NetworkAdapter',
62
+ computer_name: args[:computer_name],
60
63
  generation: args[:generation].to_i,
61
64
  memory_startup: args[:memory_startup].presence.to_i,
62
65
  name: args[:name],
@@ -87,6 +90,8 @@ module ForemanHyperv
87
90
  create_interfaces(vm, args[:interfaces_attributes])
88
91
  create_volumes(vm, args[:volumes_attributes])
89
92
 
93
+ vm.set_vlan(args[:vlan].to_i) if args[:vlan].presence && vm.respond_to?(:set_vlan)
94
+
90
95
  vm
91
96
  rescue StandardError => e
92
97
  vm.stop turn_off: true
@@ -160,13 +165,18 @@ module ForemanHyperv
160
165
  if client.respond_to? :supports_clusters?
161
166
  return [] unless client.supports_clusters?
162
167
  end
163
- client.clusters rescue []
168
+
169
+ client.clusters
170
+ rescue
171
+ []
164
172
  end
165
173
 
166
174
  def hypervisor
167
175
  client.hosts.first
168
176
  end
169
177
 
178
+ delegate :servers, to: :client
179
+
170
180
  protected
171
181
 
172
182
  def client
@@ -198,6 +208,9 @@ module ForemanHyperv
198
208
  nic.mac = iface[:mac]
199
209
  nic.dynamic_mac_address_enabled = false
200
210
  end
211
+ if vm.generation == 1 && iface[:type].present?
212
+ nic.is_legacy = Foreman::Cast.to_bool(iface[:type])
213
+ end
201
214
  nic.save
202
215
  end
203
216
 
@@ -1,13 +1,31 @@
1
1
  <%= javascript_tag("$(document).on('ContentLoad', tfm.numFields.initAll)") %>
2
2
 
3
3
  <%
4
- clusters = compute_resource.clusters.map(&:name)
5
- computers = (f.object.cluster || compute_resource).hosts.map(&:name)
4
+ cluster_errors = []
5
+ begin
6
+ clusters = compute_resource.clusters.map(&:name)
7
+ f.object.cluster_name = clusters.first if clusters.count == 1
8
+ computers = (compute_resource.clusters.find {|c| c.name == f.object.cluster_name } || compute_resource).hosts.map(&:name)
9
+ rescue Fog::Hyperv::Errors::PSError => ex
10
+ # In case of errors
11
+ clusters = []
12
+ computers = []
13
+
14
+ cluster_errors << ex
15
+ end
6
16
  %>
7
- <% if clusters.any? %>
8
- <%= select_f f, :cluster_name, clusters, :to_s, :to_s %>
9
- <%= select_f f, :computer_name, computers, :to_s, :to_s %>
17
+ <% if clusters.any? -%>
18
+ <%= select_f f, :cluster_name, clusters, :to_s, :to_s, { include_blank: true }, label: _('Cluster') %>
19
+ <% if computers.count > 1 -%>
20
+ <%= select_f f, :computer_name, computers, :to_s, :to_s, {}, label: _('Computer Name') %>
21
+ <% end -%>
10
22
  <% end %>
23
+ <% cluster_errors.each do |err| -%>
24
+ <div class="alert alert-warning alert-dismissable">
25
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
26
+ <span class="pficon pficon-error-circle-o "></span> <span class="text"><%= err.message %> (<%= err.info %>)</span>
27
+ </div>
28
+ <% end -%>
11
29
 
12
30
  <%
13
31
  generations = [ [1, 'Generation 1 (BIOS)'], [2, 'Generation 2 (UEFI)'] ]
@@ -25,6 +43,9 @@
25
43
  <%= checkbox_f f, :dynamic_memory_enabled, { label: _('Use Dynamic Memory'), onchange: 'hypervDynamicMemoryChange(this);' }, 'true', 'false' %>
26
44
 
27
45
  <% if new_host %>
46
+ <% if compute_resource.servers.new().respond_to? :set_vlan -%>
47
+ <%= text_f f, :vlan, label: _('VLAN'), label_size: 'col-md-2' %>
48
+ <% end -%>
28
49
  <% checked = params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:start] || '1' %>
29
50
  <%= checkbox_f f, :start, { checked: (checked == '1'), help_inline: _("Power ON this machine"), label: _('Start'), label_size: "col-md-2"} if new_host && controller_name != "compute_attributes" %>
30
51
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%
2
- networks = (f.object.computer || compute_resource).switches.map do |sw|
2
+ networks = compute_resource.switches.map do |sw|
3
3
  [ sw.name, "#{sw.name}#{sw.switch_type ? " (#{sw.switch_type})" : nil}" ]
4
4
  end
5
5
  %>
@@ -7,4 +7,5 @@
7
7
  <%= select_f f, :network, networks, :first, :last,
8
8
  { include_blank: true },
9
9
  { label: _('Network switch'), :label_size => 'col-md-3' } %>
10
+ <%= checkbox_f f, :type, { label: _('Legacy Network Adapter'), label_size: 'col-md-3', disabled: !new_host }, 'true', 'false' %>
10
11
  <%= f.hidden_field :id %>
@@ -1,3 +1,3 @@
1
1
  module ForemanHyperv
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '0.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_hyperv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Olofsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-15 00:00:00.000000000 Z
11
+ date: 2018-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-hyperv
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.6.14
124
+ rubygems_version: 2.7.6
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Hyper-V as a Compute Resource for Foreman