Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 80ada95

Browse files
committed
Fix AttributeError in delete_nic
1 parent 23388db commit 80ada95

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pyvcloud/vcd/vm.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -716,13 +716,14 @@ def delete_nic(self, index):
716716
indices = [None] * 10
717717
nic_not_found = True
718718
# find the nic with the given index
719-
for nc in net_conn_section.NetworkConnection:
720-
if int(nc.NetworkConnectionIndex.text) == index:
721-
net_conn_section.remove(nc)
722-
nic_not_found = False
723-
else:
724-
indices[int(nc.NetworkConnectionIndex.
725-
text)] = nc.NetworkConnectionIndex.text
719+
if hasattr(net_conn_section, 'NetworkConnection'):
720+
for nc in net_conn_section.NetworkConnection:
721+
if int(nc.NetworkConnectionIndex.text) == index:
722+
net_conn_section.remove(nc)
723+
nic_not_found = False
724+
else:
725+
indices[int(nc.NetworkConnectionIndex.
726+
text)] = nc.NetworkConnectionIndex.text
726727

727728
if nic_not_found:
728729
raise InvalidParameterException(

0 commit comments

Comments
 (0)