Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Liu, Xiaopeng (133) <[email protected]>
  • Loading branch information
Liu, Xiaopeng (133) committed May 13, 2020
1 parent bc88f0d commit 40c2d1c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.1.2][]

### Changed

- Refactory: Salt API accepts eauth method as parameter in configuration

## [0.1.1][]

### Changed
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ There are two ways of doing this:
```

* or you inject the secrets explicitly to the experiment definition:
SALTMASTER_EAUTH is optional and default to pam

```json
{
"saltstack": {
"SALTMASTER_HOST": "https://172.10.20.666",
"SALTMASTER_USER": "username",
"SALTMASTER_PASSWORD": "password"
"SALTMASTER_EAUTH": "sharedsecret"
}
}
```
Expand Down
7 changes: 5 additions & 2 deletions chaossaltstack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ def __init__(self, configuration):
elif 'username' in configuration:
self.username = configuration['username']
self.password = configuration['password']
self.eauth = configuration['eauth']
# Default settings for Salt Master
self.headers = {"Content-type": "application/json"}
self.params = {'client': 'local', 'fun': '', 'tgt': ''}
# Use User/Pass
self.login_url = self.url + "/login"
self.login_params = {
'username': self.username, 'password': self.password,
'eauth': 'pam'
'eauth': self.eauth
}

def run_cmd(self, tgt, method: str, arg=None):
Expand Down Expand Up @@ -164,9 +165,10 @@ def saltstack_api_client(secrets: Secrets = None) -> salt_api_client:
* SALTMASTER_HOST: Salt Master API address
You can authenticate with user / password via:
You can authenticate with user / password / eauth via:
* SALTMASTER_USER: the user name
* SALTMASTER_PASSWORD: the password
* SALTMASTER_EAUTH: the auth method, default to pam
Or via a token:
* SALTMASTER_TOKEN
Expand Down Expand Up @@ -197,6 +199,7 @@ def lookup(k: str, d: str = None) -> str:
if "SALTMASTER_USER" in env or "SALTMASTER_USER" in secrets:
configuration['username'] = lookup("SALTMASTER_USER", "")
configuration['password'] = lookup("SALTMASTER_PASSWORD", "")
configuration['eauth'] = lookup("SALTMASTER_EAUTH", "pam")
elif "SALTMASTER_TOKEN" in env or "SALTMASTER_TOKEN" in secrets:
configuration['token'] = lookup("SALTMASTER_TOKEN")
else:
Expand Down
3 changes: 1 addition & 2 deletions chaossaltstack/machine/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def network_loss(instance_ids: List[str] = None,
param["duration"] = execution_duration
param["param"] = "loss " + loss_ratio
param["device"] = device

return __default_salt_experiment__(instance_ids=instance_ids,
execution_duration=execution_duration,
param=param,
Expand Down Expand Up @@ -253,7 +253,6 @@ def network_corruption(instance_ids: List[str] = None,
param["param"] = "corrupt " + corruption_ratio
param["device"] = device


return __default_salt_experiment__(instance_ids=instance_ids,
execution_duration=execution_duration,
param=param,
Expand Down

0 comments on commit 40c2d1c

Please sign in to comment.