-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from napalm-automation/develop
Release 0.0.6
- Loading branch information
Showing
205 changed files
with
9,913 additions
and
885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,8 @@ services: | |
- docker | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- sshpass | ||
apt_packages: | ||
- pandoc | ||
|
||
language: python | ||
python: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.PHONY: start_nsot | ||
start_nsot: | ||
docker run -v $(PWD)/tests/inventory_data/nsot/nsot.sqlite3:/nsot.sqlite3 -p 8990:8990 -d --name=nsot nsot/nsot start --noinput | ||
|
||
.PHONY: stop_nsot | ||
stop_nsot: | ||
docker rm -f nsot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Brigade | ||
======= | ||
|
||
See [docs](https://brigade.readthedocs.io) and [demo/get_facts_simple.py](demo/get_facts_simple.py), [demo/get_facts_role.py](demo/get_facts_role.py), and [demo/configure.py](demo/configure.py). | ||
See [docs](https://brigade.readthedocs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import pkg_resources | ||
|
||
try: | ||
__version__ = pkg_resources.get_distribution('brigade').version | ||
except pkg_resources.DistributionNotFound: | ||
__version__ = "Not installed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import ast | ||
import os | ||
|
||
|
||
import yaml | ||
|
||
|
||
CONF = { | ||
'num_workers': { | ||
'description': 'Number of Brigade worker processes that are run at the same time, ' | ||
'configuration can be overridden on individual tasks by using the ' | ||
'`num_workers` argument to (:obj:`brigade.core.Brigade.run`)', | ||
'type': 'int', | ||
'default': 20, | ||
}, | ||
'raise_on_error': { | ||
'description': "If set to ``True``, (:obj:`brigade.core.Brigade.run`) method of will raise " | ||
"an exception if at least a host failed.", | ||
'type': 'bool', | ||
'default': True, | ||
}, | ||
'ssh_config_file': { | ||
'description': 'User ssh_config_file', | ||
'type': 'str', | ||
'default': os.path.join(os.path.expanduser("~"), ".ssh", "config"), | ||
'default_doc': '~/.ssh/config' | ||
}, | ||
} | ||
|
||
types = { | ||
'int': int, | ||
'str': str, | ||
} | ||
|
||
|
||
class Config: | ||
""" | ||
This object handles the configuration of Brigade. | ||
Arguments: | ||
config_file(``str``): Yaml configuration file. | ||
""" | ||
|
||
def __init__(self, config_file=None, **kwargs): | ||
|
||
if config_file: | ||
with open(config_file, 'r') as f: | ||
c = yaml.load(f.read()) | ||
else: | ||
c = {} | ||
|
||
self._assign_properties(c) | ||
|
||
for k, v in kwargs.items(): | ||
setattr(self, k, v) | ||
|
||
def _assign_properties(self, c): | ||
|
||
for p in CONF: | ||
env = CONF[p].get('env') or 'BRIGADE_' + p.upper() | ||
v = os.environ.get(env) or c.get(p) | ||
v = v if v is not None else CONF[p]['default'] | ||
if CONF[p]['type'] == 'bool': | ||
v = ast.literal_eval(str(v).title()) | ||
else: | ||
v = types[CONF[p]['type']](v) | ||
setattr(self, p, v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.