@@ -173,6 +173,61 @@ def node_info():
'sockets': raw[5]}
return info

def get_nics(vm_):
'''
Return info about the network interfaces of a named vm
CLI Example::
salt '*' virt.get_nics <vm name>
'''
nics = {}
doc = minidom.parse(StringIO.StringIO(get_xml(vm_)))
for node in doc.getElementsByTagName("devices"):
i_nodes = node.getElementsByTagName("interface")
for i_node in i_nodes:
nic = {}
nic['type'] = i_node.getAttribute('type')
for v_node in i_node.getElementsByTagName('*'):
if v_node.tagName == "mac":
nic['mac'] = v_node.getAttribute('address')
if v_node.tagName == "model":
nic['model'] = v_node.getAttribute('type')
# driver, source, and match can all have optional attributes
if re.match('(driver|source|address)', v_node.tagName):
temp = {}
for key in v_node.attributes.keys():
temp[key] = v_node.getAttribute(key)
nic[str(v_node.tagName)] = temp
# virtualport needs to be handled separately, to pick up the
# type attribute of the virtualport itself
if v_node.tagName == "virtualport":
temp = {}
temp['type'] = v_node.getAttribute('type')
for key in v_node.attributes.keys():
temp[key] = v_node.getAttribute(key)
nic['virtualport'] = temp
if 'mac' not in nic:
continue
nics[nic['mac']] = nic
return nics

def get_macs(vm_):
'''
Return a list off MAC addresses from the named vm
CLI Example::
salt '*' virt.get_macs <vm name>
'''
macs = []
doc = minidom.parse(StringIO.StringIO(get_xml(vm_)))
for node in doc.getElementsByTagName("devices"):
i_nodes = node.getElementsByTagName("interface")
for i_node in i_nodes:
for v_node in i_node.getElementsByTagName('mac'):
macs.append(v_node.getAttribute('address'))
return macs

def get_graphics(vm_):
'''
@@ -27,7 +27,6 @@ def __virtual__():
else:
return False


def _list_removed(old, new):
'''
List the packages which have been removed between the two package objects
@@ -39,7 +38,6 @@ def _list_removed(old, new):

return pkgs


def _compare_versions(old, new):
'''
Returns a dict that that displays old and new versions for a package after
@@ -61,7 +59,6 @@ def _compare_versions(old, new):
'new': new[npkg]}
return pkgs


def available_version(name):
'''
The available version of the package in the repository
@@ -96,7 +93,6 @@ def available_version(name):
# remove the duplicate items from the list and return the first one
return list(set(versions_list))[0]


def upgrade_available(name):
'''
Check whether or not an upgrade is available for a given package
@@ -105,11 +101,7 @@ def upgrade_available(name):
salt '*' pkg.upgrade_available <package name>
'''
if available_version(name):
return True
else:
return False

return available_version(name)

def version(name):
'''
@@ -125,7 +117,6 @@ def version(name):
else:
return ''


def list_pkgs(*args):
'''
List the packages currently installed in a dict::
@@ -150,7 +141,6 @@ def list_pkgs(*args):

return pkgs


def refresh_db():
'''
Since yum refreshes the database automatically, this runs a yum clean,
@@ -164,7 +154,6 @@ def refresh_db():
yb.cleanMetadata()
return True


def clean_metadata():
'''
Cleans local yum metadata.
@@ -232,7 +221,6 @@ def install(pkgs, refresh=False, repo='', skip_verify=False, **kwargs):

return _compare_versions(old, new)


def upgrade():
'''
Run a full system upgrade, a yum upgrade
@@ -263,7 +251,6 @@ def upgrade():
new = list_pkgs()
return _compare_versions(old, new)


def remove(pkgs):
'''
Removes packages with yum remove
@@ -292,7 +279,6 @@ def remove(pkgs):

return _list_removed(old, new)


def purge(pkgs):
'''
Yum does not have a purge, this function calls remove
@@ -45,8 +45,8 @@ def present(
The comment to be placed with the ssh public key
source
The source file for the key(s). Can contain any number of public keys,
in standard "authorized_keys" format. If this is set, comment, enc,
The source file for the key(s). Can contain any number of public keys,
in standard "authorized_keys" format. If this is set, comment, enc,
and options will be ignored.
options