Skip to content

Commit

Permalink
Fixes #69 and #67: proxmox 5.4 and foreman 1.22 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanrobert committed Apr 18, 2019
1 parent 6f859c6 commit 1f3b12f
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 98 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ RUN mkdir /usr/local/foreman_fog_proxmox
WORKDIR /usr/local/foreman_fog_proxmox
ADD . /usr/local/foreman_fog_proxmox
WORKDIR /usr/local
RUN git clone https://github.com/theforeman/foreman.git -b 1.21-stable
RUN git clone https://github.com/fog/fog-proxmox.git -b 0_7_0
WORKDIR /usr/local
RUN git clone https://github.com/theforeman/foreman.git -b develop
WORKDIR /usr/local/foreman
RUN echo "gem 'foreman_fog_proxmox', :path => '/usr/local/foreman_fog_proxmox'\n" > /usr/local/foreman/bundler.d/Gemfile.local.rb
RUN echo "gem 'fog-proxmox', :path => '/usr/local/fog-proxmox'\n" > /usr/local/foreman/bundler.d/Gemfile.local.rb
RUN echo "gem 'simplecov'" >> /usr/local/foreman/bundler.d/Gemfile.local.rb
RUN cp /usr/local/foreman/config/settings.yaml.example /usr/local/foreman/config/settings.yaml
RUN cp /usr/local/foreman/config/database.yml.example /usr/local/foreman/config/database.yml
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ source 'https://rubygems.org'

gemspec

gem 'fog-proxmox', '~> 0.6'
gem 'fog-proxmox', '~> 0.7'
114 changes: 59 additions & 55 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,82 +1,83 @@
PATH
remote: .
specs:
foreman_fog_proxmox (0.5.5)
foreman_fog_proxmox (0.7.0)
deface
fog-proxmox (~> 0.5)
fog-proxmox (~> 0.7)

GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.1)
actionpack (= 5.2.1)
actioncable (5.2.3)
actionpack (= 5.2.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
actionmailer (5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.1)
actionview (= 5.2.1)
activesupport (= 5.2.1)
actionpack (5.2.3)
actionview (= 5.2.3)
activesupport (= 5.2.3)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.1)
activesupport (= 5.2.1)
actionview (5.2.3)
activesupport (= 5.2.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.1)
activesupport (= 5.2.1)
activejob (5.2.3)
activesupport (= 5.2.3)
globalid (>= 0.3.6)
activemodel (5.2.1)
activesupport (= 5.2.1)
activerecord (5.2.1)
activemodel (= 5.2.1)
activesupport (= 5.2.1)
activemodel (5.2.3)
activesupport (= 5.2.3)
activerecord (5.2.3)
activemodel (= 5.2.3)
activesupport (= 5.2.3)
arel (>= 9.0)
activestorage (5.2.1)
actionpack (= 5.2.1)
activerecord (= 5.2.1)
activestorage (5.2.3)
actionpack (= 5.2.3)
activerecord (= 5.2.3)
marcel (~> 0.3.1)
activesupport (5.2.1)
activesupport (5.2.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
ast (2.4.0)
builder (3.2.3)
concurrent-ruby (1.1.3)
concurrent-ruby (1.1.5)
crass (1.0.4)
deface (1.3.2)
nokogiri (>= 1.6)
polyglot
rails (>= 4.1)
rainbow (>= 2.1.0)
docile (1.3.1)
erubi (1.7.1)
excon (0.62.0)
fog-core (1.45.0)
erubi (1.8.0)
excon (0.64.0)
fog-core (2.1.2)
builder
excon (~> 0.58)
formatador (~> 0.2)
mime-types
fog-json (1.2.0)
fog-core
multi_json (~> 1.10)
fog-proxmox (0.5.3)
fog-core (~> 1.45)
fog-json (~> 1.0)
fog-proxmox (0.7.0)
fog-core (~> 2.1)
fog-json (~> 1.2)
ipaddress (~> 0.8)
formatador (0.2.5)
globalid (0.4.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.1.1)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
ipaddress (0.8.3)
jaro_winkler (1.5.1)
Expand All @@ -89,48 +90,51 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mimemagic (0.3.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.0331)
mimemagic (0.3.3)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
mini_portile2 (2.4.0)
minitest (5.11.3)
multi_json (1.13.1)
nio4r (2.3.1)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
nokogiri (1.10.2)
mini_portile2 (~> 2.4.0)
parallel (1.12.1)
parser (2.5.1.2)
ast (~> 2.4.0)
polyglot (0.3.5)
powerpack (0.1.2)
rack (2.0.6)
rack (2.0.7)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.1)
actioncable (= 5.2.1)
actionmailer (= 5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
activemodel (= 5.2.1)
activerecord (= 5.2.1)
activestorage (= 5.2.1)
activesupport (= 5.2.1)
rails (5.2.3)
actioncable (= 5.2.3)
actionmailer (= 5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
activemodel (= 5.2.3)
activerecord (= 5.2.3)
activestorage (= 5.2.3)
activesupport (= 5.2.3)
bundler (>= 1.3.0)
railties (= 5.2.1)
railties (= 5.2.3)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.1)
actionpack (= 5.2.1)
activesupport (= 5.2.1)
railties (5.2.3)
actionpack (= 5.2.3)
activesupport (= 5.2.3)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
rake (12.3.1)
rake (12.3.2)
rdoc (6.0.4)
rubocop (0.58.2)
jaro_winkler (~> 1.5.1)
Expand Down Expand Up @@ -166,11 +170,11 @@ PLATFORMS
ruby

DEPENDENCIES
fog-proxmox (~> 0.5.3)
fog-proxmox (~> 0.7)
foreman_fog_proxmox!
rdoc
rubocop
simplecov

BUNDLED WITH
1.17.1
1.17.2
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ If you like it and need more features you can [support](SUPPORT.md) it.
|Fog-proxmox|Proxmox|Foreman-fog-proxmox|Foreman|Ruby|
|--|--|--|--|--|
|<0.6|<5.3|<0.6|<=1.20|>=2.3|
|>=0.6|=5.3|>=0.6|=1.21|>=2.3|
|=0.6|=5.3|=0.6|=1.21|>=2.3|
|=0.7|=5.4|=0.7|=1.22|>=2.3|

## Installation

Expand Down Expand Up @@ -62,7 +63,7 @@ sudo -u foreman /usr/bin/foreman-ruby /usr/bin/bundle install
/usr/bin/foreman-ruby /usr/bin/bundle exec bin/rake plugin:gettext[foreman_fog_proxmox]
```

* Complete installation of foreman 1.17+ with foreman-installer:
* Complete installation of foreman 1.22 with foreman-installer:

```shell
sudo apt install -y foreman-installer
Expand Down Expand Up @@ -99,19 +100,18 @@ Redhat, CentOS or Fedora users should also [setup Selinux](https://projects.thef

### Prerequisites

* You need a Proxmox VE >= 5.1 server running.
* You need a Proxmox VE 5.4 server running.
* You need ruby >= 2.3. You can install it with [rbenv](https://github.com/rbenv/rbenv).
* You also need nodejs in your dev machine to run webpack-dev-server. You can install it with [nvm](https://github.com/creationix/nvm).

### Platform

* Fork this github repo.
* Clone it on your local machine
* Install foreman v1.21.1 on your machine:
* Install foreman v1.22 on your machine:

```shell
git clone https://github.com/theforeman/foreman
git checkout tags/1.21.1
git clone https://github.com/theforeman/foreman -b develop
```

* Create a Gemfile.local.rb file in foreman/bundler.d/
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/proxmox_container_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def parse_container_ostemplate(args)
def parse_container_volume(args)
disk = {}
id = args['id']
id = "mp#{args['device']}" if args.has_key?('device') && !id
id = "mp#{args['device']}" if args.has_key?('device')
delete = args['_delete'].to_i == 1
logger.debug("parse_container_volume() args=#{args}")
return args if ForemanFogProxmox::Value.empty?(id) || server_disk?(id)
Expand Down
17 changes: 8 additions & 9 deletions app/models/foreman_fog_proxmox/proxmox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,13 @@ def new_volume(attr = {})
def new_volume_server(attr = {})
opts = volume_server_defaults.merge(attr.to_h).deep_symbolize_keys
opts[:size] = opts[:size].to_s
Fog::Compute::Proxmox::Disk.new(opts)
Fog::Proxmox::Compute::Disk.new(opts)
end

def new_volume_container(attr = {})
id = attr[:id]
opts = volume_container_defaults(id).merge(attr.to_h).deep_symbolize_keys
opts = volume_container_defaults.merge(attr.to_h).deep_symbolize_keys
opts[:size] = opts[:size].to_s
Fog::Compute::Proxmox::Disk.new(opts)
Fog::Proxmox::Compute::Disk.new(opts)
end

def new_interface(attr = {})
Expand All @@ -179,13 +178,13 @@ def new_interface(attr = {})
def new_server_interface(attr = {})
logger.debug("new_server_interface")
opts = interface_server_defaults.merge(attr.to_h).deep_symbolize_keys
Fog::Compute::Proxmox::Interface.new(opts)
Fog::Proxmox::Compute::Interface.new(opts)
end

def new_container_interface(attr = {})
logger.debug("new_container_interface")
opts = interface_container_defaults.merge(attr.to_h).deep_symbolize_keys
Fog::Compute::Proxmox::Interface.new(opts)
Fog::Proxmox::Compute::Interface.new(opts)
end

# used by host.clone
Expand Down Expand Up @@ -430,15 +429,15 @@ def fog_credentials
end

def client
@client ||= ::Fog::Compute::Proxmox.new(fog_credentials)
@client ||= ::Fog::Proxmox::Compute.new(fog_credentials)
end

def identity_client
@identity_client ||= ::Fog::Identity::Proxmox.new(fog_credentials)
@identity_client ||= ::Fog::Proxmox::Identity.new(fog_credentials)
end

def network_client
@network_client ||= ::Fog::Network::Proxmox.new(fog_credentials)
@network_client ||= ::Fog::Proxmox::Network.new(fog_credentials)
end

def disconnect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
<%= field_set_tag _("Mount point"), :id => "container_volume_#{f.index}", :class => ('hide' unless container), :disabled => !container do %>
<%= f.hidden_field :volid if !new_vm %>
<%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2", :disabled => !new_vm %>
<%= text_f f, :mp, :label => _('Mount point'), :label_size => "col-md-2", :disabled => !new_vm, :required => true %>
<%= text_f f, :mp, :label => _('Path'), :label_size => "col-md-2", :disabled => !new_vm, :required => true %>
<%= counter_f f, :device, :label => _('Device'), :label_size => "col-md-2", :class => ('hide' if f.object.rootfs?), :disabled => (!new_vm || f.object.rootfs?), :'data-soft-max' => 10 %>
<%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2", :disabled => !new_vm %>
<% end %>
6 changes: 1 addition & 5 deletions app/views/compute_resources_vms/show/_proxmox.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
<%= prop :uptime %>
<%= prop :vmid %>
<%= prop :description %>
<% if @vm.container? %>
<%= prop :mount_points %>
<% else %>
<%= prop :disks %>
<% end %>
<%= prop :disks %>
</table>
</div>
4 changes: 2 additions & 2 deletions foreman_fog_proxmox.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ Gem::Specification.new do |s|
s.homepage = 'https://github.com/theforeman/foreman_fog_proxmox'
s.summary = 'Foreman plugin that adds Proxmox VE compute resource using fog-proxmox'
# also update locale/gemspec.rb
s.description = 'Foreman plugin adds Proxmox VE compute resource using fog-proxmox. It is compatible with Foreman 1.17+'
s.description = 'Foreman plugin adds Proxmox VE compute resource using fog-proxmox. It is compatible with Foreman 1.22+'

s.files = Dir['{app,config,db,lib,locale}/**/*'] + ['LICENSE', 'Rakefile', 'README.md']
s.test_files = Dir['test/**/*']

s.add_dependency 'fog-proxmox', '~> 0.6'
s.add_dependency 'fog-proxmox', '~> 0.7'
s.add_dependency 'deface'
s.add_development_dependency 'rdoc'
s.add_development_dependency 'rubocop'
Expand Down
12 changes: 6 additions & 6 deletions lib/foreman_fog_proxmox/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Engine < ::Rails::Engine

initializer 'foreman_fog_proxmox.register_plugin', :before => :finisher_hook do |_app|
Foreman::Plugin.register :foreman_fog_proxmox do
requires_foreman '>= 1.21.0'
requires_foreman '>= 1.22.0'
# Register Proxmox VE compute resource in foreman
compute_resource ForemanFogProxmox::Proxmox
parameter_filter(ComputeResource, :uuid)
Expand Down Expand Up @@ -85,12 +85,12 @@ class Engine < ::Rails::Engine
require 'fog/compute/proxmox/models/volume'
require 'fog/compute/proxmox/models/node'

Fog::Compute::Proxmox::Server.send :include, FogExtensions::Proxmox::Server
Fog::Compute::Proxmox::ServerConfig.send :include, FogExtensions::Proxmox::ServerConfig
Fog::Compute::Proxmox::Disk.send :include, FogExtensions::Proxmox::Disk
Fog::Compute::Proxmox::Volume.send :include, FogExtensions::Proxmox::Volume
Fog::Proxmox::Compute::Server.send :include, FogExtensions::Proxmox::Server
Fog::Proxmox::Compute::ServerConfig.send :include, FogExtensions::Proxmox::ServerConfig
Fog::Proxmox::Compute::Disk.send :include, FogExtensions::Proxmox::Disk
Fog::Proxmox::Compute::Volume.send :include, FogExtensions::Proxmox::Volume
::ComputeResourcesController.send :include, ForemanFogProxmox::Controller::Parameters::ComputeResource
Fog::Compute::Proxmox::Node.send :include, FogExtensions::Proxmox::Node
Fog::Proxmox::Compute::Node.send :include, FogExtensions::Proxmox::Node
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/foreman_fog_proxmox/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
# along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.

module ForemanFogProxmox
VERSION = '0.6.0'.freeze
VERSION = '0.7.0'.freeze
end
Loading

0 comments on commit 1f3b12f

Please sign in to comment.