Skip to content

Commit fb6454d

Browse files
committed
Merge pull request #126 from tuxmea/types_providers_4_10
Types providers 4 10
2 parents ae3511d + 2c7e64e commit fb6454d

22 files changed

Lines changed: 186 additions & 38 deletions

File tree

lib/puppet/provider/onecluster/cli.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
# Copyright
1010
# initial provider had no copyright
11-
# Deutsche Post E-POST Development GmbH - 2014
11+
# Deutsche Post E-POST Development GmbH - 2014,2015
1212
#
1313

1414
require 'rexml/document'
@@ -73,7 +73,8 @@ def exists?
7373

7474

7575
def self.instances
76-
REXML::Document.new(onecluster('list', '-x')).elements.collect("CLUSTER_POOL/CLUSTER") do |cluster|
76+
clusters = REXML::Document.new(onecluster('list', '-x')).elements.collect("CLUSTER_POOL/CLUSTER")
77+
clusters.collect do |cluster|
7778
datastores = cluster.elements.collect("DATASTORES/ID") do |id|
7879
REXML::Document.new(onedatastore('show', id.text, '-x')).elements["DATASTORE/NAME"].text
7980
end

lib/puppet/provider/onedatastore/cli.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
#
99
# Copyright
1010
# initial provider had no copyright
11-
# Deutsche Post E-POST Development GmbH - 2014
11+
# Deutsche Post E-POST Development GmbH - 2014, 2015
1212
#
1313

14+
require 'rubygems'
1415
require 'nokogiri'
1516

1617
Puppet::Type.type(:onedatastore).provide(:cli) do
@@ -55,7 +56,8 @@ def exists?
5556
end
5657

5758
def self.instances
58-
Nokogiri::XML(onedatastore('list','-x')).root.xpath('/DATASTORE_POOL/DATASTORE').map do |datastore|
59+
datastores = Nokogiri::XML(onedatastore('list','-x')).root.xpath('/DATASTORE_POOL/DATASTORE').map
60+
datastores.collect do |datastore|
5961
new(
6062
:name => datastore.xpath('./NAME').text,
6163
:ensure => :present,

lib/puppet/provider/onehost/cli.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# OpenNebula Puppet provider for onehost
2+
#
3+
# License: APLv2
4+
#
5+
# Authors:
6+
# Based upon initial work from Ken Barber
7+
# Modified by Martin Alfke
8+
#
9+
# Copyright
10+
# initial provider had no copyright
11+
# Deutsche Post E-POST Development GmbH - 2014, 2015
12+
#
13+
14+
require 'rubygems'
115
require 'nokogiri'
216

317
Puppet::Type.type(:onehost).provide(:cli) do
@@ -24,7 +38,8 @@ def exists?
2438
end
2539

2640
def self.instances
27-
Nokogiri::XML(onehost('list','-x')).root.xpath('/HOST_POOL/HOST') do | host|
41+
hosts = Nokogiri::XML(onehost('list','-x')).root.xpath('/HOST_POOL/HOST')
42+
hosts.collect do |host|
2843
new(
2944
:name => host.xpath('./NAME').text,
3045
:ensure => :present,

lib/puppet/provider/oneimage/cli.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# OpenNebula Puppet provider for oneimage
2+
#
3+
# License: APLv2
4+
#
5+
# Authors:
6+
# Based upon initial work from Ken Barber
7+
# Modified by Martin Alfke
8+
#
9+
# Copyright
10+
# initial provider had no copyright
11+
# Deutsche Post E-POST Development GmbH - 2014, 2015
12+
#
13+
14+
require 'rubygems'
115
require 'nokogiri'
216

317
Puppet::Type.type(:oneimage).provide(:cli) do
@@ -67,7 +81,8 @@ def exists?
6781

6882
# Return the full hash of all existing oneimage resources
6983
def self.instances
70-
Nokogiri::XML(oneimage('list','-x')).root.xpath('/IMAGE_POOL/IMAGE').map do |image|
84+
images = Nokogiri::XML(oneimage('list','-x')).root.xpath('/IMAGE_POOL/IMAGE').map
85+
images.collect do |image|
7186
new(
7287
:name => image.xpath('./NAME').text,
7388
:ensure => :present,

lib/puppet/provider/onetemplate/cli.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# OpenNebula Puppet provider for onetemplate
2+
#
3+
# License: APLv2
4+
#
5+
# Authors:
6+
# Based upon initial work from Ken Barber
7+
# Modified by Martin Alfke
8+
#
9+
# Copyright
10+
# initial provider had no copyright
11+
# Deutsche Post E-POST Development GmbH - 2014, 2015
12+
#
13+
14+
require 'rubygems'
115
require 'nokogiri'
216

317
Puppet::Type.type(:onetemplate).provide(:cli) do
@@ -75,7 +89,8 @@ def exists?
7589

7690
# Return the full hash of all existing onevm resources
7791
def self.instances
78-
Nokogiri::XML(onetemplate('list', '-x')).root.xpath('/VMTEMPLATE_POOL/VMTEMPLATE') do | template|
92+
templates = Nokogiri::XML(onetemplate('list', '-x')).root.xpath('/VMTEMPLATE_POOL/VMTEMPLATE')
93+
templates.collect do |template|
7994
new(
8095
:name => template.xpath('./NAME').text,
8196
:ensure => :present,

lib/puppet/provider/onevm/cli.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
require 'rexml/document'
1+
# OpenNebula Puppet provider for onevm
2+
#
3+
# License: APLv2
4+
#
5+
# Authors:
6+
# Based upon initial work from Ken Barber
7+
# Modified by Martin Alfke
8+
#
9+
# Copyright
10+
# initial provider had no copyright
11+
# Deutsche Post E-POST Development GmbH - 2014, 2015
12+
#
13+
14+
require 'rubygems'
15+
require 'nokogiri'
216
require 'tempfile'
317
require 'erb'
418

@@ -33,7 +47,8 @@ def exists?
3347

3448
# Return the full hash of all existing onevm resources
3549
def self.instances
36-
Nokogiri::XML(omevm('list','-x')).root.xpath('/VM_POOL/VM') do |vm|
50+
vms = Nokogiri::XML(omevm('list','-x')).root.xpath('/VM_POOL/VM')
51+
vms.collect do |vm|
3752
new(
3853
:name => vm.xpath('./NAME').text,
3954
:ensure => :present,

lib/puppet/provider/onevnet/cli.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88
#
99
# Copyright
1010
# initial provider had no copyright
11-
# Deutsche Post E-POST Development GmbH - 2014
11+
# Deutsche Post E-POST Development GmbH - 2014, 2015
1212
#
1313

14-
# require section:
15-
# we read onevnet structure by using xml
16-
# we write tempfiles as erb templates for creating resources and setting properties
17-
#
14+
require 'rubygems'
1815
require 'nokogiri'
1916

2017
Puppet::Type.type(:onevnet).provide(:cli) do
@@ -104,7 +101,8 @@ def exists?
104101

105102
# Return the full hash of all existing onevnet resources
106103
def self.instances
107-
Nokogiri::XML(onevnet('list','-x')).root.xpath('/VNET_POOL/VNET').map do |vnet|
104+
vnets = Nokogiri::XML(onevnet('list','-x')).root.xpath('/VNET_POOL/VNET').map
105+
vnets.collect do |vnet|
108106
hash = {
109107
:name => vnet.xpath('./NAME').text,
110108
:ensure => :present,

lib/puppet/type/onecluster.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# OpenNebula Puppet type for onecluster
2+
#
3+
# License: APLv2
4+
#
5+
# Authors:
6+
# Based upon initial work from Ken Barber
7+
# Modified by Martin Alfke
8+
#
9+
# Copyright
10+
# initial provider had no copyright
11+
# Deutsche Post E-POST Development GmbH - 2014, 2015
12+
#
13+
114
Puppet::Type.newtype(:onecluster) do
215
@doc = "Type for managing clusters in OpenNebula using the onecluster" +
316
"wrapper command."

lib/puppet/type/onedatastore.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# OpenNebula Puppet type for onedatastore
2+
#
3+
# License: APLv2
4+
#
5+
# Authors:
6+
# Based upon initial work from Ken Barber
7+
# Modified by Martin Alfke
8+
#
9+
# Copyright
10+
# initial provider had no copyright
11+
# Deutsche Post E-POST Development GmbH - 2014, 2015
12+
#
113
Puppet::Type.newtype(:onedatastore) do
214
@doc = "Type for managing datastores in OpenNebula using the onedatastore" +
315
"wrapper command."

lib/puppet/type/onehost.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# OpenNebula Puppet type for onehost
2+
#
3+
# License: APLv2
4+
#
5+
# Authors:
6+
# Based upon initial work from Ken Barber
7+
# Modified by Martin Alfke
8+
#
9+
# Copyright
10+
# initial provider had no copyright
11+
# Deutsche Post E-POST Development GmbH - 2014, 2015
12+
#
113
Puppet::Type.newtype(:onehost) do
214
@doc = <<-EOS
315
Type for managing hypervisor hosts in OpenNebula using the onehost wrapper
@@ -22,7 +34,7 @@
2234
newproperty(:vm_mad) do
2335
desc "Virtualization Driver"
2436
defaultto :dummy
25-
newvalues(:kvm, :xen, :vmware, :ec2, :dummy)
37+
newvalues(:kvm, :xen, :vmware, :ec2, :dummy, :qemu)
2638
end
2739

2840
newproperty(:vn_mad) do

0 commit comments

Comments
 (0)