Skip to content

Commit

Permalink
Ensure that cloned Items always have higher InstanceID than parent It…
Browse files Browse the repository at this point in the history
…em. Fixes #70
  • Loading branch information
glennmatthews committed Nov 29, 2017
1 parent 294b023 commit 06c0214
Show file tree
Hide file tree
Showing 6 changed files with 372 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This project adheres to `Semantic Versioning`_.

**Fixed**

- COT now ensures that cloned Items have a higher InstanceID than the Item
they were cloned from, avoiding unexpected out-of-order behavior (`#70`_).
- COT now produces valid manifests for OVF 2.x files (which use SHA256
instead of SHA1 as in OVF 0.x and 1.x).

Expand Down Expand Up @@ -799,6 +801,7 @@ Initial public release.
.. _#65: https://github.com/glennmatthews/cot/issues/65
.. _#66: https://github.com/glennmatthews/cot/issues/66
.. _#67: https://github.com/glennmatthews/cot/issues/67
.. _#70: https://github.com/glennmatthews/cot/issues/70

.. _Semantic Versioning: http://semver.org/
.. _`PEP 8`: https://www.python.org/dev/peps/pep-0008/
Expand Down
40 changes: 40 additions & 0 deletions COT/commands/tests/test_edit_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,46 @@ def test_set_nic_count_add_smart_networks(self):
+ </ovf:Item>
</ovf:VirtualHardwareSection>""", file1=self.csr_ovf)

def test_set_nic_count_add_nonconsecutive_instances(self):
"""Add additional NICs to an OVF with non-consecutive InstanceIDs."""
self.command.package = self.csr_ovf_2017
self.command.nics = 5
self.command.run()
self.command.finished()
self.check_diff("""
<ovf:Description>Data network 3</ovf:Description>
+ </ovf:Network>
+ <ovf:Network ovf:name="GigabitEthernet4">
+ <ovf:Description>Data network 4</ovf:Description>
+ </ovf:Network>
+ <ovf:Network ovf:name="GigabitEthernet5">
+ <ovf:Description>Data network 5</ovf:Description>
</ovf:Network>
...
<ovf:Item>
+ <rasd:AddressOnParent>14</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
+ <rasd:Connection>GigabitEthernet4</rasd:Connection>
+ <rasd:Description>NIC representing GigabitEthernet4</rasd:Description>
+ <rasd:ElementName>GigabitEthernet4</rasd:ElementName>
+ <rasd:InstanceID>14</rasd:InstanceID>
+ <rasd:ResourceSubType>VMXNET3</rasd:ResourceSubType>
+ <rasd:ResourceType>10</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>15</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
+ <rasd:Connection>GigabitEthernet5</rasd:Connection>
+ <rasd:Description>NIC representing GigabitEthernet5</rasd:Description>
+ <rasd:ElementName>GigabitEthernet5</rasd:ElementName>
+ <rasd:InstanceID>15</rasd:InstanceID>
+ <rasd:ResourceSubType>VMXNET3</rasd:ResourceSubType>
+ <rasd:ResourceType>10</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
""", file1=self.csr_ovf_2017)

def test_set_nic_count_named_nics_and_networks(self):
"""Add more NICs and explicitly named networks across all profiles.
Expand Down
4 changes: 3 additions & 1 deletion COT/tests/cot_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ class COTTestCase(unittest.TestCase): # noqa: N801
minimal_ovf = _localfile("minimal.ovf")
# IOSv OVF
iosv_ovf = _localfile("iosv.ovf")
# CSR1000V OVF
# CSR1000V OVF - legacy
csr_ovf = _localfile("csr1000v.ovf")
# CSR1000V OVF as of 2017
csr_ovf_2017 = _localfile("csr1000v_2017.ovf")
# v0.9 OVF
v09_ovf = _localfile("v0.9.ovf")
# v2.0 OVF from VirtualBox
Expand Down
Loading

0 comments on commit 06c0214

Please sign in to comment.