foreman_m2 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +619 -0
  3. data/README.md +48 -0
  4. data/Rakefile +47 -0
  5. data/app/controllers/foreman_m2/hosts_controller.rb +19 -0
  6. data/app/helpers/concerns/foreman_m2/hosts_helper_extensions.rb +12 -0
  7. data/app/helpers/concerns/foreman_m2/images_helper_extensions.rb +24 -0
  8. data/app/lib/proxy_api/m2.rb +35 -0
  9. data/app/models/concerns/foreman_m2/compute_resource_extensions.rb +23 -0
  10. data/app/models/concerns/foreman_m2/host_extensions.rb +110 -0
  11. data/app/models/concerns/foreman_m2/host_orchestration_extensions.rb +52 -0
  12. data/app/models/concerns/foreman_m2/nic_extensions.rb +17 -0
  13. data/app/models/concerns/foreman_m2/nic_orchestration_extensions.rb +75 -0
  14. data/app/models/foreman_m2/m2.rb +20 -0
  15. data/app/overrides/give_ids.rb +14 -0
  16. data/app/overrides/hybrid_js.rb +4 -0
  17. data/app/overrides/update_media_selection.rb +6 -0
  18. data/app/views/compute_resources/edit/_m2.html.erb +0 -0
  19. data/app/views/compute_resources/form/_m2.html.erb +1 -0
  20. data/app/views/compute_resources/show/_m2.html.erb +0 -0
  21. data/app/views/compute_resources_vms/form/m2/_base.html.erb +16 -0
  22. data/app/views/dashboard/_foreman_m2_widget.erb +2 -0
  23. data/app/views/foreman_m2/hosts/hosts/new_action.html.erb +1 -0
  24. data/app/views/foreman_m2/hosts/new_action.html.erb +15 -0
  25. data/app/views/foreman_m2/layouts/layouts/new_layout.html.erb +0 -0
  26. data/app/views/foreman_m2/layouts/new_layout.html.erb +0 -0
  27. data/app/views/hosts/provisioning_method/hybrid/_form.html.erb +6 -0
  28. data/app/views/images/form/_m2.html.erb +6 -0
  29. data/app/views/overrides/host_creation/_add_bm_div.html.erb +12 -0
  30. data/app/views/overrides/host_creation/_add_hybrid_js.html.erb +85 -0
  31. data/app/views/overrides/host_creation/_add_ptable_div.html.erb +4 -0
  32. data/app/views/overrides/image_selection/_host_media_type_select.html.erb +28 -0
  33. data/app/views/unattended/provisioning_templates/PXELinux/m2_default_pxelinux.erb +18 -0
  34. data/app/views/unattended/provisioning_templates/iPXE/m2_default_ipxe.erb +22 -0
  35. data/config/routes.rb +3 -0
  36. data/db/seeds.d/071-m2_prov_templates.rb +59 -0
  37. data/db/seeds.d/111-m2_sp_features.rb +6 -0
  38. data/lib/foreman_m2/engine.rb +80 -0
  39. data/lib/foreman_m2/version.rb +3 -0
  40. data/lib/foreman_m2.rb +5 -0
  41. data/lib/tasks/foreman_m2_tasks.rake +47 -0
  42. data/locale/Makefile +60 -0
  43. data/locale/en/foreman_m2.po +19 -0
  44. data/locale/foreman_m2.pot +19 -0
  45. data/locale/gemspec.rb +2 -0
  46. data/test/factories/foreman_m2_factories.rb +2 -0
  47. data/test/test_plugin_helper.rb +7 -0
  48. data/test/unit/foreman_m2_test.rb +11 -0
  49. metadata +136 -0
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'ForemanM2'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+ task default: :test
37
+
38
+ begin
39
+ require 'rubocop/rake_task'
40
+ RuboCop::RakeTask.new
41
+ rescue StandardError => _
42
+ puts 'Rubocop not loaded.'
43
+ end
44
+
45
+ task :default do
46
+ Rake::Task['rubocop'].execute
47
+ end
@@ -0,0 +1,19 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ module ForemanM2
5
+ # Example: Plugin's HostsController inherits from Foreman's HostsController
6
+ class HostsController < ::HostsController
7
+ # change layout if needed
8
+ # layout 'foreman_m2/layouts/new_layout'
9
+
10
+ def new_action
11
+ # automatically renders view/foreman_m2/hosts/new_action
12
+
13
+ proxy = SmartProxy.find_by name: 'proxy_m2'
14
+ proxyAPI = ::ProxyAPI::M2.new(url: proxy.url)
15
+ @response = proxyAPI.get_images(:project => 'ian')
16
+ @snaps = proxyAPI.get_snapshots(:project => 'ian')
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ module ForemanM2
2
+ module HostsHelperExtensions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # execute callbacks
7
+ end
8
+
9
+ # create or overwrite instance methods...
10
+ def instance_method_name; end
11
+ end
12
+ end
@@ -0,0 +1,24 @@
1
+ module ForemanM2
2
+ module ImagesHelperExtensions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # execute callbacks
7
+ end
8
+
9
+ # create or overwrite instance methods...
10
+ def image_field(f, opts = {})
11
+ return if (@compute_resource.capabilities & %i[image hybrid]).empty?
12
+ images = @compute_resource.available_images
13
+ if images.any?
14
+ images.each { |image| image.name = image.id if image.name.nil? }
15
+ select_f f, :uuid, images.to_a.sort_by { |image| image.name.downcase },
16
+ :id, :name, {}, :label => _('Image')
17
+ else
18
+ text_f f, :uuid, :label => opts[:label] ||
19
+ _('Image ID'), :help_inline => opts[:help_inline] ||
20
+ _('Image ID as provided by the compute resource, e.g. ami-..')
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ module ProxyAPI
2
+ class M2 < ProxyAPI::Resource
3
+ def initialize(args)
4
+ @url = args[:url] + '/m2'
5
+ super args
6
+ end
7
+
8
+ def get_images(_args)
9
+ # img_strings = parse(get("image_list?project=#{args[:project]}"))
10
+ img_strings = parse(get('image_list'))
11
+
12
+ id = 0
13
+ imgs = []
14
+ img_strings.each do |img|
15
+ id += 1
16
+ imgs << Image.new(:id => id, :uuid => id, :name => img)
17
+ end
18
+
19
+ imgs
20
+ end
21
+
22
+ def get_iscsi_target(args)
23
+ get("iscsi_target?disk=#{args[:disk]}&image=#{args[:image]}").body
24
+ end
25
+
26
+ def delete_iscsi_target(args)
27
+ delete("iscsi_target?disk=#{args[:disk]}").body
28
+ end
29
+
30
+ def get_snapshots(_args)
31
+ # snap_strings = parse(get("snapshot_list?project=#{args[:project]}"))
32
+ parse(get('snapshot_list'))
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,23 @@
1
+ module ForemanM2
2
+ module ComputeResourceExtensions
3
+ extend ActiveSupport::Concern
4
+
5
+ attr_accessor :image_id
6
+
7
+ included do
8
+ # execute callbacks
9
+ end
10
+
11
+ # create or overwrite instance methods...
12
+ def instance_method_name; end
13
+
14
+ def new_vm(_attr = {})
15
+ self
16
+ end
17
+
18
+ module ClassMethods
19
+ # create or overwrite class methods...
20
+ def class_method_name; end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,110 @@
1
+ module ForemanM2
2
+ module HostExtensions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # execute callbacks
7
+ # TODO: Destroy disk only if M2
8
+ #before_destroy :destroy_disk #, prepend: true
9
+ validates :root_pass, :length => { :minimum => 8, :message =>
10
+ _('should be 8 characters or more') },
11
+ :presence => { :message =>
12
+ N_('should not be blank - ' \
13
+ 'consider setting a global or ' \
14
+ 'host group default') },
15
+ :if => proc { |host|
16
+ host.managed &&
17
+ (host.pxe_build? ||
18
+ host.hybrid_build?) && build?
19
+ }
20
+ end
21
+
22
+ # create or overwrite instance methods...
23
+ def instance_method_name; end
24
+
25
+ def compute?
26
+ false
27
+ end
28
+
29
+ class ::Host::Managed::Jail < Safemode::Jail
30
+ allow :iscsi_target, :hybrid_build?, :image_name
31
+ end
32
+
33
+ def can_be_built?
34
+ managed? && SETTINGS[:unattended] && (pxe_build? || hybrid_build?) &&
35
+ !build?
36
+ end
37
+
38
+ def inherited_attributes
39
+ inherited_attrs = %w[domain_id]
40
+ if SETTINGS[:unattended]
41
+ inherited_attrs.concat(
42
+ %w[operatingsystem_id architecture_id compute_resource_id]
43
+ )
44
+ inherited_attrs << 'subnet_id' unless compute_provides?(:ip)
45
+ inherited_attrs << 'subnet6_id' unless compute_provides?(:ip6)
46
+ inherited_attrs.concat(%w[medium_id ptable_id pxe_loader]) \
47
+ if pxe_build? || hybrid_build?
48
+ end
49
+ inherited_attrs
50
+ end
51
+
52
+ def hybrid_build?
53
+ provision_method == 'hybrid'
54
+ end
55
+
56
+ def ensure_associations
57
+ status = true
58
+ if SETTINGS[:unattended] && managed? && os &&
59
+ (pxe_build? || hybrid_build?)
60
+ %w[ptable medium architecture].each do |e|
61
+ value = send(e.to_sym)
62
+ next if value.blank?
63
+
64
+ unless os.send(e.pluralize.to_sym).include?(value)
65
+ errors.add("#{e}_id".to_sym,
66
+ format(_('%{value} does not belong to %{os} '\
67
+ 'operating system'),
68
+ :value => value, :os => os))
69
+ status = false
70
+ end
71
+ end
72
+ end
73
+
74
+ if environment
75
+ puppetclasses.select('puppetclasses.id,puppetclasses.name')
76
+ .distinct.each do |e|
77
+ unless environment.puppetclasses.map(&:id).include?(e.id)
78
+ errors.add(:puppetclasses,
79
+ format(_('%{e} does not belong to the '\
80
+ '%{environment} environment'),
81
+ :e => e, :environment => environment))
82
+ status = false
83
+ end
84
+ end
85
+ end
86
+ status
87
+ end
88
+
89
+ def iscsi_target
90
+ logger.info "Creating disk #{name}"
91
+ proxy = SmartProxy.find_by name: 'proxy_m2'
92
+ proxyAPI = ::ProxyAPI::M2.new(url: proxy.url)
93
+ img = Image.find_by name: image_name
94
+ # project = img.uuid
95
+ proxyAPI.get_iscsi_target(:disk => name, :image => image_name)
96
+ end
97
+
98
+ def destroy_disk
99
+ logger.info "Destroying disk #{name}"
100
+ proxy = SmartProxy.find_by name: 'proxy_m2'
101
+ proxyAPI = ::ProxyAPI::M2.new(url: proxy.url)
102
+ proxyAPI.delete_iscsi_target(:disk => name)
103
+ end
104
+
105
+ module ClassMethods
106
+ # create or overwrite class methods...
107
+ def class_method_name; end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,52 @@
1
+ module ForemanM2
2
+ module HostOrchestrationExtensions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # execute callbacks
7
+ end
8
+
9
+ # create or overwrite instance methods...
10
+
11
+ def ssh_provision?
12
+ compute_attributes.present? && (hybrid_build? || image_build?) &&
13
+ !image.try(:user_data)
14
+ end
15
+
16
+ def validate_compute_provisioning
17
+ return true if compute_attributes.nil?
18
+
19
+ if hybrid_build?
20
+ img = find_image
21
+ if img
22
+ self.image = img
23
+ else
24
+ failure(_('Selected image does not belong to %s') % compute_resource)
25
+ return false
26
+ end
27
+ elsif image_build?
28
+ return true if (compute_attributes[:image_id] ||
29
+ compute_attributes[:image_ref]).blank?
30
+
31
+ img = find_image
32
+ if img
33
+ self.image = img
34
+ else
35
+ failure(_('Selected image does not belong to %s') % compute_resource)
36
+ return false
37
+ end
38
+ else
39
+ # don't send the image information to the compute resource
40
+ # unless using the image provisioning method
41
+ %i[image_id image_ref].each do |image_key|
42
+ compute_attributes.delete(image_key)
43
+ end
44
+ end
45
+ end
46
+
47
+ module ClassMethods
48
+ # create or overwrite class methods...
49
+ def class_method_name; end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ module ForemanM2
2
+ module NicExtensions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # execute callbacks
7
+ delegate :hybrid_build?, :to => :host
8
+ end
9
+
10
+ # create or overwrite instance methods...
11
+
12
+ module ClassMethods
13
+ # create or overwrite class methods...
14
+ def class_method_name; end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,75 @@
1
+ module ForemanM2
2
+ module NicOrchestrationExtensions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # execute callbacks
7
+ delegate :hybrid_build?, :to => :host
8
+ end
9
+
10
+ # create or overwrite instance methods...
11
+
12
+ # def hybrid_build?
13
+ # self.provision_method == 'hybrid'
14
+ # end
15
+
16
+ def tftp_ready?
17
+ # host.managed? and managed? should always come first so that
18
+ # orchestration doesn't
19
+ # even get tested for such objects
20
+ (host.nil? || host.managed?) &&
21
+ managed && provision? &&
22
+ (host.operatingsystem && host.pxe_loader.present?) &&
23
+ (pxe_build? || host.hybrid_build?) && SETTINGS[:unattended]
24
+ end
25
+
26
+ def generate_pxe_template(kind)
27
+ # this is the only place we generate a template not via a web request
28
+ # therefore some workaround is required to "render" the template.
29
+
30
+ # If hybrid building, do not generate the template variables
31
+ @kernel = ''
32
+ @initrd = ''
33
+ @mediapath = ''
34
+ @xen = ''
35
+ unless host.hybrid_build?
36
+ @kernel = host.operatingsystem.kernel(host.arch)
37
+ @initrd = host.operatingsystem.initrd(host.arch)
38
+ if host.operatingsystem.respond_to?(:mediumpath)
39
+ @mediapath = host.operatingsystem.mediumpath(host)
40
+ end
41
+ end
42
+
43
+ # Xen requires additional boot files.
44
+ if host.operatingsystem.respond_to?(:xen)
45
+ @xen = host.operatingsystem.xen(host.arch)
46
+ end
47
+
48
+ # work around for ensuring that people can use @host
49
+ # as well, as tftp templates were usually confusing.
50
+ @host = self.host
51
+
52
+ return build_pxe_render(kind) if build?
53
+ default_pxe_render(kind)
54
+ end
55
+
56
+ def queue_tftp_create
57
+ host.operatingsystem.template_kinds.each do |kind|
58
+ queue.create(:name => _('Deploy TFTP %{kind} config for %{host}') %
59
+ { :kind => kind, :host => self }, :priority => 20,
60
+ :action => [self, :setTFTP, kind])
61
+ end
62
+ return unless build
63
+ # Download files if using media
64
+ unless host.hybrid_build?
65
+ queue.create(:name => _('Fetch TFTP boot files for %s') % self,
66
+ :priority => 25, :action => [self, :setTFTPBootFiles])
67
+ end
68
+ end
69
+
70
+ module ClassMethods
71
+ # create or overwrite class methods...
72
+ def class_method_name; end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,20 @@
1
+ module ForemanM2
2
+ class M2 < ComputeResource
3
+ def self.model_name
4
+ ComputeResource.model_name
5
+ end
6
+
7
+ def capabilities
8
+ %i[build image hybrid]
9
+ end
10
+
11
+ def available_images
12
+ proxy = SmartProxy.find_by name: 'proxy_m2'
13
+ proxyAPI = ::ProxyAPI::M2.new(url: proxy.url)
14
+ # proxy = ::ProxyAPI::M2.new(url: url)
15
+ proxyAPI.get_images([])
16
+ end
17
+
18
+ def client; end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ Deface::Override.new(:virtual_path => 'common/os_selection/_operatingsystem',
2
+ :name => 'add_bm_div_p2',
3
+ :remove =>
4
+ 'erb[loud]:contains("select_f"):contains(":ptable_id")')
5
+ Deface::Override.new(:virtual_path => 'common/os_selection/_operatingsystem',
6
+ :name => 'add_bm_div_p1',
7
+ :replace =>
8
+ 'erb[loud]:contains("select_f"):contains(":medium_id")',
9
+ :partial => 'overrides/host_creation/add_bm_div')
10
+ Deface::Override.new(:virtual_path => 'hosts/provision_method/build/_form',
11
+ :name => 'add_bm_div_p1',
12
+ :replace =>
13
+ 'erb[loud]:contains("textarea_f"):contains(":disk")',
14
+ :partial => 'overrides/host_creation/add_ptable_div')
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(:virtual_path => 'hosts/_operating_system',
2
+ :name => 'add_hybrid_js',
3
+ :insert_after => 'div#root_password',
4
+ :partial => 'overrides/host_creation/add_hybrid_js')
@@ -0,0 +1,6 @@
1
+ # Deface::Override.new(:virtual_path => "common/os_selection/_operatingsystem",
2
+ # :name => "add_m2_radio",
3
+ # :insert_before =>
4
+ # 'erb[loud]:contains("select_f"):contains(":medium_id")',
5
+ # :partial =>
6
+ # 'overrides/image_selection/host_media_type_select')
File without changes
@@ -0,0 +1 @@
1
+ <%= text_f f, :url, :label => _("M2 Smart Proxy URL") %>
File without changes
@@ -0,0 +1,16 @@
1
+ <h2>Nothing to see here!</h2>
2
+
3
+ <%
4
+ arch ||= nil ; os ||= nil
5
+ #compute_resource = ComputeResource.find_by name: "mustard"
6
+ images = possible_images(compute_resource, arch, os)
7
+ -%>
8
+
9
+ <div id='image_selection'>
10
+ <%= select_f f, :image_id, images, :uuid, :name,{:include_blank => (images.empty? || images.size == 1) ? false : _('Please select an image')},
11
+ { :disabled => images.empty? || (params[:host] && params[:host][:provision_method] == 'build'),
12
+ :'data-url' => template_selected_compute_resource_path(compute_resource),
13
+ :help_inline => :indicator,
14
+ :help_block => _("Image to use"),
15
+ :label => _('Image'), :label_size => "col-md-2"} %>
16
+ </div>
@@ -0,0 +1,2 @@
1
+ <h4 class="header ca"><%= _('ForemanM2') %></h4>
2
+ <%= _('Widget content') %>
@@ -0,0 +1 @@
1
+ Welcome to <b>ForemanM2</b>
@@ -0,0 +1,15 @@
1
+ Welcome to <b>ForemanM2</b>
2
+
3
+ <p>
4
+ <strong>M2 Images Available:</strong>
5
+ <% @response.each do |t| %>
6
+ <%= t %></li>
7
+ <% end %>
8
+ <br>
9
+
10
+ <strong>M2 Snapshots:</strong>
11
+ <% @snaps.each do |t| %>
12
+ <%= t %></li>
13
+ <% end %>
14
+ <br>
15
+ </p>
File without changes
@@ -0,0 +1,6 @@
1
+ <div id='hybrid_provisioning' <%= display? !@host.hybrid_build? %> >
2
+ <%= render "common/os_selection/image_details", {:item => @host} %>
3
+ <% if host.operatingsystem %>
4
+ <%= render "common/os_selection/pxe_loader", {:item => @host} %>
5
+ <% end %>
6
+ </div>
@@ -0,0 +1,6 @@
1
+ <%= text_f f,
2
+ :username,
3
+ :value => @image.username || "root",
4
+ :help_inline => _("The user that is used to ssh into the instance, normally cloud-user, ec2-user, ubuntu, root etc") %>
5
+ <%= password_f f, :password, :help_inline => _("Password to authenticate with - used for SSH finish step.") %>
6
+ <%= image_field(f) %>
@@ -0,0 +1,12 @@
1
+ <div id='media_selection'>
2
+ <%= select_f f, :medium_id, os_media, :id, :to_label,
3
+ {:include_blank => blank_or_inherit_f(f, :medium), :selected => item.medium_id},
4
+ {:label => _("Media"), :help_inline => :indicator, :onchange => 'medium_selected(this);',
5
+ :'data-url' => method_path('medium_selected'), :'data-type' => controller_name.singularize,
6
+ :required => !item.is_a?(Hostgroup), :placeholder => os_media.empty? ? _("No options available for selected Operating System") : nil }
7
+ %>
8
+ <%= select_f f, :ptable_id, os_ptable, :id, :to_label,
9
+ {:include_blank => blank_or_inherit_f(f, :ptable), :selected => item.ptable_id},
10
+ {:label => _("Partition Table"), :required => true, :placeholder => os_ptable.empty? ? _("No options available for selected Operating System") : nil }
11
+ %>
12
+ </div>
@@ -0,0 +1,85 @@
1
+ <script>
2
+ function os_selected(element){
3
+ var url = $(element).attr('data-url');
4
+ var type = $(element).attr('data-type');
5
+ var attrs = {};
6
+ attrs[type] = attribute_hash(tfm.hosts.getAttributesToPost("os"));
7
+ tfm.tools.showSpinner();
8
+ $.ajax({
9
+ data: attrs,
10
+ type:'post',
11
+ url: url,
12
+ complete: function(){
13
+ reloadOnAjaxComplete(element);
14
+ },
15
+ success: function(request) {
16
+ $('#media_select').html(request);
17
+ reload_host_params();
18
+ reload_puppetclass_params();
19
+ hybrid_hide_build_fields()
20
+ }
21
+ });
22
+ update_provisioning_image();
23
+ }
24
+
25
+ function hybrid_provision_method_selected() {
26
+ $('#image_provisioning').show();
27
+ $('#network_provisioning').show();
28
+ $('div[id*=media_selection]').hide();
29
+ $('div[id*=custom_ptable]').hide();
30
+ $('#network_selection select').attr('disabled', false);
31
+ var image_options = $('#image_selection select');
32
+ image_options.attr('disabled', false);
33
+ $('#image_selection select').show();
34
+ if ($('#provider').val() == 'Libvirt') {
35
+ tfm.computeResource.libvirt.imageSelected(image_options);
36
+ } else if ($('#provider').val() == 'Ovirt') {
37
+ var template_options = $('#host_compute_attributes_template');
38
+ if (template_options.length > 0) {
39
+ template_options.attr('disabled', true);
40
+ template_options.val(image_options.val());
41
+ tfm.computeResource.ovirt.templateSelected(image_options);
42
+ }
43
+ }
44
+ }
45
+ $(document).on('change', '#host_provision_method_hybrid', hybrid_provision_method_selected);
46
+ function hybrid_hide_build_fields() {
47
+ if ($('#host_provision_method_hybrid')[0].checked) {
48
+ $('#network_provisioning').show();
49
+ $('div[id*=media_selection]').hide();
50
+ $('div[id*=custom_ptable]').hide();
51
+ }
52
+ }
53
+ $(document).on('change', '#host_operatingsystem_id', hybrid_hide_build_fields);
54
+
55
+ function build_provision_method_selected() {
56
+ $('div[id*=_provisioning]').hide();
57
+ $('#network_provisioning').show();
58
+ $('div[id*=custom_ptable]').show();
59
+ $('div[id*=media_selection]').show();
60
+ $('#image_selection select').attr('disabled', true);
61
+ if ($('#provider').val() == 'Ovirt')
62
+ $('#host_compute_attributes_template').attr('disabled', false);
63
+ }
64
+ $(document).on('change', '#host_provision_method_build', build_provision_method_selected);
65
+
66
+ function image_provision_method_selected() {
67
+ $('div[id*=_provisioning]').hide();
68
+ $('div[id*=media_selection]').hide();
69
+ $('#image_provisioning').show();
70
+ $('#network_selection select').attr('disabled', true);
71
+ var image_options = $('#image_selection select');
72
+ image_options.attr('disabled', false);
73
+ if ($('#provider').val() == 'Libvirt') {
74
+ tfm.computeResource.libvirt.imageSelected(image_options);
75
+ } else if ($('#provider').val() == 'Ovirt') {
76
+ var template_options = $('#host_compute_attributes_template');
77
+ if (template_options.length > 0) {
78
+ template_options.attr('disabled', true);
79
+ template_options.val(image_options.val());
80
+ tfm.computeResource.ovirt.templateSelected(image_options);
81
+ }
82
+ }
83
+ }
84
+ $(document).on('change', '#host_provision_method_image', image_provision_method_selected);
85
+ </script>
@@ -0,0 +1,4 @@
1
+ <div id='custom_ptable'>
2
+ <%= textarea_f f, :disk, :size => "col-md-8", :rows => "4",
3
+ :help_block => _("What ever text(or ERB template) you use in here, would be used as your OS disk layout options If you want to use the partition table option, delete all of the text from this field") %>
4
+ </div>