Merge pull request #24543 from rallytime/fix_centos_prkrepo_test

The first arg in a state should always be name, and unfreeze name from salt/state.py
This commit is contained in:
Thomas S Hatch 2015-06-09 14:07:14 -06:00
commit dfef03f789
2 changed files with 16 additions and 16 deletions

View File

@ -66,7 +66,6 @@ STATE_REQUISITE_IN_KEYWORDS = frozenset([
'listen_in', 'listen_in',
]) ])
STATE_RUNTIME_KEYWORDS = frozenset([ STATE_RUNTIME_KEYWORDS = frozenset([
'name', # name of the highstate running
'fun', 'fun',
'state', 'state',
'check_cmd', 'check_cmd',

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
''' '''
Control concurrency of steps within state execution using zookeeper Control concurrency of steps within state execution using zookeeper
========================================================================= ===================================================================
This module allows you to "wrap" a state's execution with concurrency control. This module allows you to "wrap" a state's execution with concurrency control.
This is useful to protect against all hosts executing highstate simultaneously This is useful to protect against all hosts executing highstate simultaneously
@ -17,8 +17,8 @@ steps are executing with a single path.
acquire_lock: acquire_lock:
zk_concurrency.lock: zk_concurrency.lock:
- name: /trafficeserver
- zk_hosts: 'zookeeper:2181' - zk_hosts: 'zookeeper:2181'
- path: /trafficserver
- max_concurrency: 4 - max_concurrency: 4
- prereq: - prereq:
- service: trafficserver - service: trafficserver
@ -34,7 +34,7 @@ steps are executing with a single path.
release_lock: release_lock:
zk_concurrency.unlock: zk_concurrency.unlock:
- path: /trafficserver - name: /trafficserver
- require: - require:
- service: trafficserver - service: trafficserver
@ -48,6 +48,7 @@ REQUIRED_FUNCS = (
'zk_concurrency.unlock', 'zk_concurrency.unlock',
'zk_concurrency.party_members', 'zk_concurrency.party_members',
) )
__virtualname__ = 'zk_concurrency' __virtualname__ = 'zk_concurrency'
@ -58,7 +59,7 @@ def __virtual__():
return __virtualname__ return __virtualname__
def lock(path, def lock(name,
zk_hosts, zk_hosts,
identifier=None, identifier=None,
max_concurrency=1, max_concurrency=1,
@ -69,7 +70,7 @@ def lock(path,
Block state execution until you are able to get the lock (or hit the timeout) Block state execution until you are able to get the lock (or hit the timeout)
''' '''
ret = {'name': path, ret = {'name': name,
'changes': {}, 'changes': {},
'result': False, 'result': False,
'comment': ''} 'comment': ''}
@ -82,7 +83,7 @@ def lock(path,
if identifier is None: if identifier is None:
identifier = __grains__['id'] identifier = __grains__['id']
locked = __salt__['zk_concurrency.lock'](path, locked = __salt__['zk_concurrency.lock'](name,
zk_hosts, zk_hosts,
identifier=identifier, identifier=identifier,
max_concurrency=max_concurrency, max_concurrency=max_concurrency,
@ -97,16 +98,16 @@ def lock(path,
return ret return ret
def unlock(path, def unlock(name,
zk_hosts=None, # in case you need to unlock without having run lock (failed execution for example) zk_hosts=None, # in case you need to unlock without having run lock (failed execution for example)
identifier=None, identifier=None,
max_concurrency=1, max_concurrency=1,
ephemeral_lease=False ephemeral_lease=False
): ):
''' '''
Remove lease from semaphore Remove lease from semaphore.
''' '''
ret = {'name': path, ret = {'name': name,
'changes': {}, 'changes': {},
'result': False, 'result': False,
'comment': ''} 'comment': ''}
@ -119,7 +120,7 @@ def unlock(path,
if identifier is None: if identifier is None:
identifier = __grains__['id'] identifier = __grains__['id']
unlocked = __salt__['zk_concurrency.unlock'](path, unlocked = __salt__['zk_concurrency.unlock'](name,
zk_hosts=zk_hosts, zk_hosts=zk_hosts,
identifier=identifier, identifier=identifier,
max_concurrency=max_concurrency, max_concurrency=max_concurrency,
@ -128,23 +129,23 @@ def unlock(path,
if unlocked: if unlocked:
ret['result'] = True ret['result'] = True
else: else:
ret['comment'] = 'Unable to find lease for path {0}'.format(path) ret['comment'] = 'Unable to find lease for path {0}'.format(name)
return ret return ret
def min_party(path, def min_party(name,
zk_hosts, zk_hosts,
min_nodes, min_nodes,
): ):
''' '''
Ensure that there are `min_nodes` in the party at `path` Ensure that there are `min_nodes` in the party at `name`.
''' '''
ret = {'name': path, ret = {'name': name,
'changes': {}, 'changes': {},
'result': False, 'result': False,
'comment': ''} 'comment': ''}
nodes = __salt__['zk_concurrency.party_members'](path, zk_hosts) nodes = __salt__['zk_concurrency.party_members'](name, zk_hosts)
if not isinstance(nodes, list): if not isinstance(nodes, list):
raise Exception('Error from zk_concurrency.party_members, return was not a list: {0}'.format(nodes)) raise Exception('Error from zk_concurrency.party_members, return was not a list: {0}'.format(nodes))