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

Add method delete_all_nics to vm.py #788

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pyvcloud/vcd/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,24 @@ def delete_nic(self, index):
net_conn_section, RelationType.EDIT,
EntityType.NETWORK_CONNECTION_SECTION.value, net_conn_section)

def delete_all_nics(self):
"""Deletes all nics from the VM.

:return: an object containing EntityType.TASK XML data which represents
the asynchronous task deleting all nics.

:rtype: lxml.objectify.ObjectifiedElement
"""
# get network connection section.
net_conn_section = self.get_resource().NetworkConnectionSection

if hasattr(net_conn_section, 'NetworkConnection'):
for nc in net_conn_section.NetworkConnection:
net_conn_section.remove(nc)
return self.client.put_linked_resource(
net_conn_section, RelationType.EDIT,
EntityType.NETWORK_CONNECTION_SECTION.value, net_conn_section)

def install_vmware_tools(self):
"""Install vmware tools in the vm.

Expand Down