Skip to content

Commit

Permalink
Multiple EulaSections is not an error. Added provisional support for …
Browse files Browse the repository at this point in the history
…OVF 2.0
  • Loading branch information
glennmatthews committed Jan 16, 2015
1 parent e43c90c commit 6e8fd45
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions COT/ovf.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,16 @@ def __init__(self, input_file, working_dir, output_file):
self.root.tag))

root_namespace = XML.get_ns(self.root.tag)
logger.verbose("Root namespace is " + root_namespace)
if root_namespace == 'http://www.vmware.com/schema/ovf/1/envelope':
logger.info("OVF version is 0.9")
self.ovf_version = 0.9
elif root_namespace == 'http://schemas.dmtf.org/ovf/envelope/1':
logger.info("OVF version is 1.0 or later")
# TODO, be more granular here?
logger.info("OVF version is 1.x")
self.ovf_version = 1.0
elif root_namespace == 'http://schemas.dmtf.org/ovf/envelope/2':
logger.info("OVF version is 2.x")
self.ovf_version = 2.0
else:
raiseVMInitError(
2,
Expand Down Expand Up @@ -226,8 +229,6 @@ def __init__(self, input_file, working_dir, output_file):
required=True)
self.product_section = self.find_child(self.virtual_system,
self.PRODUCT_SECTION)
self.eula_section = self.find_child(self.virtual_system,
self.EULA_SECTION)
self.annotation_section = self.find_child(
self.virtual_system,
self.ANNOTATION_SECTION,
Expand Down Expand Up @@ -425,19 +426,25 @@ def info_string(self, verbosity_option=None):
first = False

# End user license agreement information
e = self.eula_section
if e is not 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):
info = e.find(self.INFO)
lic = e.find(self.EULA_LICENSE)
if lic is not None and lic.text:
str_list.append("")
if verbosity_option == 'brief':
str_list.append("End User License Agreement: "
"(not displayed)")
if not eula_header:
str_list.append("End User License Agreement(s):")
eula_header = True
if info is not None and info.text:
str_list.append(' ' + info.text)
if verbosity_option != 'verbose':
str_list.append(" (not displayed, use 'cot info "
"--verbose' if desired)")
else:
str_list.append("End User License Agreement:")
wrapper = textwrap.TextWrapper(width=TEXT_WIDTH,
initial_indent=' ',
subsequent_indent=' ')
initial_indent=' ',
subsequent_indent=' ')
for line in lic.text.splitlines():
str_list.append(wrapper.fill(line))

Expand Down Expand Up @@ -572,7 +579,8 @@ def info_string(self, verbosity_option=None):
str_list.append("")
str_list.append("NICs and Associated Networks:")
wrapper = textwrap.TextWrapper(width=TEXT_WIDTH,
initial_indent= ' ')
initial_indent= ' ',
subsequent_indent=' ')
for nic in nics:
network_name = nic.get_value(self.CONNECTION)
str_list.append(" {0:30} : {1}"
Expand Down Expand Up @@ -1851,8 +1859,10 @@ def __init__(self, version):

if self.ovf_version < 1.0:
self.NSM['ovf'] = "http://www.vmware.com/schema/ovf/1/envelope"
else:
elif self.ovf_version < 2.0:
self.NSM['ovf'] = "http://schemas.dmtf.org/ovf/envelope/1"
else:
self.NSM['ovf'] = "http://schemas.dmtf.org/ovf/envelope/2"

# Shortcuts for finding/creating elements in various namespaces
self.OVF = ('{' + self.NSM['ovf'] + '}')
Expand Down

0 comments on commit 6e8fd45

Please sign in to comment.