ovfparse 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ovfparse/vmcollection.rb +15 -40
- data/lib/ovfparse/vmpackage.rb +10 -6
- metadata +4 -4
@@ -100,51 +100,24 @@ class VmCollection
|
|
100
100
|
return [isValid, response]
|
101
101
|
end
|
102
102
|
|
103
|
-
def
|
104
|
-
return
|
103
|
+
def getCollectionName
|
104
|
+
return virtualSystemCollection['id'] || ''
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
108
|
-
|
107
|
+
def getCollectionDescription
|
108
|
+
descNode = getChildByName(virtualSystemCollection, 'Info')
|
109
|
+
return descNode.nil? ? '' : descNode.content
|
109
110
|
end
|
110
111
|
|
111
|
-
def
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
}
|
117
|
-
|
118
|
-
getChildrenByName(diskSection, 'Disk').each { |node|
|
119
|
-
capacity = node['capacity']
|
120
|
-
units = node['capacityAllocationUnits']
|
121
|
-
if(units == "byte * 2^40")
|
122
|
-
capacity = (capacity.to_i * 1099511627776).to_s
|
123
|
-
elsif(units == "byte * 2^30")
|
124
|
-
capacity = (capacity.to_i * 1073741824).to_s
|
125
|
-
elsif(units == "byte * 2^20")
|
126
|
-
capacity = (capacity.to_i * 1048576).to_s
|
127
|
-
elsif(units == "byte * 2^10")
|
128
|
-
capacity = (capacity.to_i * 1024).to_s
|
129
|
-
end
|
130
|
-
thin_size = node['populatedSize']
|
131
|
-
disks.push({ 'name' => node['diskId'], 'location' => filenames[node['fileRef']], 'size' => capacity, 'thin_size' => (thin_size || "-1") })
|
132
|
-
}
|
133
|
-
|
134
|
-
return disks
|
135
|
-
end
|
136
|
-
|
137
|
-
def getVmNetworks
|
138
|
-
networks = Array.new
|
139
|
-
getChildrenByName(networkSection, 'Network').each { |node|
|
140
|
-
descriptionNode = getChildByName(node, 'Description')
|
141
|
-
text = descriptionNode.nil? ? '' : descriptionNode.text
|
142
|
-
networks.push({'location' => node['name'], 'notes' => text })
|
143
|
-
}
|
144
|
-
return networks
|
112
|
+
def setCollectionName(newValue)
|
113
|
+
virtualSystem['ovf:id'] = newValue
|
114
|
+
nameNode = getChildByName(virtualSystemCollection, 'Name') ||
|
115
|
+
getChildByName(virtualSystemCollection, 'Info').add_next_sibling(xml.create_element('Name', {}))
|
116
|
+
nameNode.content = newValue
|
145
117
|
end
|
146
118
|
|
147
|
-
def
|
119
|
+
def setCollectionDescription(newValue)
|
120
|
+
getChildByName(virtualSystemCollection, 'Info').content = newValue
|
148
121
|
end
|
149
122
|
|
150
123
|
def self.constructFromVmPackages(packages)
|
@@ -304,7 +277,7 @@ class VmCollection
|
|
304
277
|
xml.NetworkSection{
|
305
278
|
xml.Info "List of logical networks"
|
306
279
|
}
|
307
|
-
xml.VirtualSystemCollection('
|
280
|
+
xml.VirtualSystemCollection('id' => "vm_collection"){
|
308
281
|
xml.Info "A collection of virtual machines"
|
309
282
|
}
|
310
283
|
}
|
@@ -313,6 +286,7 @@ class VmCollection
|
|
313
286
|
xml.doc.children[0].add_previous_sibling(node)
|
314
287
|
end
|
315
288
|
|
289
|
+
builder.doc.root.children[3].attribute("id").namespace = builder.doc.root.namespace_definitions.detect{ |ns| ns.prefix == "ovf"}
|
316
290
|
newPackage = NewVmCollection.new
|
317
291
|
newPackage.xml = builder.doc
|
318
292
|
newPackage.loadElementRefs
|
@@ -351,6 +325,7 @@ class VmCollection
|
|
351
325
|
}
|
352
326
|
|
353
327
|
new_package.virtualSystem.children.unlink
|
328
|
+
new_package.virtualSystem['ovf:id'] = virtualSystem['id']
|
354
329
|
new_package.virtualSystem.add_child(virtualSystem.clone.children)
|
355
330
|
new_package.virtualSystem.children.each{ |child|
|
356
331
|
child.namespace = new_package.virtualSystem.namespace
|
data/lib/ovfparse/vmpackage.rb
CHANGED
@@ -302,7 +302,6 @@ class VmPackage
|
|
302
302
|
getChildByName(virtualSystem, 'OperatingSystemSection')['ovf:id'] = newValue.to_s
|
303
303
|
end
|
304
304
|
|
305
|
-
|
306
305
|
def setVmCPUs(newValue)
|
307
306
|
setVirtualQuantity(3, newValue)
|
308
307
|
end
|
@@ -622,10 +621,10 @@ class VmPackage
|
|
622
621
|
xml.NetworkSection{
|
623
622
|
xml.Info "List of logical networks"
|
624
623
|
}
|
625
|
-
xml.VirtualSystem('
|
624
|
+
xml.VirtualSystem('id' => "vm"){
|
626
625
|
xml.Info "A virtual machine"
|
627
626
|
xml.Name "New Virtual Machine"
|
628
|
-
xml.OperatingSystemSection('
|
627
|
+
xml.OperatingSystemSection('id' => "94"){
|
629
628
|
xml.Info "The kind of guest operating system"
|
630
629
|
}
|
631
630
|
xml.VirtualHardwareSection{
|
@@ -659,15 +658,20 @@ class VmPackage
|
|
659
658
|
xml.doc.children[0].add_previous_sibling(node)
|
660
659
|
end
|
661
660
|
|
661
|
+
builder.doc.root.children[3].attribute("id").namespace = builder.doc.root.namespace_definitions.detect{ |ns| ns.prefix == "ovf"}
|
662
|
+
builder.doc.root.children[3].children[2].attribute("id").namespace = builder.doc.root.namespace_definitions.detect{ |ns| ns.prefix == "ovf"}
|
663
|
+
|
662
664
|
newPackage = NewVmPackage.new
|
663
665
|
newPackage.xml = builder.doc
|
664
666
|
newPackage.loadElementRefs
|
665
667
|
return newPackage
|
666
668
|
end
|
667
669
|
|
668
|
-
|
669
|
-
|
670
|
-
|
670
|
+
def writeXML(filename)
|
671
|
+
file = File.new(filename, "w")
|
672
|
+
file.puts(xml.to_s)
|
673
|
+
file.close
|
674
|
+
end
|
671
675
|
|
672
676
|
# @todo make this a general purpose signing util
|
673
677
|
def sign(signature)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ovfparse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 2
|
10
|
+
version: 0.9.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jim Barkley
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-11 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|