Created
February 20, 2016 04:15
-
-
Save fracai/cbb61974a04ac4f1e7d5 to your computer and use it in GitHub Desktop.
A short script using the FreeNAS API to cycle the AFP service off and back on. Just replace your root password and hostname in the script.
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
#!/usr/bin/env python | |
import requests, json, time | |
password='root_password' | |
host='freenas_hostname' | |
login = ('root', password) | |
headers = {'Content-Type': "application/json"} | |
url = 'http://'+host+'/api/v1.0/services/services/afp/' | |
result = requests.put( | |
url, | |
headers=headers, | |
auth=login, | |
data=json.dumps({'srv_enable': 'False'}) | |
) | |
print result.json() | |
time.sleep(1) | |
result = requests.put( | |
url, | |
headers=headers, | |
auth=login, | |
data=json.dumps({'srv_enable': 'True'}) | |
) | |
print result.json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment