Skip to content

Commit

Permalink
Added a simple EULA to v0.9.ovf to cover EULAs in 'info' UT
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmatthews committed Jan 27, 2015
1 parent b728499 commit 850127b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
19 changes: 14 additions & 5 deletions COT/ovf.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ def info_string(self, verbosity_option=None):
# An OVF may have zero, one, or more
eula_header = False
for e in self.find_all_children(self.virtual_system,
self.EULA_SECTION):
self.EULA_SECTION,
self.EULA_SECTION_ATTRIB):
info = e.find(self.INFO)
lic = e.find(self.EULA_LICENSE)
if lic is not None and lic.text:
Expand Down Expand Up @@ -1346,9 +1347,7 @@ def get_type_from_device(self, device):
for key in self.RES_MAP.keys():
if type == self.RES_MAP[key]:
return key
raise ValueUnsupportedError(self.RESOURCE_TYPE,
type,
self.RES_MAP.values())
return "unknown ({0})".format(type)

def get_subtype_from_device(self, device):
"""Return the subtype string for the given device"""
Expand Down Expand Up @@ -1996,7 +1995,15 @@ def __init__(self, version):
self.PROPERTY_DESC = OVF + 'Description'

# Envelope -> VirtualSystem -> EulaSection -> License
self.EULA_SECTION = OVF + 'EulaSection'
if self.ovf_version < 1.0:
self.EULA_SECTION = OVF + 'Section'
self.EULA_SECTION_ATTRIB = {
XSI + 'type': "ovf:EulaSection_Type"
}
else:
self.EULA_SECTION = OVF + 'EulaSection'
self.EULA_SECTION_ATTRIB = {}

self.EULA_LICENSE = OVF + 'License'

# Envelope -> VirtualSystem -> VirtualHardwareSection -> Item(s)
Expand Down Expand Up @@ -2119,6 +2126,8 @@ def __init__(self, version):
self.VIRTUAL_SYSTEM_TYPE = VSSD + 'VirtualSystemType'

# List of ResourceType string values we know about
# http://schemas.dmtf.org/wbem/cim-html/2/
# CIM_ResourceAllocationSettingData.html
self.RES_MAP = {
'cpu': '3',
'memory': '4',
Expand Down
9 changes: 9 additions & 0 deletions COT/tests/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ def test_v09_ovf(self):
-------------------------------------------------------------------------------
Annotation: Hello world! This is a version 0.9 OVF.
End User License Agreement(s):
Licensing agreement
(not displayed, use 'cot info --verbose' if desired)
Files and Disks: File Size Capacity Device
---------- ---------- --------------------
input.vmdk 149.00 kB 1.00 GB harddisk @ SCSI 0:0
Expand Down Expand Up @@ -483,6 +487,11 @@ def test_v09_ovf(self):
-------------------------------------------------------------------------------
Annotation: Hello world! This is a version 0.9 OVF.
End User License Agreement(s):
Licensing agreement
Licensing text, oh licensing text!
How lovely is thy legalese!
Files and Disks: File Size Capacity Device
---------- ---------- --------------------
input.vmdk 149.00 kB 1.00 GB harddisk @ SCSI 0:0
Expand Down
5 changes: 5 additions & 0 deletions COT/tests/v0.9.ovf
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,10 @@
<ovf:Info>A human-readable annotation</ovf:Info>
<ovf:Annotation>Hello world! This is a version 0.9 OVF.</ovf:Annotation>
</ovf:Section>
<ovf:Section ovf:required="false" xsi:type="ovf:EulaSection_Type">
<ovf:Info>Licensing agreement</ovf:Info>
<ovf:License>Licensing text, oh licensing text!
How lovely is thy legalese!</ovf:License>
</ovf:Section>
</ovf:Content>
</ovf:Envelope>

0 comments on commit 850127b

Please sign in to comment.