foreman_one 0.2 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +6 -3
- data/app/models/concerns/fog_extensions/opennebula/server.rb +29 -0
- data/app/models/foreman_one/one.rb +15 -25
- data/app/views/compute_resources_vms/form/_one.html.erb +2 -18
- data/app/views/compute_resources_vms/form/one/_base.html.erb +5 -0
- data/lib/foreman_one/engine.rb +15 -2
- data/lib/foreman_one/version.rb +1 -1
- metadata +11 -25
- data/app/views/compute_resources_vms/form/one/_volume.html.erb +0 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MjMyOGUzZWE2YTI1MDdhMDIwOTIwZmQwNmM1MWZjYWRkMjZmMGUwOA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df5b26c25658b73795a6879ca77d068b7a8a8086
|
4
|
+
data.tar.gz: 092656a76deeb1b126120ca5428c8ad6913acf87
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZWZjYWFiMDRlN2Q5MWFlZDA3ZDc1NWFiZTc0OWFmNzQ3ZDExNTdlNGY1NjE5
|
11
|
-
NzgxZTQyMTY5YjIzMWU2ZmE4NjFjNjk3ZmZkYzE4Y2FiMDA5MWI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MDQ2ZjllMWU0MDMxOWNlNmZlYWQ4ZjlmZWVjY2RiZWQwOTExYzFkNTMxMDBk
|
14
|
-
OWQ5MWM1YzJjMTk4Mzc1YmE1MTg3YWJkYzliYjU2NDQ2MjY4NmY4YmQ2ZDQ5
|
15
|
-
YWQwZGEzOGU2MTI2NjlkZTA3MzhhZDc4YWNkOWZhZjYxODdlNGU=
|
6
|
+
metadata.gz: cbeb50ae5d2575a571c8f6c106ae08951753ad924f496fea84c7e91532960e2f31634f84f7375239fbbc066672f133040e7cec3852dbf96715b8f2a210498368
|
7
|
+
data.tar.gz: 2973dd8006cd5b28012921f8760177f7b514c87365be61064c0c73f7b31ceed95c55f8c5c0d9830c081401e60c1552fb44c859c9cab81159db49d1def2a929c1
|
data/README.md
CHANGED
@@ -15,12 +15,15 @@ The gem name is "foreman_one".
|
|
15
15
|
| Foreman Version | Plugin Version |
|
16
16
|
| ---------------:| --------------:|
|
17
17
|
| >= 1.5 | 0.1 |
|
18
|
+
| >= 1.8 | 0.3 |
|
18
19
|
|
19
|
-
## Latest code
|
20
|
+
## Latest code (recommended)
|
20
21
|
|
21
|
-
|
22
|
+
To use foreman-one with newer Versions of TheForeman >=1.8 you should add the
|
23
|
+
following lines to your Gemfile.
|
22
24
|
|
23
|
-
gem 'foreman_one', :git => "https://github.com/
|
25
|
+
gem 'foreman_one', :git => "https://github.com/theforeman/foreman-one.git"
|
26
|
+
gem "fog", :git => "https://github.com/netways/fog.git", :branch => "net-v1.33.0"
|
24
27
|
|
25
28
|
# Copyright
|
26
29
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module FogExtensions
|
2
|
+
module OpenNebula
|
3
|
+
module Server
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
include ActionView::Helpers::NumberHelper
|
7
|
+
|
8
|
+
def vminterfaces
|
9
|
+
interfaces
|
10
|
+
end
|
11
|
+
|
12
|
+
def select_nic(fog_nics, nic)
|
13
|
+
fog_nics.detect {|fn| fn.vnet == nic.compute_attributes['vnetid']} # grab any nic on the same network
|
14
|
+
end
|
15
|
+
|
16
|
+
def vminterfaces_attributes=(attributes)
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def template_id
|
21
|
+
""
|
22
|
+
end
|
23
|
+
|
24
|
+
def vm_description
|
25
|
+
_("%{cpus} CPUs and %{memory} memory") % {:cpus => cpu, :memory => number_to_human_size(memory.to_i)}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -5,12 +5,12 @@ module ForemanOne
|
|
5
5
|
validates :user, :password, :presence => true
|
6
6
|
validates :url, :format => { :with => URI.regexp }
|
7
7
|
|
8
|
-
def provider_friendly_name
|
8
|
+
def self.provider_friendly_name
|
9
9
|
"OpenNebula"
|
10
10
|
end
|
11
11
|
|
12
12
|
def provided_attributes
|
13
|
-
super.merge({ :mac => :
|
13
|
+
super.merge({ :mac => :mac })
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.model_name
|
@@ -30,18 +30,17 @@ module ForemanOne
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def interfaces
|
33
|
-
|
34
|
-
[]
|
33
|
+
vm.interfaces
|
35
34
|
end
|
35
|
+
|
36
36
|
def vminterfaces
|
37
|
-
|
38
|
-
[]
|
37
|
+
interfaces
|
39
38
|
end
|
40
39
|
|
41
40
|
def networks
|
42
41
|
client.networks rescue []
|
43
42
|
end
|
44
|
-
|
43
|
+
|
45
44
|
|
46
45
|
def flavors
|
47
46
|
client.flavors
|
@@ -66,8 +65,8 @@ module ForemanOne
|
|
66
65
|
vm.flavor.nic = [] unless vm.flavor.nic.is_a? Array
|
67
66
|
|
68
67
|
#INTERFACES {"new_interfaces"=>{"vnetid"=>"0", "_delete"=>"", "model"=>"virtio"}, "new_1398239695352"=>{"vnetid"=>"2", "_delete"=>"", "model"=>"virtio"}, "new_1398239700415"=>{"vnetid"=>"2", "_delete"=>"", "model"=>"virtio"}, "new_1398239705632"=>{"vnetid"=>"0", "_delete"=>"", "model"=>"e1000"}}
|
69
|
-
logger.
|
70
|
-
nics = args[:
|
68
|
+
logger.debug "NEW #{args[:interfaces_attributes].inspect}"
|
69
|
+
nics = args[:interfaces_attributes].values
|
71
70
|
if nics.is_a? Array then
|
72
71
|
nics.each do |nic|
|
73
72
|
unless (nic["vnetid"].empty? || nic["model"].empty?)
|
@@ -76,10 +75,11 @@ module ForemanOne
|
|
76
75
|
end
|
77
76
|
end
|
78
77
|
|
79
|
-
logger.
|
80
|
-
logger.
|
81
|
-
logger.
|
82
|
-
logger.
|
78
|
+
logger.debug "VM: #{vm.inspect}"
|
79
|
+
logger.debug "FLAVOR: #{vm.flavor.inspect}"
|
80
|
+
logger.debug "NIC: #{vm.flavor.nic.inspect}"
|
81
|
+
logger.debug "FLAVORto_s: #{vm.flavor.to_s}"
|
82
|
+
|
83
83
|
vm.save
|
84
84
|
rescue ::OpenNebula::Error => e
|
85
85
|
logger.debug "OpenNebula error: #{e.message}\n " + e.backtrace.join("\n ")
|
@@ -115,13 +115,8 @@ module ForemanOne
|
|
115
115
|
false
|
116
116
|
end
|
117
117
|
|
118
|
-
# def associated_host(vm)
|
119
|
-
# Host.my_hosts.where(:ip => [vm.public_ip_address, vm.private_ip_address]).first
|
120
|
-
# end
|
121
|
-
|
122
118
|
def associated_host(vm)
|
123
|
-
|
124
|
-
Host.authorized(:view_hosts, Host).where(:mac => vm.vm_mac_address).first
|
119
|
+
associate_by("mac", vm.vm_mac_address)
|
125
120
|
end
|
126
121
|
|
127
122
|
def new_vminterface attr={}
|
@@ -135,13 +130,8 @@ module ForemanOne
|
|
135
130
|
@client ||= ::Fog::Compute.new({:provider => 'OpenNebula', :opennebula_username => user, :opennebula_password => password, :opennebula_endpoint => url})
|
136
131
|
end
|
137
132
|
|
138
|
-
|
139
133
|
def vm_instance_defaults
|
140
|
-
super
|
141
|
-
:b0e => "foob0e",
|
142
|
-
:foob0e => "b0e"
|
143
|
-
)
|
134
|
+
super
|
144
135
|
end
|
145
|
-
|
146
136
|
end
|
147
137
|
end
|
@@ -1,20 +1,4 @@
|
|
1
1
|
<%= select_f f, :template_id, compute_resource.flavors, :id, :to_label, {}, :label => _('Templates') %>
|
2
|
-
<%= selectable_f f, :vcpu, 1..
|
3
|
-
<%= selectable_f f, :memory,[512, 1024, 2048, 4096] , { :include_blank => _("Template default")}, :class => "col-md-2", :label => _('Memory') %>
|
2
|
+
<%= selectable_f f, :vcpu, 1..32, { :include_blank => _("Template default")}, :label => _('VCPUs') %>
|
3
|
+
<%= selectable_f f, :memory,[512, 1024, 2048, 4096, 8192, 16384, 32768, 65536] , { :include_blank => _("Template default")}, :class => "col-md-2", :label => _('Memory') %>
|
4
4
|
<%= select_f f, :gid, compute_resource.groups, :id, :to_label, { :include_blank => _("User default")}, :label => _('One Group') %>
|
5
|
-
|
6
|
-
<!--NICS -->
|
7
|
-
<div class="children_fields">
|
8
|
-
<%= new_child_fields_template(f, :vminterfaces, {
|
9
|
-
:object => compute_resource.new_vminterface,
|
10
|
-
:partial => 'compute_resources_vms/form/one/network', :form_builder_attrs => { :compute_resource => compute_resource } }) %>
|
11
|
-
<%= field_set_tag "Virtual Network", :id => "network_vminterfaces", :title => _('Networks') do %>
|
12
|
-
<%= f.fields_for :vminterfaces do |i| %>
|
13
|
-
<%= render 'compute_resources_vms/form/one/network', :f => i, :compute_resource => compute_resource %>
|
14
|
-
<% end %>
|
15
|
-
<%= add_child_link '+ ' + _("Add Interface"), :vminterfaces, { :class => "info disable-unsupported", :title => _('add new network interface') } %>
|
16
|
-
<% end %>
|
17
|
-
</div>
|
18
|
-
|
19
|
-
|
20
|
-
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<%= select_f f, :template_id, compute_resource.flavors, :id, :to_label, {}, :label => _('Templates') %>
|
2
|
+
<%= selectable_f f, :vcpu, 1..8, { :include_blank => _("Template default")}, :label => _('VCPUs') %>
|
3
|
+
<%= selectable_f f, :memory,[512, 1024, 2048, 4096] , { :include_blank => _("Template default")}, :class => "col-md-2", :label => _('Memory') %>
|
4
|
+
<%= select_f f, :gid, compute_resource.groups, :id, :to_label, { :include_blank => _("User default")}, :label => _('One Group') %>
|
5
|
+
|
data/lib/foreman_one/engine.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'fast_gettext'
|
2
2
|
require 'gettext_i18n_rails'
|
3
|
-
require 'fog'
|
3
|
+
require 'fog/opennebula'
|
4
4
|
|
5
5
|
module ForemanOne
|
6
6
|
#Inherit from the Rails module of the parent app (Foreman), not the plugin.
|
@@ -16,11 +16,24 @@ module ForemanOne
|
|
16
16
|
|
17
17
|
initializer 'foreman_one.register_plugin', :after=> :finisher_hook do |app|
|
18
18
|
Foreman::Plugin.register :foreman_one do
|
19
|
-
requires_foreman '
|
19
|
+
requires_foreman '>= 1.8'
|
20
20
|
# Register OpenNebula compute resource in foreman
|
21
21
|
compute_resource ForemanOne::One
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
config.to_prepare do
|
26
|
+
begin
|
27
|
+
# extend fog opennebula server/
|
28
|
+
require 'fog/opennebula/models/compute/server'
|
29
|
+
require File.expand_path('../../../app/models/concerns/fog_extensions/opennebula/server', __FILE__)
|
30
|
+
|
31
|
+
Fog::Compute::OpenNebula::Server.send(:include, ::FogExtensions::OpenNebula::Server)
|
32
|
+
::HostsHelper.send(:include, ForemanOne::HostHelperExtensions)
|
33
|
+
rescue => e
|
34
|
+
puts "Foreman-One: skipping engine hook (#{e.to_s})"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
25
38
|
end
|
26
39
|
end
|
data/lib/foreman_one/version.rb
CHANGED
metadata
CHANGED
@@ -1,55 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_one
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NETWAYS Managed Services GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: fog
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ! '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.23.0
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ! '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.23.0
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: opennebula
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- -
|
31
|
+
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
33
|
version: 4.4.0
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- -
|
38
|
+
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: 4.4.0
|
55
41
|
description: Provision and manage OpenNebula VMs from Foreman
|
@@ -62,12 +48,13 @@ files:
|
|
62
48
|
- LICENSE
|
63
49
|
- README.md
|
64
50
|
- Rakefile
|
51
|
+
- app/models/concerns/fog_extensions/opennebula/server.rb
|
65
52
|
- app/models/foreman_one/one.rb
|
66
53
|
- app/views/compute_resources/form/_one.html.erb
|
67
54
|
- app/views/compute_resources/show/_one.html.erb
|
68
55
|
- app/views/compute_resources_vms/form/_one.html.erb
|
56
|
+
- app/views/compute_resources_vms/form/one/_base.html.erb
|
69
57
|
- app/views/compute_resources_vms/form/one/_network.html.erb
|
70
|
-
- app/views/compute_resources_vms/form/one/_volume.html.erb
|
71
58
|
- app/views/compute_resources_vms/index/_one.html.erb
|
72
59
|
- app/views/compute_resources_vms/show/_one.html.erb
|
73
60
|
- lib/foreman_one.rb
|
@@ -87,21 +74,20 @@ require_paths:
|
|
87
74
|
- lib
|
88
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
89
76
|
requirements:
|
90
|
-
- -
|
77
|
+
- - ">="
|
91
78
|
- !ruby/object:Gem::Version
|
92
79
|
version: '0'
|
93
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
81
|
requirements:
|
95
|
-
- -
|
82
|
+
- - ">="
|
96
83
|
- !ruby/object:Gem::Version
|
97
84
|
version: '0'
|
98
85
|
requirements: []
|
99
86
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.4.5.1
|
101
88
|
signing_key:
|
102
89
|
specification_version: 4
|
103
90
|
summary: Provision and manage OpenNebula VMs from Foreman
|
104
91
|
test_files:
|
105
92
|
- test/test_helper.rb
|
106
93
|
- test/foreman_one_test.rb
|
107
|
-
has_rdoc:
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<div class="fields">
|
2
|
-
<div class="form-group">
|
3
|
-
<%= selectable_f f, :pool_name, compute_resource.storage_pools.map(&:name), { }, :class => "col-md-2", :label => _("Storage pool") %>
|
4
|
-
<%= text_f f, :capacity, :class => "col-md-2", :label => _("Size (GB)"), :onchange => 'capacity_edit(this)' %>
|
5
|
-
<%= allocation_text_f f %>
|
6
|
-
<%= select_f f, :format_type, %w[RAW QCOW2],:downcase, :to_s, { }, :class => "col-md-2", :label => _("Type"),
|
7
|
-
:help_inline => remove_child_link("X", f, { :method => :'_delete', :title => _('remove volume'), :class => 'label label-danger disable-unsupported' }) %>
|
8
|
-
</div>
|
9
|
-
</div>
|