foreman_ovm 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/models/concerns/fog_extensions/{ovm → oracle}/image.rb +0 -0
- data/app/models/concerns/fog_extensions/{ovm → oracle}/server.rb +1 -1
- data/app/models/foreman_ovm/ovm.rb +24 -59
- data/app/views/compute_resources/form/_ovm.html.erb +8 -10
- data/app/views/compute_resources/show/_ovm.html.erb +2 -2
- data/app/views/compute_resources_vms/form/ovm/_base.html.erb +1 -3
- data/app/views/compute_resources_vms/index/_ovm.html.erb +9 -4
- data/app/views/compute_resources_vms/show/_ovm.html.erb +5 -5
- data/app/views/images/form/_ovm.html.erb +1 -0
- data/lib/foreman_ovm/engine.rb +8 -8
- data/lib/foreman_ovm/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8cdbae31238b11a968f5995d06bc37042c891de
|
4
|
+
data.tar.gz: 228ae0087106a7ba4ddeffc5ed2d672c4b4d64e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a61f28d032cfdbd4f02db849713a33646f251c2a48cfea7a079fc3f6d449d80a5c32d8fb753bed6204a99851b0cd19408f23d369d3bed3a2b01a96cd21e9c4ba
|
7
|
+
data.tar.gz: 6058f4d4d74d2ac97fcbe9ab643f35b228e499a619507e3462b2ba4c0eed8c05599463011b2da0edc65f01e59574b41435f21c93bdb512c9e75b9fc0f4bfe0eb
|
data/README.md
CHANGED
File without changes
|
@@ -1,12 +1,15 @@
|
|
1
1
|
module ForemanOvm
|
2
2
|
class Ovm < ComputeResource
|
3
|
+
#alias_attribute :api_key, :password
|
3
4
|
#alias_attribute :api_key, :password
|
4
5
|
#alias_attribute :region, :url
|
5
6
|
|
6
|
-
has_one :key_pair, :foreign_key => :compute_resource_id, :dependent => :destroy
|
7
|
-
delegate :flavors, :to => :client
|
8
|
-
|
9
|
-
|
7
|
+
#has_one :key_pair, :foreign_key => :compute_resource_id, :dependent => :destroy
|
8
|
+
#delegate :flavors, :to => :client
|
9
|
+
|
10
|
+
|
11
|
+
validates :url, :format => { :with => URI.regexp }, :presence => true
|
12
|
+
validates :user, :presence => true
|
10
13
|
validates :password, :presence => true
|
11
14
|
before_create :test_connection
|
12
15
|
|
@@ -26,18 +29,18 @@ module ForemanOvm
|
|
26
29
|
end
|
27
30
|
|
28
31
|
def capabilities
|
29
|
-
[:image]
|
32
|
+
[:build, :image]
|
30
33
|
end
|
31
34
|
|
32
35
|
def find_vm_by_uuid(uuid)
|
33
36
|
client.servers.get(uuid)
|
34
|
-
rescue Fog::Compute::
|
37
|
+
rescue Fog::Compute::Oracle::Error
|
35
38
|
raise(ActiveRecord::RecordNotFound)
|
36
39
|
end
|
37
40
|
|
38
41
|
def create_vm(args = {})
|
39
|
-
args["ssh_keys"] = [ssh_key] if ssh_key
|
40
|
-
args['image'] = args['image_id']
|
42
|
+
#args["ssh_keys"] = [ssh_key] if ssh_key
|
43
|
+
#args['image'] = args['image_id']
|
41
44
|
super(args)
|
42
45
|
rescue Fog::Errors::Error => e
|
43
46
|
logger.error "Unhandled Ovm error: #{e.class}:#{e.message}\n " + e.backtrace.join("\n ")
|
@@ -53,14 +56,14 @@ module ForemanOvm
|
|
53
56
|
images
|
54
57
|
end
|
55
58
|
|
56
|
-
def regions
|
57
|
-
|
58
|
-
|
59
|
-
end
|
59
|
+
#def regions
|
60
|
+
# return [] if api_key.blank?
|
61
|
+
# client.regions
|
62
|
+
#end
|
60
63
|
|
61
64
|
def test_connection(options = {})
|
62
65
|
super
|
63
|
-
errors[:password].empty? &&
|
66
|
+
errors[:password].empty? && errors[:user].empty? && errors[:url].empty? && hypervisor
|
64
67
|
rescue Excon::Errors::Unauthorized => e
|
65
68
|
errors[:base] << e.response.body
|
66
69
|
rescue Fog::Errors::Error => e
|
@@ -95,15 +98,19 @@ module ForemanOvm
|
|
95
98
|
rescue Excon::Errors::Unauthorized => e
|
96
99
|
errors[:base] << e.response.body
|
97
100
|
end
|
101
|
+
|
102
|
+
def hypervisor
|
103
|
+
client.hosts.first
|
104
|
+
end
|
98
105
|
|
99
106
|
private
|
100
107
|
|
101
108
|
def client
|
102
109
|
@client ||= Fog::Compute.new(
|
103
|
-
:provider => "
|
104
|
-
|
105
|
-
:
|
106
|
-
:
|
110
|
+
:provider => "Oracle",
|
111
|
+
:oracle_url => url,
|
112
|
+
:oracle_username => user,
|
113
|
+
:oracle_password => password
|
107
114
|
)
|
108
115
|
end
|
109
116
|
|
@@ -113,47 +120,5 @@ module ForemanOvm
|
|
113
120
|
)
|
114
121
|
end
|
115
122
|
|
116
|
-
/*
|
117
|
-
# Creates a new key pair for each new Ovm compute resource
|
118
|
-
# After creating the key, it uploads it to Ovm
|
119
|
-
def setup_key_pair
|
120
|
-
public_key, private_key = generate_key
|
121
|
-
key_name = "foreman-#{id}#{Foreman.uuid}"
|
122
|
-
client.create_ssh_key key_name, public_key
|
123
|
-
KeyPair.create! :name => key_name, :compute_resource_id => id, :secret => private_key
|
124
|
-
rescue => e
|
125
|
-
logger.warn "failed to generate key pair"
|
126
|
-
logger.error e.message
|
127
|
-
logger.error e.backtrace.join("\n")
|
128
|
-
destroy_key_pair
|
129
|
-
raise
|
130
|
-
end
|
131
|
-
|
132
|
-
def destroy_key_pair
|
133
|
-
return unless key_pair
|
134
|
-
logger.info "removing DigitalOcean key #{key_pair.name}"
|
135
|
-
client.destroy_ssh_key(ssh_key.id) if ssh_key
|
136
|
-
key_pair.destroy
|
137
|
-
true
|
138
|
-
rescue => e
|
139
|
-
logger.warn "failed to delete key pair from DigitalOcean, you might need to cleanup manually : #{e}"
|
140
|
-
end
|
141
|
-
|
142
|
-
def ssh_key
|
143
|
-
@ssh_key ||= begin
|
144
|
-
key = client.list_ssh_keys.data[:body]["ssh_keys"].find { |i| i["name"] == key_pair.name }
|
145
|
-
key['id'] if key.present?
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def generate_key
|
150
|
-
key = OpenSSL::PKey::RSA.new 2048
|
151
|
-
type = key.ssh_type
|
152
|
-
data = [key.to_blob].pack('m0')
|
153
|
-
|
154
|
-
openssh_format_public_key = "#{type} #{data}"
|
155
|
-
[openssh_format_public_key, key.to_pem]
|
156
|
-
end
|
157
|
-
*/
|
158
123
|
end
|
159
124
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
+
<%= text_f f, :url, :size => "col-md-8", :help_block => _("e.g. https://ovmm.example.com:7002") %>
|
2
|
+
<%= text_f f, :user %>
|
1
3
|
<%= password_f f, :password, :label => _("Password"), :unset => unset_password? %>
|
2
|
-
<% regions = f.object.regions rescue [] %>
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
:'data-url' => test_connection_compute_resources_path) +
|
11
|
-
hidden_spinner('', :id => 'test_connection_indicator').html_safe) %>
|
12
|
-
</div>
|
5
|
+
<% authenticated = f.object.authenticate! rescue false %>
|
6
|
+
<%= link_to_function _("Test Connection"), "testConnection(this)",
|
7
|
+
:class => "btn + #{authenticated ? "btn-success" : "btn-default"}",
|
8
|
+
:'data-url' => test_connection_compute_resources_path %>
|
9
|
+
|
10
|
+
<%= spinner('', :id => 'test_connection_indicator', :class => 'hide') %>
|
@@ -1,7 +1,5 @@
|
|
1
|
+
<%= text_f f, :name if show_vm_name? %>
|
1
2
|
<%= select_f f, :size, compute_resource.flavors, :slug, :slug, {}, {:label => _('Flavor')} %>
|
2
3
|
<div id='image_selection'>
|
3
4
|
<%= select_image(f, compute_resource) %>
|
4
5
|
</div>
|
5
|
-
<div id='region_selection'>
|
6
|
-
<%= select_region(f, compute_resource) %>
|
7
|
-
</div>
|
@@ -4,8 +4,11 @@
|
|
4
4
|
<th><%= _('Name') %></th>
|
5
5
|
<th><%= _('Image') %></th>
|
6
6
|
<th><%= _('Type') %></th>
|
7
|
-
<th><%= _('
|
8
|
-
<th><%= _('
|
7
|
+
<th><%= _('CPUs') %></th>
|
8
|
+
<th><%= _('Memory') %></th>
|
9
|
+
<th><%= _('Status') %></th>
|
10
|
+
<th><%= _('Power') %></th>
|
11
|
+
<th><%= _('Actions') %></th>
|
9
12
|
<th></th>
|
10
13
|
</tr>
|
11
14
|
</thead>
|
@@ -14,8 +17,10 @@
|
|
14
17
|
<td><%= link_to_if_authorized vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.identity).merge(:auth_object => @compute_resource, :authorizer => authorizer) %></td>
|
15
18
|
<td><%= vm.image['slug'] if vm.image.present? %></td>
|
16
19
|
<td><%= vm.size['slug'] %></td>
|
17
|
-
<td><%= vm.
|
18
|
-
<td>
|
20
|
+
<td><%= vm.cores %></td>
|
21
|
+
<td> <%= number_to_human_size vm.memory %> </td>
|
22
|
+
<td> <%= vm.attributes['status'] %> </td>
|
23
|
+
<td> <span <%= vm_power_class(vm.ready?) %>> <%= vm_state(vm) %></span> </td>
|
19
24
|
<td>
|
20
25
|
<%= action_buttons(
|
21
26
|
vm_power_action(vm, authorizer),
|
@@ -2,12 +2,12 @@
|
|
2
2
|
<div class='col-md-12'>
|
3
3
|
<table class="table table-bordered table-striped">
|
4
4
|
<tr><th colspan="2">Properties</th></tr>
|
5
|
-
<%= prop :
|
6
|
-
<%= prop :
|
7
|
-
<%= prop :
|
5
|
+
<%= prop :name %>
|
6
|
+
<%= prop :ip_address %>
|
7
|
+
<%= prop :cores %>
|
8
|
+
<%= prop :memory %>
|
9
|
+
<%= prop :identity %>
|
8
10
|
<%= prop :created_at, 'Created' %>
|
9
11
|
<%= prop :image_name, 'Image' if @vm.image.present? %>
|
10
|
-
<%= prop :flavor_name, "Type (flavor)" %>
|
11
|
-
<%= prop :region_name, "Region" %>
|
12
12
|
</table>
|
13
13
|
</div>
|
@@ -2,5 +2,6 @@
|
|
2
2
|
:username,
|
3
3
|
:value => @image.username || "root",
|
4
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.") %>
|
5
6
|
<%= ovm_image_field(f) %>
|
6
7
|
<%= checkbox_f f, :user_data, :help_inline => _("Does this image support user data input (e.g. via cloud-init)?") %>
|
data/lib/foreman_ovm/engine.rb
CHANGED
@@ -18,7 +18,7 @@ module ForemanOvm
|
|
18
18
|
Foreman::Plugin.register :foreman_ovm do
|
19
19
|
requires_foreman '>= 1.13'
|
20
20
|
compute_resource ForemanOvm::Ovm
|
21
|
-
parameter_filter ComputeResource, :username, :password, :
|
21
|
+
parameter_filter ComputeResource, :username, :password, :url
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -27,21 +27,21 @@ module ForemanOvm
|
|
27
27
|
end
|
28
28
|
|
29
29
|
config.to_prepare do
|
30
|
-
require '
|
30
|
+
require 'fog/oracle'
|
31
31
|
#require 'fog/digitalocean/compute_v2'
|
32
32
|
#require 'fog/digitalocean/models/compute_v2/image'
|
33
33
|
#require 'fog/digitalocean/models/compute_v2/server'
|
34
34
|
require File.expand_path(
|
35
|
-
'../../../app/models/concerns/fog_extensions/
|
35
|
+
'../../../app/models/concerns/fog_extensions/oracle/server',
|
36
36
|
__FILE__)
|
37
37
|
require File.expand_path(
|
38
|
-
'../../../app/models/concerns/fog_extensions/
|
38
|
+
'../../../app/models/concerns/fog_extensions/oracle/image',
|
39
39
|
__FILE__)
|
40
40
|
|
41
|
-
Fog::Compute::
|
42
|
-
|
43
|
-
Fog::Compute::
|
44
|
-
FogExtensions::
|
41
|
+
#Fog::Compute::Oracle::Image.send :include,
|
42
|
+
# FogExtensions::Oracle::Image
|
43
|
+
Fog::Compute::Oracle.send :include,
|
44
|
+
FogExtensions::Oracle
|
45
45
|
::Host::Managed.send :include,
|
46
46
|
ForemanOvm::Concerns::HostManagedExtensions
|
47
47
|
end
|
data/lib/foreman_ovm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_ovm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Wilmott
|
@@ -34,8 +34,8 @@ files:
|
|
34
34
|
- LICENSE
|
35
35
|
- README.md
|
36
36
|
- app/helpers/ovm_images_helper.rb
|
37
|
-
- app/models/concerns/fog_extensions/
|
38
|
-
- app/models/concerns/fog_extensions/
|
37
|
+
- app/models/concerns/fog_extensions/oracle/image.rb
|
38
|
+
- app/models/concerns/fog_extensions/oracle/server.rb
|
39
39
|
- app/models/foreman_ovm/concerns/host_managed_extensions.rb
|
40
40
|
- app/models/foreman_ovm/ovm.rb
|
41
41
|
- app/views/api/v1/compute_resources/ovm.json
|