foreman_fog_proxmox 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of foreman_fog_proxmox might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +24 -12
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +26 -0
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +92 -0
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_container.js +60 -0
- data/app/assets/javascripts/foreman_fog_proxmox/{proxmox.js → proxmox_vm_server.js} +10 -10
- data/app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb +1 -1
- data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +9 -1
- data/app/helpers/node_dashboard_helper.rb +36 -0
- data/app/helpers/proxmox_compute_selectors_helper.rb +23 -0
- data/app/helpers/proxmox_container_helper.rb +157 -0
- data/app/helpers/proxmox_form_helper.rb +67 -0
- data/app/helpers/{proxmox_compute_helper.rb → proxmox_server_helper.rb} +49 -38
- data/app/helpers/proxmox_vm_helper.rb +86 -0
- data/app/models/concerns/fog_extensions/proxmox/container.rb +57 -0
- data/{test/factories/foreman_fog_proxmox_factories.rb → app/models/concerns/fog_extensions/proxmox/container_config.rb} +16 -13
- data/app/models/concerns/fog_extensions/proxmox/server.rb +8 -2
- data/app/models/foreman_fog_proxmox/proxmox.rb +160 -67
- data/app/overrides/compute_resources_vms/form/add_clone_to_new_vm_compute_detail.rb +24 -0
- data/app/overrides/compute_resources_vms/form/add_vm_type_to_networks_form.rb +32 -0
- data/app/overrides/compute_resources_vms/form/add_vm_type_to_nic_provider_specific_form.rb +25 -0
- data/app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_edit.rb +24 -0
- data/app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_new_volume.rb +24 -0
- data/app/services/foreman_fog_proxmox/node_dashboard/data.rb +37 -0
- data/app/views/compute_resources/form/_proxmox.html.erb +7 -4
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_form.html.erb +23 -0
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_new_childs_form.html.erb +25 -0
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_nic_provider_specific_form.html.erb +23 -0
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb +73 -0
- data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +16 -23
- data/app/views/compute_resources_vms/form/proxmox/_general.html.erb +37 -0
- data/app/views/compute_resources_vms/form/proxmox/_network.html.erb +2 -7
- data/app/views/compute_resources_vms/form/proxmox/container/_advanced.html.erb +31 -0
- data/app/views/compute_resources_vms/form/proxmox/container/_config.html.erb +41 -0
- data/app/views/compute_resources_vms/form/proxmox/container/_extended.html.erb +26 -0
- data/app/views/compute_resources_vms/form/proxmox/container/_network.html.erb +25 -0
- data/app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb +25 -0
- data/app/views/compute_resources_vms/form/proxmox/container/_volume_rootfs.html.erb +24 -0
- data/app/views/compute_resources_vms/form/proxmox/server/_advanced.html.erb +31 -0
- data/app/views/compute_resources_vms/form/proxmox/{_config.html.erb → server/_config.html.erb} +11 -8
- data/app/views/compute_resources_vms/form/proxmox/server/_network.html.erb +29 -0
- data/app/views/compute_resources_vms/form/proxmox/server/_volume.html.erb +27 -0
- data/app/views/compute_resources_vms/index/_proxmox.html.erb +4 -2
- data/app/views/compute_resources_vms/show/_proxmox.html.erb +9 -2
- data/app/views/dashboard/_foreman_fog_proxmox_widget.erb +4 -2
- data/app/views/images/form/_proxmox.html.erb +17 -0
- data/config/routes.rb +1 -0
- data/lib/foreman_fog_proxmox/engine.rb +10 -3
- data/lib/foreman_fog_proxmox/value.rb +24 -0
- data/lib/foreman_fog_proxmox/version.rb +1 -1
- data/locale/en/foreman_fog_proxmox.edit.po +456 -0
- data/locale/en/foreman_fog_proxmox.po +327 -11
- data/locale/en/foreman_fog_proxmox.po.time_stamp +0 -0
- data/locale/foreman_fog_proxmox.pot +515 -8
- data/locale/fr/foreman_fog_proxmox.edit.po +456 -0
- data/locale/fr/foreman_fog_proxmox.po +327 -11
- data/locale/fr/foreman_fog_proxmox.po.time_stamp +0 -0
- data/test/factories/proxmox_factory.rb +72 -0
- data/test/functional/compute_resources_controller_test.rb +34 -0
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +205 -0
- data/test/{helpers/proxmox_compute_helper_test.rb → unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb} +36 -28
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +240 -0
- data/test/unit/foreman_fog_proxmox/proxmox_test.rb +327 -0
- data/test/unit/foreman_fog_proxmox/proxmox_test_helpers.rb +251 -0
- metadata +83 -14
- data/app/views/compute_resources_vms/form/proxmox/_volume.html.erb +0 -23
- data/test/unit/foreman_fog_proxmox_test.rb +0 -11
@@ -21,12 +21,14 @@ require 'fog/proxmox'
|
|
21
21
|
|
22
22
|
module ForemanFogProxmox
|
23
23
|
class Proxmox < ComputeResource
|
24
|
-
include
|
24
|
+
include ProxmoxVmHelper
|
25
|
+
include ProxmoxServerHelper
|
26
|
+
include ProxmoxContainerHelper
|
25
27
|
validates :url, :format => { :with => URI::DEFAULT_PARSER.make_regexp }, :presence => true
|
26
28
|
validates :user, :format => { :with => /(\w+)[@]{1}(\w+)/ }, :presence => true
|
27
29
|
validates :password, :presence => true
|
30
|
+
validates :node_name, :presence => true
|
28
31
|
before_create :test_connection
|
29
|
-
attr_accessor :node
|
30
32
|
|
31
33
|
def provided_attributes
|
32
34
|
super.merge(
|
@@ -47,7 +49,7 @@ module ForemanFogProxmox
|
|
47
49
|
end
|
48
50
|
|
49
51
|
def credentials_valid?
|
50
|
-
errors[:url].empty? && errors[:user].empty? && errors[:user].include?('@') && errors[:password].empty? &&
|
52
|
+
errors[:url].empty? && errors[:user].empty? && errors[:user].include?('@') && errors[:password].empty? && errors[:node_name].empty?
|
51
53
|
end
|
52
54
|
|
53
55
|
def test_connection(options = {})
|
@@ -59,8 +61,8 @@ module ForemanFogProxmox
|
|
59
61
|
end
|
60
62
|
|
61
63
|
def nodes
|
62
|
-
nodes = client.nodes.all
|
63
|
-
nodes.sort_by(&:node)
|
64
|
+
nodes = client.nodes.all if client
|
65
|
+
nodes.sort_by(&:node) if nodes
|
64
66
|
end
|
65
67
|
|
66
68
|
def pools
|
@@ -68,19 +70,14 @@ module ForemanFogProxmox
|
|
68
70
|
pools.sort_by(&:poolid)
|
69
71
|
end
|
70
72
|
|
71
|
-
def storages
|
72
|
-
storages = node.storages.list_by_content_type
|
73
|
+
def storages(type = 'images')
|
74
|
+
storages = node.storages.list_by_content_type type
|
73
75
|
storages.sort_by(&:storage)
|
74
76
|
end
|
75
77
|
|
76
|
-
def
|
77
|
-
storages = node.storages.list_by_content_type 'iso'
|
78
|
-
storages.sort_by(&:storage)
|
79
|
-
end
|
80
|
-
|
81
|
-
def isos(storage_id)
|
78
|
+
def images_by_storage(type = 'iso', storage_id)
|
82
79
|
storage = node.storages.find_by_id storage_id if storage_id
|
83
|
-
storage.volumes.list_by_content_type(
|
80
|
+
storage.volumes.list_by_content_type(type).sort_by(&:volid) if storage
|
84
81
|
end
|
85
82
|
|
86
83
|
def associated_host(vm)
|
@@ -104,51 +101,85 @@ module ForemanFogProxmox
|
|
104
101
|
end
|
105
102
|
|
106
103
|
def template(vmid)
|
107
|
-
find_vm_by_uuid(vmid)
|
104
|
+
vm = find_vm_by_uuid("qemu_#{vmid}")
|
105
|
+
vm = find_vm_by_uuid("lxc_#{vmid}") unless vm
|
106
|
+
vm
|
108
107
|
end
|
109
108
|
|
110
109
|
def host_compute_attrs(host)
|
111
110
|
super.tap do |attrs|
|
112
111
|
ostype = host.compute_attributes['config_attributes']['ostype']
|
113
|
-
|
112
|
+
case host.compute_attributes['type']
|
113
|
+
when 'lxc'
|
114
|
+
host.compute_attributes['config_attributes'].store('hostname',host.name)
|
115
|
+
when 'qemu'
|
116
|
+
raise ::Foreman::Exception.new(_("Operating system family %{type} is not consistent with %{ostype}") % { type: host.operatingsystem.type, ostype: ostype }) unless compute_os_types(host).include?(ostype)
|
117
|
+
end
|
114
118
|
end
|
115
119
|
end
|
116
120
|
|
117
121
|
def host_interfaces_attrs(host)
|
118
122
|
host.interfaces.select(&:physical?).each.with_index.reduce({}) do |hash, (nic, index)|
|
119
|
-
raise ::Foreman::Exception.new
|
120
|
-
raise ::Foreman::Exception.new
|
121
|
-
|
123
|
+
raise ::Foreman::Exception.new _("Identifier interface[%{index}] required." % { index: index }) if nic.identifier.empty?
|
124
|
+
raise ::Foreman::Exception.new _("Invalid identifier interface[%{index}]. Must be net[n] with n integer >= 0" % { index: index }) unless Fog::Proxmox::NicHelper.valid?(nic.identifier)
|
125
|
+
nic_compute_attributes = nic.compute_attributes.merge(id: nic.identifier)
|
126
|
+
nic_compute_attributes.store(:ip, nic.ip) if (nic.ip && !nic.ip.empty?)
|
127
|
+
nic_compute_attributes.store(:ip6, nic.ip6) if (nic.ip6 && !nic.ip6.empty?)
|
128
|
+
hash.merge(index.to_s => nic_compute_attributes)
|
122
129
|
end
|
123
130
|
end
|
124
131
|
|
125
132
|
def new_volume(attr = {})
|
126
|
-
|
133
|
+
type = attr['type']
|
134
|
+
type = 'qemu' unless type
|
135
|
+
case type
|
136
|
+
when 'lxc'
|
137
|
+
return new_volume_server(attr)
|
138
|
+
when 'qemu'
|
139
|
+
return new_volume_container(attr)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def new_volume_server(attr = {})
|
144
|
+
opts = volume_server_defaults.merge(attr.to_h).deep_symbolize_keys
|
145
|
+
opts[:size] = opts[:size].to_s
|
146
|
+
Fog::Compute::Proxmox::Disk.new(opts)
|
147
|
+
end
|
148
|
+
|
149
|
+
def new_volume_container(attr = {})
|
150
|
+
id = attr[:id]
|
151
|
+
opts = volume_container_defaults(id).merge(attr.to_h).deep_symbolize_keys
|
127
152
|
opts[:size] = opts[:size].to_s
|
128
153
|
Fog::Compute::Proxmox::Disk.new(opts)
|
129
154
|
end
|
130
155
|
|
131
156
|
def new_interface(attr = {})
|
132
|
-
opts =
|
157
|
+
opts = interface_server_defaults.merge(attr.to_h).deep_symbolize_keys
|
133
158
|
Fog::Compute::Proxmox::Interface.new(opts)
|
134
159
|
end
|
135
160
|
|
136
161
|
def vm_compute_attributes(vm)
|
137
|
-
vm_attrs = vm.attributes
|
138
|
-
vm_attrs =
|
162
|
+
vm_attrs = vm.attributes.reject { |key,value| [:config].include?(key) || value.to_s.empty? }
|
163
|
+
vm_attrs = set_vm_config_attributes(vm, vm_attrs)
|
139
164
|
vm_attrs = set_vm_volumes_attributes(vm, vm_attrs)
|
140
165
|
vm_attrs = set_vm_interfaces_attributes(vm, vm_attrs)
|
141
166
|
vm_attrs
|
142
167
|
end
|
143
168
|
|
144
|
-
def
|
145
|
-
if vm.
|
146
|
-
|
147
|
-
vm_attrs[:
|
169
|
+
def set_vm_config_attributes(vm, vm_attrs)
|
170
|
+
if vm.respond_to?(:config)
|
171
|
+
config = vm.config.attributes.reject { |key,value| [:disks,:mount_points,:interfaces].include?(key) || value.to_s.empty?}
|
172
|
+
vm_attrs[:config_attributes] = config
|
148
173
|
end
|
149
174
|
vm_attrs
|
150
175
|
end
|
151
176
|
|
177
|
+
def set_vm_volumes_attributes(vm, vm_attrs)
|
178
|
+
volumes = vm.container? ? vm.config.mount_points : vm.config.disks || []
|
179
|
+
vm_attrs[:volumes_attributes] = Hash[volumes.each_with_index.map { |volume, idx| [idx.to_s, volume.attributes] }]
|
180
|
+
vm_attrs
|
181
|
+
end
|
182
|
+
|
152
183
|
def set_vm_interfaces_attributes(vm, vm_attrs)
|
153
184
|
if vm.config.respond_to?(:interfaces)
|
154
185
|
interfaces = vm.config.interfaces || []
|
@@ -158,37 +189,72 @@ module ForemanFogProxmox
|
|
158
189
|
end
|
159
190
|
|
160
191
|
def new_vm(attr = {})
|
161
|
-
|
162
|
-
|
192
|
+
attr = ActiveSupport::HashWithIndifferentAccess.new(attr)
|
193
|
+
type = attr['type']
|
194
|
+
type = 'qemu' unless type
|
195
|
+
case type
|
196
|
+
when 'lxc'
|
197
|
+
vm = new_container_vm(attr)
|
198
|
+
when 'qemu'
|
199
|
+
vm = new_server_vm(attr)
|
200
|
+
end
|
201
|
+
logger.debug(_("new_vm() vm.config=%{config}") % { config: vm.config.inspect })
|
202
|
+
vm
|
203
|
+
end
|
204
|
+
|
205
|
+
def new_container_vm(attr = {})
|
206
|
+
vm = node.containers.new(vm_container_instance_defaults.merge(parse_container_vm(attr.merge(type: 'lxc'))))
|
207
|
+
logger.debug(_("new_container_vm() vm.config=%{config}") % { config: vm.config.inspect })
|
208
|
+
vm
|
209
|
+
end
|
210
|
+
|
211
|
+
def new_server_vm(attr = {})
|
212
|
+
vm = node.servers.new(vm_server_instance_defaults.merge(parse_server_vm(attr.merge(type: 'qemu'))))
|
213
|
+
logger.debug(_("new_server_vm() vm.config=%{config}") % { config: vm.config.inspect })
|
163
214
|
vm
|
164
215
|
end
|
165
216
|
|
166
217
|
def create_vm(args = {})
|
167
|
-
vmid = args[:vmid]
|
168
|
-
|
218
|
+
vmid = args[:vmid].to_i
|
219
|
+
type = args[:type]
|
220
|
+
raise ::Foreman::Exception.new N_("invalid vmid=%{vmid}") % { vmid: vmid } unless node.servers.id_valid?(vmid)
|
169
221
|
image_id = args[:image_id]
|
170
|
-
node = get_cluster_node args
|
171
222
|
if image_id
|
172
|
-
logger.debug("create_vm(): clone
|
223
|
+
logger.debug(_("create_vm(): clone %{image_id} in %{vmid}") % { image_id: image_id, vmid: vmid })
|
173
224
|
image = node.servers.get image_id
|
174
225
|
image.clone(vmid)
|
226
|
+
clone = node.servers.get vmid
|
227
|
+
clone.update(name: args[:name])
|
175
228
|
else
|
176
|
-
logger.debug("create_vm():
|
229
|
+
logger.debug(_("create_vm(): %{args}") % { args: args })
|
177
230
|
convert_sizes(args)
|
178
|
-
|
231
|
+
case type
|
232
|
+
when 'qemu'
|
233
|
+
node.servers.create(parse_server_vm(args))
|
234
|
+
when 'lxc'
|
235
|
+
hash = parse_container_vm(args)
|
236
|
+
hash = hash.merge(vmid: vmid)
|
237
|
+
node.containers.create(hash.reject { |key,_value| %w[ostemplate_storage ostemplate_file].include? key })
|
238
|
+
end
|
179
239
|
end
|
180
|
-
vm = find_vm_by_uuid(vmid)
|
240
|
+
vm = find_vm_by_uuid("#{type}_#{vmid}")
|
181
241
|
vm
|
182
242
|
rescue => e
|
183
|
-
logger.warn
|
243
|
+
logger.warn(_("failed to create vm: %{e}") % { e: e })
|
184
244
|
destroy_vm vm.id if vm
|
185
245
|
raise e
|
186
246
|
end
|
187
247
|
|
188
248
|
def find_vm_by_uuid(uuid)
|
189
|
-
|
249
|
+
type, vmid = parse_type_and_vmid(uuid)
|
250
|
+
case type
|
251
|
+
when 'qemu'
|
252
|
+
node.servers.get(vmid)
|
253
|
+
when 'lxc'
|
254
|
+
node.containers.get(vmid)
|
255
|
+
end
|
190
256
|
rescue Fog::Errors::Error => e
|
191
|
-
Foreman::Logging.exception("Failed retrieving proxmox vm by vmid
|
257
|
+
Foreman::Logging.exception(_("Failed retrieving proxmox vm by vmid=%{vmid} and type=%{type}") % { vmid: vmid, type: type }, e)
|
192
258
|
raise(ActiveRecord::RecordNotFound)
|
193
259
|
end
|
194
260
|
|
@@ -219,18 +285,23 @@ module ForemanFogProxmox
|
|
219
285
|
end
|
220
286
|
|
221
287
|
def image_exists?(image)
|
222
|
-
find_vm_by_uuid(image)
|
288
|
+
vm = find_vm_by_uuid("qemu_#{image}")
|
289
|
+
vm = find_vm_by_uuid("lxc_#{image}") unless vm
|
290
|
+
vm!=nil
|
223
291
|
end
|
224
292
|
|
225
293
|
def save_vm(uuid, attr)
|
294
|
+
type, vmid = parse_type_and_vmid(uuid)
|
295
|
+
attr = attr.merge(type: type, vmid: vmid)
|
226
296
|
vm = find_vm_by_uuid(uuid)
|
227
|
-
logger.debug("save_vm():
|
297
|
+
logger.debug(N_("save_vm(): %{attr}") % { attr: attr })
|
228
298
|
templated = attr[:templated]
|
229
299
|
if (templated == '1' && !vm.templated?)
|
230
300
|
vm.template
|
231
301
|
else
|
232
|
-
|
233
|
-
|
302
|
+
parsed_attr = vm.container? ? parse_container_vm(attr) : parse_server_vm(attr)
|
303
|
+
merged = vm.config.attributes.merge(parsed_attr.symbolize_keys).deep_symbolize_keys
|
304
|
+
filtered = merged.reject { |key,value| [:node,:vmid,:type,:templated,:image_id].include?(key) || value.to_s.empty? }
|
234
305
|
vm.update(filtered)
|
235
306
|
end
|
236
307
|
end
|
@@ -239,8 +310,16 @@ module ForemanFogProxmox
|
|
239
310
|
node.servers.next_id
|
240
311
|
end
|
241
312
|
|
313
|
+
def node_name
|
314
|
+
self.attrs[:node_name]
|
315
|
+
end
|
316
|
+
|
317
|
+
def node_name=(value)
|
318
|
+
self.attrs[:node_name] = value
|
319
|
+
end
|
320
|
+
|
242
321
|
def node
|
243
|
-
|
322
|
+
client.nodes.find_by_id node_name
|
244
323
|
end
|
245
324
|
|
246
325
|
def ssl_certs
|
@@ -281,11 +360,15 @@ module ForemanFogProxmox
|
|
281
360
|
|
282
361
|
def console(uuid)
|
283
362
|
vm = find_vm_by_uuid(uuid)
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
363
|
+
type_console = vm.config.type_console
|
364
|
+
options = {}
|
365
|
+
options.store(:websocket, 1) if type_console == 'vnc'
|
366
|
+
begin
|
367
|
+
vnc_console = vm.start_console(options)
|
368
|
+
WsProxy.start(:host => host, :host_port => vnc_console['port'], :password => vnc_console['ticket']).merge(:name => vm.name, :type => type_console)
|
369
|
+
rescue => e
|
370
|
+
logger.error(e)
|
371
|
+
raise ::Foreman::Exception.new(_("%s console is not supported at this time") % type_console)
|
289
372
|
end
|
290
373
|
end
|
291
374
|
|
@@ -319,8 +402,9 @@ module ForemanFogProxmox
|
|
319
402
|
@network_client = nil
|
320
403
|
end
|
321
404
|
|
322
|
-
def
|
323
|
-
|
405
|
+
def vm_server_instance_defaults
|
406
|
+
ActiveSupport::HashWithIndifferentAccess.new(
|
407
|
+
name: "foreman_#{Time.now.to_i}",
|
324
408
|
vmid: next_vmid,
|
325
409
|
type: 'qemu',
|
326
410
|
node: node.to_s,
|
@@ -334,23 +418,39 @@ module ForemanFogProxmox
|
|
334
418
|
cpu: 'kvm64',
|
335
419
|
scsihw: 'virtio-scsi-pci',
|
336
420
|
ide2: "none,media=cdrom",
|
337
|
-
templated: 0
|
338
|
-
).merge(Fog::Proxmox::DiskHelper.flatten(volume_defaults)).merge(Fog::Proxmox::NicHelper.flatten(interface_defaults))
|
421
|
+
templated: 0).merge(Fog::Proxmox::DiskHelper.flatten(volume_server_defaults)).merge(Fog::Proxmox::NicHelper.flatten(interface_server_defaults))
|
339
422
|
end
|
340
423
|
|
341
|
-
def
|
424
|
+
def vm_container_instance_defaults
|
425
|
+
ActiveSupport::HashWithIndifferentAccess.new(
|
426
|
+
name: "foreman_#{Time.now.to_i}",
|
427
|
+
vmid: next_vmid,
|
428
|
+
type: 'lxc',
|
429
|
+
node: node.to_s,
|
430
|
+
memory: 512 * MEGA,
|
431
|
+
templated: 0).merge(Fog::Proxmox::DiskHelper.flatten(volume_container_defaults)).merge(Fog::Proxmox::NicHelper.container_flatten(interface_container_defaults))
|
432
|
+
end
|
433
|
+
|
434
|
+
def vm_instance_defaults
|
435
|
+
super.merge(vmid: next_vmid, node: node.to_s)
|
436
|
+
end
|
437
|
+
|
438
|
+
def volume_server_defaults(controller = 'scsi', device = 0)
|
342
439
|
id = "#{controller}#{device}"
|
343
440
|
{ id: id, storage: storages.first.to_s, size: (8 * GIGA), options: { cache: 'none' } }
|
344
441
|
end
|
345
442
|
|
346
|
-
def
|
443
|
+
def volume_container_defaults(id='rootfs')
|
444
|
+
{ id: id, storage: storages.first.to_s, size: (8 * GIGA), options: { } }
|
445
|
+
end
|
446
|
+
|
447
|
+
def interface_server_defaults(id = 'net0')
|
347
448
|
{ id: id, model: 'virtio', bridge: bridges.first.to_s }
|
348
449
|
end
|
349
450
|
|
350
|
-
def
|
351
|
-
|
352
|
-
|
353
|
-
end
|
451
|
+
def interface_container_defaults(id = 'net0')
|
452
|
+
{ id: id, name: 'eth0', bridge: bridges.first.to_s }
|
453
|
+
end
|
354
454
|
|
355
455
|
def compute_os_types(host)
|
356
456
|
os_linux_types_mapping(host).empty? ? os_windows_types_mapping(host) : os_linux_types_mapping(host)
|
@@ -364,7 +464,7 @@ module ForemanFogProxmox
|
|
364
464
|
end
|
365
465
|
|
366
466
|
def available_linux_operating_systems
|
367
|
-
%w[l24 l26]
|
467
|
+
%w[l24 l26 debian ubuntu centos fedora opensuse archlinux gentoo alpine]
|
368
468
|
end
|
369
469
|
|
370
470
|
def available_windows_operating_systems
|
@@ -379,13 +479,6 @@ module ForemanFogProxmox
|
|
379
479
|
%w[Windows].include?(host.operatingsystem.type) ? available_windows_operating_systems : []
|
380
480
|
end
|
381
481
|
|
382
|
-
def convert_sizes(args)
|
383
|
-
args['config_attributes']['memory'] = (args['config_attributes']['memory'].to_i / MEGA).to_s
|
384
|
-
args['config_attributes']['min_memory'] = (args['config_attributes']['min_memory'].to_i / MEGA).to_s
|
385
|
-
args['config_attributes']['shares'] = (args['config_attributes']['shares'].to_i / MEGA).to_s
|
386
|
-
args['volumes_attributes'].each_value { |value| value['size'] = (value['size'].to_i / GIGA).to_s }
|
387
|
-
end
|
388
|
-
|
389
482
|
def host
|
390
483
|
URI.parse(url).host
|
391
484
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright 2018 Tristan Robert
|
2
|
+
|
3
|
+
# This file is part of ForemanFogProxmox.
|
4
|
+
|
5
|
+
# ForemanFogProxmox is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
|
10
|
+
# ForemanFogProxmox is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
Deface::Override.new(
|
19
|
+
:virtual_path => "hosts/_compute_detail",
|
20
|
+
:name => "add_clone_to_new_vm_compute_detail",
|
21
|
+
:replace => "erb[silent]:contains('new_vm = @host.nil? || new_vm?(@host)')",
|
22
|
+
:text => "<% new_vm = @host.nil? || new_vm?(@host) || @host.name.nil? %>",
|
23
|
+
:original => "<% new_vm = @host.nil? || new_vm?(@host) %>"
|
24
|
+
)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright 2018 Tristan Robert
|
2
|
+
|
3
|
+
# This file is part of ForemanFogProxmox.
|
4
|
+
|
5
|
+
# ForemanFogProxmox is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
|
10
|
+
# ForemanFogProxmox is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
Deface::Override.new(
|
19
|
+
:virtual_path => "compute_resources_vms/form/_networks",
|
20
|
+
:name => "add_vm_type_to_networks_form",
|
21
|
+
:replace => "erb[loud]:contains('render')",
|
22
|
+
:partial => "compute_resources_vms/form/proxmox/add_vm_type_to_networks_form",
|
23
|
+
:original => 'bae57f59cbbf6fcf1aecdf3a02baee5ff3494c85'
|
24
|
+
)
|
25
|
+
|
26
|
+
Deface::Override.new(
|
27
|
+
:virtual_path => "compute_resources_vms/form/_networks",
|
28
|
+
:name => "add_vm_type_to_networks_new_childs_form",
|
29
|
+
:replace => "erb[loud]:contains('new_child_fields_template')",
|
30
|
+
:partial => "compute_resources_vms/form/proxmox/add_vm_type_to_networks_new_childs_form",
|
31
|
+
:original => '4ba200e5e02810ade03827374de9b0b8b6a2f6a9'
|
32
|
+
)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Copyright 2018 Tristan Robert
|
2
|
+
|
3
|
+
# This file is part of ForemanFogProxmox.
|
4
|
+
|
5
|
+
# ForemanFogProxmox is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
|
10
|
+
# ForemanFogProxmox is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
Deface::Override.new(
|
19
|
+
:virtual_path => "nic/_provider_specific_form",
|
20
|
+
:name => "add_vm_type_to_nic_provider_specific_form",
|
21
|
+
:replace => "erb[loud]:contains('f.fields_for')",
|
22
|
+
:closing_selector => "erb[silent]:contains('end')",
|
23
|
+
:partial => "compute_resources_vms/form/proxmox/add_vm_type_to_nic_provider_specific_form",
|
24
|
+
:original => '3c575e0e570cc620277fbffd61bfdc7c42bbdc77'
|
25
|
+
)
|