Permalink
Browse files

Merge branch 'develop' of github.com:saltstack/salt into hotfix/pylin…

…t/C0103
  • Loading branch information...
2 parents 32171d7 + 8f04fde commit cc65301cc2a507d6004a791ddb8ac8724580f067 @s0undt3ch s0undt3ch committed Dec 30, 2012
View
@@ -41,7 +41,7 @@ load-plugins=
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
-#disable=
+disable=W0142
[REPORTS]
@@ -170,7 +170,7 @@ dummy-variables-rgx=_|dummy
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
-additional-builtins=__opts__,__salt__,__pillar__,__grains__,__context__
+additional-builtins=__opts__,__salt__,__pillar__,__grains__,__context__,__ret__
[SIMILARITIES]
View
@@ -396,6 +396,7 @@ def master_config(path):
'default_include': 'master.d/*.conf',
'win_repo': '/srv/salt/win/repo',
'win_repo_mastercachefile': '/srv/salt/win/repo/winrepo.p',
+ 'win_gitrepos': ['https://github.com/UtahDave/salt-winrepo.git'],
}
if len(opts['sock_dir']) > len(opts['cachedir']) + 10:
View
@@ -117,12 +117,14 @@ def list_pkgs():
def refresh_db():
'''
- Updates the portage tree (emerge --sync)
+ Updates the portage tree (emerge --sync). Uses eix-sync if available.
CLI Example::
salt '*' pkg.refresh_db
'''
+ if 'eix.sync' in __salt__:
+ return __salt__['eix.sync']()
return __salt__['cmd.retcode']('emerge --sync --quiet') == 0
View
@@ -0,0 +1,36 @@
+'''
+Support for Eix
+
+'''
+
+import salt.utils
+
+def __virtual__():
+ '''
+ Only work on Gentoo systems with eix installed
+ '''
+ if __grains__['os'] == 'Gentoo' and salt.utils.which('eix'):
+ return 'eix'
+ return False
+
+def sync():
+ '''
+ Sync portage/overlay trees and update the eix database
+
+ CLI Example::
+
+ salt '*' eix.sync
+ '''
+ cmd = 'eix-sync -q'
+ return __salt__['cmd.retcode'](cmd) == 0
+
+def update():
+ '''
+ Update the eix database
+
+ CLI Example::
+
+ salt '*' eix.update
+ '''
+ cmd = 'eix-update --quiet'
+ return __salt__['cmd.retcode'](cmd) == 0
View
@@ -3,6 +3,8 @@
'''
+import salt.utils
+
def __virtual__():
'''
Only work on Gentoo systems with gentoolkit installed
@@ -28,3 +30,46 @@ def revdep_rebuild(lib=None):
if lib is not None:
cmd += ' --library={0}'.format(lib)
return __salt__['cmd.retcode'](cmd) == 0
+
+def eclean_dist(destructive=False, pkg_names=False, size=None,
+ time=None, restricted=False):
+ '''
+ Clean obsolete portage sources
+
+ destructive
+ Only keep minimum for reinstallation
+
+ pkg_names
+ Protect all versions of installed packages. Only meaningful if used
+ with destructive=True
+
+ size <size>
+ Don't delete distfiles bigger than <size>.
+ <size> is a size specification: "10M" is "ten megabytes",
+ "200K" is "two hundreds kilobytes", etc. Units are: G, M, K and B.
+
+ time <time>
+ Don't delete distfiles files modified since <time>
+ <time> is an amount of time: "1y" is "one year", "2w" is
+ "two weeks", etc. Units are: y (years), m (months), w (weeks),
+ d (days) and h (hours).
+
+ restricted
+ Protect fetch-restricted files. Only meaningful if used with
+ destructive=True
+
+ CLI Example::
+ salt '*' gentoolkit.eclean_dist destructive=True
+ '''
+ cmd = 'eclean-dist --quiet'
+ if destructive:
+ cmd += ' --destructive'
+ if pkg_names:
+ cmd += ' --package-names'
+ if size is not None:
+ cmd += ' --size-limit={0}'.format(size)
+ if time is not None:
+ cmd += ' --time-limit={0}'.format(time)
+ if restricted:
+ cmd += ' --fetch-restricted'
+ return __salt__['cmd.retcode'](cmd) == 0
View
@@ -0,0 +1,86 @@
+'''
+Support for Layman
+
+'''
+
+import salt.utils
+
+def __virtual__():
+ '''
+ Only work on Gentoo systems with layman installed
+ '''
+ if __grains__['os'] == 'Gentoo' and salt.utils.which('layman'):
+ return 'layman'
+ return False
+
+def add(overlay):
+ '''
+ Add the given overlay from the caced remote list to your locally
+ installed overlays. Specify 'ALL' to add all overlays from the
+ remote list.
+
+ Return a list of the new overlay(s) added:
+
+ CLI Example::
+
+ salt '*' layman.add <overlay name>
+ '''
+ ret = list()
+ old_overlays = list_local()
+ cmd = 'layman --quietness=0 --add {0}'.format(overlay)
+ __salt__['cmd.retcode'](cmd)
+ new_overlays = list_local()
+
+ ret = [overlay for overlay in new_overlays if overlay not in old_overlays]
+ return ret
+
+
+def delete(overlay):
+ '''
+ Remove the given overlay from the your locally installed overlays.
+ Specify 'ALL' to remove all overlays.
+
+ Return a list of the overlays(s) that were removed:
+
+ CLI Example::
+
+ salt '*' layman.delete <overlay name>
+ '''
+ ret = list()
+ old_overlays = list_local()
+ cmd = 'layman --quietness=0 --delete {0}'.format(overlay)
+ __salt__['cmd.retcode'](cmd)
+ new_overlays = list_local()
+
+ ret = [overlay for overlay in old_overlays if overlay not in new_overlays]
+ return ret
+
+def sync(overlay='ALL'):
+ '''
+ Update the specified overlay. Use 'ALL' to synchronize all overlays.
+ This is the default if no overlay is specified.
+
+ overlay
+ Name of the overlay to sync. (Defaults to 'ALL')
+
+ CLI Example::
+
+ salt '*' layman.sync
+ '''
+ cmd = 'layman --quietness=0 --sync {0}'.format(overlay)
+ return __salt__['cmd.retcode'](cmd) == 0
+
+def list_local():
+ '''
+ List the locally installed overlays.
+
+ Return a list of installed overlays:
+
+ CLI Example::
+
+ salt '*' layman.list_local
+ '''
+ cmd = 'layman --quietness=1 --list-local --nocolor'
+ out = __salt__['cmd.run'](cmd).split('\n')
+ ret = [line.split()[1] for line in out]
+ return ret
View
@@ -23,7 +23,7 @@
# Import salt libs
import salt.utils
-from salt._compat import StringIO
+from salt._compat import StringIO as _StringIO
from salt.exceptions import CommandExecutionError
@@ -177,6 +177,7 @@ def _info(vm_):
'cputime': int(raw[4]),
'disks': get_disks(vm_),
'graphics': get_graphics(vm_),
+ 'nics': get_nics(vm_),
'maxMem': int(raw[1]),
'mem': int(raw[2]),
'state': VIRT_STATE_NAME_MAP.get(raw[0], 'unknown')}
@@ -189,19 +190,30 @@ def _info(vm_):
return info
-def vm_state(vm_):
+def vm_state(vm_=None):
'''
- Return the status of the named VM.
+ Return list of all the vms and their state.
+
+ If you pass a VM name in as an argument then it will return info
+ for just the named VM, otherwise it will return all VMs.
CLI Example::
salt '*' virt.vm_state <vm name>
'''
- state = ''
- dom = _get_dom(vm_)
- raw = dom.info()
- state = VIRT_STATE_NAME_MAP.get(raw[0], 'unknown')
- return state
+ def _info(vm_):
+ state = ''
+ dom = _get_dom(vm_)
+ raw = dom.info()
+ state = VIRT_STATE_NAME_MAP.get(raw[0], 'unknown')
+ return state
+ info = {}
+ if vm_:
+ info[vm_] = _info(vm_)
+ else:
+ for vm_ in list_vms():
+ info[vm_] = _info(vm_)
+ return info
def node_info():
@@ -234,7 +246,7 @@ def get_nics(vm_):
salt '*' virt.get_nics <vm name>
'''
nics = {}
- doc = minidom.parse(StringIO(get_xml(vm_)))
+ doc = minidom.parse(_StringIO(get_xml(vm_)))
for node in doc.getElementsByTagName("devices"):
i_nodes = node.getElementsByTagName("interface")
for i_node in i_nodes:
@@ -274,7 +286,7 @@ def get_macs(vm_):
salt '*' virt.get_macs <vm name>
'''
macs = []
- doc = minidom.parse(StringIO(get_xml(vm_)))
+ doc = minidom.parse(_StringIO(get_xml(vm_)))
for node in doc.getElementsByTagName("devices"):
i_nodes = node.getElementsByTagName("interface")
for i_node in i_nodes:
@@ -297,7 +309,7 @@ def get_graphics(vm_):
'port': 'None',
'type': 'vnc'}
xml = get_xml(vm_)
- ssock = StringIO(xml)
+ ssock = _StringIO(xml)
doc = minidom.parse(ssock)
for node in doc.getElementsByTagName("domain"):
g_nodes = node.getElementsByTagName("graphics")
@@ -316,7 +328,7 @@ def get_disks(vm_):
salt '*' virt.get_disks <vm name>
'''
disks = {}
- doc = minidom.parse(StringIO(get_xml(vm_)))
+ doc = minidom.parse(_StringIO(get_xml(vm_)))
for elem in doc.getElementsByTagName('disk'):
sources = elem.getElementsByTagName('source')
targets = elem.getElementsByTagName('target')
Oops, something went wrong.

0 comments on commit cc65301

Please sign in to comment.