foreman_opennebula 3.0.0 → 3.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
  SHA256:
3
- metadata.gz: dda5882a295555eb9c4e145959787fee3af1c522681ac2ca1d7d85ae35ac4d14
4
- data.tar.gz: 7f9a76c97effc394aed06300c501ddeaf09d7a706fab6f2e28d4a228cc9147b2
3
+ metadata.gz: 0d7b045930e7933b1f22554eef853d485eab53ed36958dab6567f59fe752b953
4
+ data.tar.gz: b1d1f20dc6a50809a452563c9fff2fa2a275d8496d69d0fe735ae68f3834d610
5
5
  SHA512:
6
- metadata.gz: 1f2011131086920a71f02a797d545e9d097cb3c05a042106015dd2bdc25b9bc5d4eb7a0300095bfbacf4cea459608e3126eec1dfdf21cc28d7dc908cc78ff582
7
- data.tar.gz: 7916313a9f48a3c22753030a29e0a0eeb9047a8d124dd3d211a0ed2285cd2b5e01e49c5254bb2cf547883687e0df313eb310f31e69bba22f1b125c803df76189
6
+ metadata.gz: 8aed536860c30ae369157c7ef9c89160cbeaf120af70884261cd44657628f2efb1f91be05a77a8ba240f8ada2fdaa182cc2ec36fde71030722965c5ddcf8cd4c
7
+ data.tar.gz: 05b7ae4aea5ec6d676199d36188e2d3b090aed6208fc955bfee16941c0ec84373c2c91af9865ddf671931e2705c02456101b209f5cadf3c85e19735b0403585a
@@ -4,8 +4,8 @@ module FogExtensions
4
4
  extend ActiveSupport::Concern
5
5
  include ActionView::Helpers::NumberHelper
6
6
 
7
- attr_writer :template_id, :image_id, :disk_size, :vmgroup_id,
8
- :vmgroup_role, :scheduler_hint_filter, :scheduler_hint_data
7
+ attr_writer :template_id, :image_id, :disk_size, :vmgroup_id, :vmgroup_role,
8
+ :user_template_attributes, :scheduler_hint_filter, :scheduler_hint_data
9
9
 
10
10
  included do
11
11
  def cpu
@@ -47,8 +47,19 @@ module FogExtensions
47
47
  onevm_object.present? ? onevm_object['TEMPLATE/VMGROUP/ROLE'] : @vmgroup_role
48
48
  end
49
49
 
50
+ def user_template
51
+ return if onevm_object.nil?
52
+ standard_attributes = %w[SCHED_DS_REQUIREMENTS SCHED_RANK SCHED_REQUIREMENTS]
53
+ user_attributes = onevm_object.to_hash['VM']['USER_TEMPLATE'].filter do |name, _|
54
+ !standard_attributes.include?(name)
55
+ end
56
+ user_attributes.map do |name, value|
57
+ OpenStruct.new({:name => name, :value => value})
58
+ end
59
+ end
60
+
50
61
  def sched_requirements
51
- return unless onevm_object
62
+ return if onevm_object.nil?
52
63
  onevm_object['USER_TEMPLATE/SCHED_REQUIREMENTS']
53
64
  end
54
65
 
@@ -116,6 +116,15 @@ module ForemanOpennebula
116
116
  vm_attrs[:flavor].vmgroup = { 'VMGROUP_ID' => args[:vmgroup_id], 'ROLE' => args[:vmgroup_role] }
117
117
  end
118
118
 
119
+ if args[:user_template_attributes].present?
120
+ user_template_attributes = args[:user_template_attributes].values.filter do |attribute|
121
+ attribute[:name].present? && attribute[:_delete].empty?
122
+ end
123
+ vm_attrs[:flavor].user_variables = user_template_attributes.reduce({}) do |user_variables, attribute|
124
+ user_variables.merge({attribute[:name] => attribute[:value]})
125
+ end
126
+ end
127
+
119
128
  if args['provision_method'] == 'image' && args['image_id'].present?
120
129
  [vm_attrs[:flavor].disk].flatten.compact.first.delete('IMAGE')
121
130
  [vm_attrs[:flavor].disk].flatten.compact.first['IMAGE_ID'] = args[:image_id]
@@ -83,3 +83,23 @@
83
83
  <%= javascript_include_tag 'foreman_opennebula/vmgroup_selected' %>
84
84
  <%= javascript_include_tag 'foreman_opennebula/scheduler_hint_filter_selected' %>
85
85
  <% end %>
86
+
87
+ <div class="row">
88
+ <%= label_tag(:user_template, _("Custom attributes"), :class => 'col-md-2 control-label') %>
89
+ <div class="col-md-4">
90
+ <table id="opennebula_custom_attributes" class="<%= table_css_classes %>">
91
+ <tbody>
92
+ <%= f.fields_for :user_template, f.object.user_template do |fields| %>
93
+ <%= render "compute_resources_vms/form/opennebula/custom_attribute", f: fields, new_vm: new_vm %>
94
+ <% end %>
95
+ </tbody>
96
+ </table>
97
+ <% if new_vm %>
98
+ <%= link_to_add_fields(_("Add attribute"), f, :user_template, "compute_resources_vms/form/opennebula/custom_attribute", {
99
+ :target => '#opennebula_custom_attributes tbody',
100
+ :class => 'w-100',
101
+ :object => [OpenStruct.new({:name => '', :value => ''})],
102
+ :locals => { new_vm: new_vm } }) %>
103
+ <% end %>
104
+ </div>
105
+ </div>
@@ -0,0 +1,13 @@
1
+ <tr class="fields">
2
+ <td>
3
+ <%= f.text_field(:name, class: "form-control", disabled: !new_vm, placeholder: _("Name")) %>
4
+ </td>
5
+ <td>
6
+ <%= f.text_field(:value, class: "form-control", disabled: !new_vm, placeholder: _("Value")) %>
7
+ </td>
8
+ <% if new_vm %>
9
+ <td>
10
+ <%= link_to_remove_fields('', f, title: _('Remove')) %>
11
+ </td>
12
+ <% end %>
13
+ </tr>
@@ -1,3 +1,3 @@
1
1
  module ForemanOpennebula
2
- VERSION = '3.0.0'.freeze
2
+ VERSION = '3.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_opennebula
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitaly Pyslar
@@ -149,6 +149,7 @@ files:
149
149
  - app/views/compute_resources/form/_opennebula.html.erb
150
150
  - app/views/compute_resources/show/_opennebula.html.erb
151
151
  - app/views/compute_resources_vms/form/opennebula/_base.html.erb
152
+ - app/views/compute_resources_vms/form/opennebula/_custom_attribute.html.erb
152
153
  - app/views/compute_resources_vms/form/opennebula/_network.html.erb
153
154
  - app/views/compute_resources_vms/form/opennebula/_scheduler_hint_data.html.erb
154
155
  - app/views/compute_resources_vms/form/opennebula/_vmgroup_role.html.erb