Updated the documentation for the network APIs in libvirtworker.

This commit is contained in:
Darryl L. Pierce 2011-05-26 14:37:16 -04:00 committed by Cole Robinson
parent 3c068b9971
commit 83c25e6ad4
1 changed files with 25 additions and 4 deletions

View File

@ -157,27 +157,48 @@ class LibvirtWorker:
virtmachine.migrate(target_conn, libvirt.VIR_MIGRATE_LIVE, None, None, 0)
def list_networks(self, defined = True, started = True):
'''Lists all networks.'''
'''Lists all networks that meet the given criteria.
Keyword arguments:
defined -- Include defined, but not started, networks. (default True)
started -- Include only started networks. (default True)
'''
result = []
if defined: result.extend(self.__conn.listDefinedNetworks())
if started: result.extend(self.__conn.listNetworks())
return result
def get_network(self, name):
'''Returns the specified network.'''
'''Returns the specified network. Raises an exception if the netowrk does not exist.
Keyword arguments:
name -- the name of the network
'''
result = self.__conn.networkLookupByName(name)
if result is None: raise Exception("No such network exists: %s" % name)
return result
def network_exists(self, name):
'''Returns if a network with the given name already exists.'''
'''Returns True if the specified network exists.
Keyword arguments:
name -- the name of the network
'''
networks = self.list_networks()
if name in networks: return True
return False
def define_network(self, config):
'''Defines a new network.'''
'''Defines a new network.
Keyword arguments:
config -- the network descriptor
'''
# since there's no other way currently, we'll have to use XML
name = config.get_name()
ip = config.get_ipv4_address_raw()