rbovirt 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f288949bbc80a2901f8b6e2aa257f551e33b298c
4
- data.tar.gz: 17de341eb7cf43b68ec47304e4cb19c3a4f3d93b
3
+ metadata.gz: abcc1f63781e5ac6ab29e40b1f497e5ae0fc35a7
4
+ data.tar.gz: fb5b226fe6dcd08f3ed0c7aad7449ed19805127c
5
5
  SHA512:
6
- metadata.gz: 73d71c0726bb896b8fe7d78b4387eb229d81823de853cb82fc4cf5bfd05b0050d02c16a3314f32b540f8e84bcf185d85a403d296aa7e68c19afce643f5ced9df
7
- data.tar.gz: e6fef3df78fa83ce368614845dba1aed084bf24a7352200456215823abccfd9b6458ce348c68ffa4f06bd9cce35e8f90ec27302a5205255c1f12020c09f26ade
6
+ metadata.gz: 4a0bdc00d5b70be58f5daca0a9e67eb9b646f34b127c5514d4a84468a51aa44cff3417f8d89890d44dff3154c4f472ee98895e7a7478dedc1334707a92dda813
7
+ data.tar.gz: af49d5221bf07f53d22569ea6db69c8370113321c1bb308aa4bd252c7509d7cf37cc5fbf1d00a3f9975db1dbb80132e8c180c5367b658ad632517cded9a82ad5
@@ -0,0 +1,43 @@
1
+ module OVIRT
2
+ class Client
3
+ def affinity_group(affinity_group_id, opts={})
4
+ cluster_id = opts[:cluster_id] || current_cluster.id
5
+ ag_xml = http_get("/clusters/%s/affinitygroups/%s" % [cluster_id, affinity_group_id], http_headers)
6
+ OVIRT::AffinityGroup.new(self, ag_xml.root)
7
+ end
8
+
9
+ def affinity_groups(opts={})
10
+ cluster_id = opts[:cluster_id] || current_cluster.id
11
+ http_get("/clusters/%s/affinitygroups" % cluster_id, http_headers).xpath('/affinity_groups/affinity_group').collect do |ag|
12
+ OVIRT::AffinityGroup.new(self, ag)
13
+ end
14
+ end
15
+
16
+ def affinity_group_vms(affinity_group_id, opts={})
17
+ cluster_id = opts[:cluster_id] || current_cluster.id
18
+ http_get("/clusters/%s/affinitygroups/%s/vms" % [cluster_id, affinity_group_id], http_headers).xpath('/vms/vm').collect do |vm_ref|
19
+ OVIRT::VM.new(self, http_get("/vms/%s" % vm_ref.attribute('id').value, http_headers).root)
20
+ end
21
+ end
22
+
23
+ def create_affinity_group(opts={})
24
+ cluster_id = opts[:cluster_id] || current_cluster.id
25
+ OVIRT::AffinityGroup.new(self, http_post("/clusters/%s/affinitygroups" % cluster_id, OVIRT::AffinityGroup.to_xml(opts)).root)
26
+ end
27
+
28
+ def destroy_affinity_group(affinity_group_id, opts={})
29
+ cluster_id = opts[:cluster_id] || current_cluster.id
30
+ http_delete("/clusters/%s/affinitygroups/%s" % [cluster_id, affinity_group_id])
31
+ end
32
+
33
+ def add_vm_to_affinity_group(affinity_group_id, vm_id, opts={})
34
+ cluster_id = opts[:cluster_id] || current_cluster.id
35
+ http_post("/clusters/%s/affinitygroups/%s/vms" % [cluster_id, affinity_group_id], "<vm id='%s'/>" % vm_id)
36
+ end
37
+
38
+ def delete_vm_from_affinity_group(affinity_group_id, vm_id, opts={})
39
+ cluster_id = opts[:cluster_id] || current_cluster.id
40
+ http_delete("/clusters/%s/affinitygroups/%s/vms/%s" % [cluster_id, affinity_group_id, vm_id])
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ module OVIRT
2
+
3
+ class AffinityGroup < BaseObject
4
+ attr_reader :name, :positive, :enforcing
5
+
6
+ def initialize(client, xml)
7
+ super(client, xml[:id], xml[:href], (xml/'name').first.text)
8
+ parse_xml_attributes!(xml)
9
+ self
10
+ end
11
+
12
+ def self.to_xml(opts={})
13
+ builder = Nokogiri::XML::Builder.new do
14
+ affinity_group_{
15
+ if opts[:name]
16
+ name_(opts[:name])
17
+ end
18
+ if opts[:positive]
19
+ positive_(opts[:positive])
20
+ end
21
+ if opts[:enforcing]
22
+ enforcing_(opts[:enforcing])
23
+ end
24
+ }
25
+ end
26
+ Nokogiri::XML(builder.to_xml).root.to_s
27
+ end
28
+
29
+ def parse_xml_attributes!(xml)
30
+ @name = (xml/'name').first.text
31
+ @positive = (xml/'positive').first.text if (xml/'positive')
32
+ @enforcing = (xml/'enforcing').first.text if (xml/'enforcing')
33
+ @cluster = Link::new(@client, (xml/'cluster').first[:id], (xml/'cluster').first[:href]) rescue nil
34
+ end
35
+ end
36
+ end
data/lib/ovirt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OVIRT
2
- VERSION = "0.0.34"
2
+ VERSION = "0.0.35"
3
3
  end
data/lib/ovirt/volume.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module OVIRT
2
2
 
3
3
  class Volume < BaseObject
4
- attr_reader :size, :disk_type, :bootable, :interface, :format, :sparse, :status, :storage_domain, :vm, :quota
4
+ attr_reader :size, :disk_type, :bootable, :interface, :format, :sparse, :status, :storage_domain, :vm, :quota, :alias
5
5
 
6
6
  def initialize(client, xml)
7
7
  super(client, xml[:id], xml[:href], (xml/'name').first.text)
@@ -38,6 +38,9 @@ module OVIRT
38
38
  if opts[:quota]
39
39
  quota_( :id => opts[:quota])
40
40
  end
41
+ if opts[:alias]
42
+ alias_(opts[:alias])
43
+ end
41
44
  }
42
45
  end
43
46
  Nokogiri::XML(builder.to_xml).root.to_s
@@ -54,6 +57,7 @@ module OVIRT
54
57
  @status = ((xml/'status/state').first.text rescue nil)
55
58
  @vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href]) rescue nil
56
59
  @quota = ((xml/'quota').first[:id] rescue nil)
60
+ @alias = ((xml/'alias').first.text rescue nil)
57
61
  end
58
62
 
59
63
  end
data/lib/rbovirt.rb CHANGED
@@ -10,6 +10,7 @@ require "ovirt/volume"
10
10
  require "ovirt/interface"
11
11
  require "ovirt/network"
12
12
  require "ovirt/quota"
13
+ require "ovirt/affinity_group"
13
14
  require "ovirt/version"
14
15
 
15
16
  require "client/vm_api"
@@ -20,6 +21,7 @@ require "client/datacenter_api"
20
21
  require "client/storage_domain_api"
21
22
  require "client/quota_api"
22
23
  require "client/disk_api"
24
+ require "client/affinity_group_api"
23
25
 
24
26
  require "nokogiri"
25
27
  require "rest_client"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbovirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.34
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amos Benari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-13 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -97,6 +97,7 @@ files:
97
97
  - LICENSE.txt
98
98
  - README.rdoc
99
99
  - Rakefile
100
+ - lib/client/affinity_group_api.rb
100
101
  - lib/client/cluster_api.rb
101
102
  - lib/client/datacenter_api.rb
102
103
  - lib/client/disk_api.rb
@@ -105,6 +106,7 @@ files:
105
106
  - lib/client/storage_domain_api.rb
106
107
  - lib/client/template_api.rb
107
108
  - lib/client/vm_api.rb
109
+ - lib/ovirt/affinity_group.rb
108
110
  - lib/ovirt/base_object.rb
109
111
  - lib/ovirt/cluster.rb
110
112
  - lib/ovirt/datacenter.rb