-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proxmox extention for foreman_bootdisk
- Loading branch information
Showing
7 changed files
with
98 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ Rails: | |
Style: | ||
Enabled: false | ||
|
||
Layout/LineLength: | ||
Enabled: false | ||
|
||
Metrics: | ||
Enabled: false | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'fog/compute/proxmox/models/node' | ||
|
||
FactoryBot.define do | ||
factory :proxmox_resource, :class => ComputeResource do | ||
sequence(:name) { |n| "compute_resource#{n}" } | ||
organizations { [Organization.find_by(name: 'Organization 1')] } | ||
locations { [Location.find_by(name: 'Location 1')] } | ||
|
||
trait :proxmox do | ||
provider { 'Proxmox' } | ||
user { 'root@pam' } | ||
password { 'proxmox01' } | ||
url { 'https://192.168.56.101:8006/api2/json' } | ||
end | ||
|
||
after(:build) do | ||
WebMock.stub_request(:post, "https://192.168.56.101:8006/api2/json/access/ticket") | ||
.with( | ||
body: "username=root%40pam&password=proxmox01", | ||
headers: { | ||
'Accept' => 'application/json', | ||
'Host' => '192.168.56.101:8006', | ||
'User-Agent' => 'fog-core/2.1.0' | ||
} | ||
).to_return(status: 200, body: "", headers: {}) | ||
end | ||
factory :proxmox_cr, :class => ForemanFogProxmox::Proxmox, :traits => [:proxmox] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_plugin_helper' | ||
|
||
module ForemanBootdisk | ||
class ProxmoxTest < ActiveSupport::TestCase | ||
describe '#new_vm' do | ||
setup do | ||
@cr = FactoryBot.build(:proxmox_cr) | ||
end | ||
|
||
test 'calls client with cdrom drive and correct boot order when bootdisk provisioning' do | ||
attr = { 'boot' => 'dcn', 'bootdisk' => 'ide2' } | ||
vm = mock('vm') | ||
config = mock('config') | ||
config.stubs(:inspect).returns('config') | ||
vm.stubs(:config).returns(config) | ||
@cr.stubs(:new_server_vm).with(attr).returns(vm) | ||
assert_equal vm, @cr.new_vm(attr) | ||
end | ||
end | ||
|
||
describe '#capabilities' do | ||
setup do | ||
@cr = FactoryBot.build(:proxmox_cr) | ||
end | ||
|
||
test 'should include bootdisk' do | ||
assert_includes @cr.capabilities, :bootdisk | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters