-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
two new example scripts to get and set the agents configuration
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Get the sysdig cloud agents configuration as a json file and print it on the screen. | ||
# Agents configuration settings can be managed in a centralized way through the API | ||
# This script downloads the settings and its result can be edited and the used from | ||
# the set_agents_config script. | ||
# | ||
|
||
import os | ||
import sys | ||
import json | ||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..')) | ||
from sdcclient import SdcClient | ||
|
||
# | ||
# Parse arguments | ||
# | ||
if len(sys.argv) != 2: | ||
print 'usage: %s <sysdig-token>' % sys.argv[0] | ||
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user' | ||
sys.exit(1) | ||
|
||
sdc_token = sys.argv[1] | ||
|
||
# | ||
# Instantiate the SDC client | ||
# | ||
sdclient = SdcClient(sdc_token, 'https://app-staging.sysdigcloud.com') | ||
|
||
# | ||
# Get the configuration | ||
# | ||
res = sdclient.get_agents_config() | ||
|
||
# | ||
# Return the result | ||
# | ||
if res[0]: | ||
print json.dumps(res[1], indent=2) | ||
else: | ||
print res[1] |
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,48 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Set the sysdig cloud agents configuration. | ||
# This script takes a user token and a json file as input, and pushes the configuration | ||
# in the json file to the user. | ||
# Typically, you want to create the json file by using the get_agents_config.py script, | ||
# edit it and then push it back with this script. | ||
# | ||
|
||
import os | ||
import sys | ||
import json | ||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..')) | ||
from sdcclient import SdcClient | ||
|
||
# | ||
# Parse arguments | ||
# | ||
if len(sys.argv) != 3: | ||
print 'usage: %s <sysdig-token> <config-json-file>' % sys.argv[0] | ||
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user' | ||
sys.exit(1) | ||
|
||
sdc_token = sys.argv[1] | ||
|
||
# | ||
# Load the config file | ||
# | ||
with open(sys.argv[2]) as cfile: | ||
conf = json.load(cfile) | ||
|
||
# | ||
# Instantiate the SDC client | ||
# | ||
sdclient = SdcClient(sdc_token, 'https://app-staging.sysdigcloud.com') | ||
|
||
# | ||
# Push the configuration | ||
# | ||
res = sdclient.set_agents_config(conf) | ||
|
||
# | ||
# Check if everything went well | ||
# | ||
if res[0]: | ||
print 'configuration set successfully' | ||
else: | ||
print res[1] |