Skip to content

Commit

Permalink
Merge pull request #337 from san7ket/vmware_network
Browse files Browse the repository at this point in the history
Add methods to fetch network object and list networks for Vmware
  • Loading branch information
mshriver authored Feb 18, 2019
2 parents 3693409 + 0193d5b commit 6cf5684
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions wrapanapi/systems/virtualcenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,13 @@ def list_cluster(self):
def list_resource_pools(self):
return [str(h.name) for h in self.get_obj_list(vim.ResourcePool)]

def list_networks(self):
"""Fetch the list of network names
Returns: A list of Network names
"""
return [str(h.name) for h in self.get_obj_list(vim.Network)]

def info(self):
# NOTE: Can't find these two methods in either psphere or suds
# return '{} {}'.format(self.api.get_server_type(), self.api.get_api_version())
Expand Down Expand Up @@ -1027,3 +1034,15 @@ def usage_and_quota(self):
'cpu_total': installed_cpu,
'cpu_limit': None,
}

def get_network(self, network_name):
"""Fetch the network object from specified network name
Args:
network_name: The name of the network from Vmware
Returns: A object of vim.Network object
"""
network = self.get_obj(vimtype=vim.Network, name=network_name)
if not network:
raise NotFoundError
return network

0 comments on commit 6cf5684

Please sign in to comment.