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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 973693d8259f7c0fff9eca33599dd4485e00e042
4
- data.tar.gz: 5001dafbd11c69e806072baee1fafcdbe5c598b5
3
+ metadata.gz: c8cdbae31238b11a968f5995d06bc37042c891de
4
+ data.tar.gz: 228ae0087106a7ba4ddeffc5ed2d672c4b4d64e4
5
5
  SHA512:
6
- metadata.gz: f7908eda7094e040de1d1e0fcdbdcb3c2b89f86c2b325c2a228bb6647a8c63113ab118fe5d04109e759e1367f221de6f1271499ccd58b0981c0f55d9c6ef89c5
7
- data.tar.gz: c0b3665f6af39fc386d4b46e67e70754df6cd836eb80da0cb6eac2661cc54742f12f8688371637a4fae7ef2c07ded94081ce280b9d428336f49caf89bf5c2283
6
+ metadata.gz: a61f28d032cfdbd4f02db849713a33646f251c2a48cfea7a079fc3f6d449d80a5c32d8fb753bed6204a99851b0cd19408f23d369d3bed3a2b01a96cd21e9c4ba
7
+ data.tar.gz: 6058f4d4d74d2ac97fcbe9ab643f35b228e499a619507e3462b2ba4c0eed8c05599463011b2da0edc65f01e59574b41435f21c93bdb512c9e75b9fc0f4bfe0eb
data/README.md CHANGED
@@ -55,7 +55,7 @@ To verify that the installation was successful, go to Foreman, top bar **Adminis
55
55
 
56
56
  | Foreman Version | Plugin Version |
57
57
  | --------------- | --------------:|
58
- | >= 1.13.0 | ~> 0.0.1 |
58
+ | >= 1.13.0 | ~> 0.0.2 |
59
59
 
60
60
  ## Configuration
61
61
 
@@ -1,5 +1,5 @@
1
1
  module FogExtensions
2
- module Ovm
2
+ module Oracle
3
3
  module Server
4
4
  extend ActiveSupport::Concern
5
5
 
@@ -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
- validates :username, :presence => true
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::Ovm::Error
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
- return [] if api_key.blank?
58
- client.regions
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? && regions.count
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 => "Ovm",
104
- :version => 'V1',
105
- :username => username,
106
- :password => password
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
- <div id='region_selection'>
5
- <%= selectable_f(f, :region, regions.map(&:slug), {},
6
- :label => _('Default Region'), :disabled => regions.empty?,
7
- :help_inline => link_to_function(
8
- regions.empty? ? _("Load Regions") : _("Test Connection"), "testConnection(this)",
9
- :class => "btn + #{regions.empty? ? "btn-default" : "btn-success"}",
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,4 +1,4 @@
1
1
  <tr>
2
- <td><%= _("Default Region") %></td>
3
- <td><%= @compute_resource.default_region_name %></td>
2
+ <td><%= _("URL") %></td>
3
+ <td><%= @compute_resource.default_rrsource.url %></td>
4
4
  </tr>
@@ -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><%= _('Region') %></th>
8
- <th><%= _('State') %></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.region['slug'] %></td>
18
- <td> <span <%= vm_power_class(vm.ready?) %>> <%= vm_state(vm) %></span> </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 :public_ip_address %>
6
- <%= prop :private_ip_address %>
7
- <%= prop :state %>
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)?") %>
@@ -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, :uri
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 'xlab-si/fog-oracle'
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/ovm/server',
35
+ '../../../app/models/concerns/fog_extensions/oracle/server',
36
36
  __FILE__)
37
37
  require File.expand_path(
38
- '../../../app/models/concerns/fog_extensions/ovm/image',
38
+ '../../../app/models/concerns/fog_extensions/oracle/image',
39
39
  __FILE__)
40
40
 
41
- Fog::Compute::Ovm::Image.send :include,
42
- FogExtensions::Ovm::Image
43
- Fog::Compute::Ovm::Server.send :include,
44
- FogExtensions::Ovm::Server
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
@@ -1,3 +1,3 @@
1
1
  module ForemanOvm
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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.1
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/ovm/image.rb
38
- - app/models/concerns/fog_extensions/ovm/server.rb
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