irTwit
Dabbler
- Joined
- Aug 18, 2014
- Messages
- 48
My experience with the API and python is a few hours, there is a good chance I may be at fault.
Enabling and disabling a replication task through the web interface doesn't clear the hostname and SSH key but using the API update does.
http://api.freenas.org/resources/storage.html#id9
Build: FreeNAS-9.3-STABLE-201511040813
Hardware: ASRock C226WS | Intel Xeon E3-1275 v3 | KINGSTON 32GB ECC DDR3 RAM | SAS9211-8i | 2x WD Red 2TB, 2x Hitachi Deskstar 5K3000 2TB | Raidz2
I have one dummy replication task configured and can get that with the python script below.
I then try to update the task through the API as shown in the documentation.
For some reason "repl_remote_cipher" is required.
Cipher was already set. Ok, now again with "repl_remote_cipher".
Task is now enabled ("repl_enabled": true) as shown in the result above and in the web interface but the hostname and key are gone.
Is this a bug or am I executing this wrong?
Also the API documentation lists repl_remote_cipher as boolean.
Enabling and disabling a replication task through the web interface doesn't clear the hostname and SSH key but using the API update does.
http://api.freenas.org/resources/storage.html#id9
Build: FreeNAS-9.3-STABLE-201511040813
Hardware: ASRock C226WS | Intel Xeon E3-1275 v3 | KINGSTON 32GB ECC DDR3 RAM | SAS9211-8i | 2x WD Red 2TB, 2x Hitachi Deskstar 5K3000 2TB | Raidz2
I have one dummy replication task configured and can get that with the python script below.
Code:
CODE:
print requests.get(
'http://nas/api/v1.0/storage/replication/',
auth=('root', 'password'),
headers={'Content-Type': 'application/json'}
).text
RESULT:
{
"id": 1,
"repl_begin": "00:00:00",
"repl_compression": "lz4",
"repl_enabled": false,
"repl_end": "23:59:00",
"repl_filesystem": "pond/public",
"repl_followdelete": false,
"repl_lastsnapshot": "",
"repl_limit": 0,
"repl_remote_cipher": "standard",
"repl_remote_dedicateduser": null,
"repl_remote_dedicateduser_enabled": false,
"repl_remote_hostkey": "127.0.0.1 KEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKE",
"repl_remote_hostname": "127.0.0.1",
"repl_remote_port": 22,
"repl_status": "Failed: cannot open 'ExtBackup_01/public': dataset does not exist\n",
"repl_userepl": false,
"repl_zfs": "ExtBackup_01"
}I then try to update the task through the API as shown in the documentation.
Code:
CODE:
print requests.put('http://nas/api/v1.0/storage/replication/1/',
auth=('root', 'password'),
data=json.dumps({"repl_enabled":"true"}),
headers={'Content-Type': 'application/json'}
).text
RESULT:
{"repl_remote_cipher": ["This field is required."]}For some reason "repl_remote_cipher" is required.
Code:
CODE:
print requests.put('http://nas/api/v1.0/storage/replication/1/',
auth=('root', 'password'),
data=json.dumps({"repl_enabled":"true","repl_remote_cipher":"standard"}),
headers={'Content-Type': 'application/json'}
).text
RESULT:
{
"id": 1,
"pk": "1",
"repl_begin": "00:00:00",
"repl_compression": "lz4",
"repl_enabled": true,
"repl_end": "23:59:00",
"repl_filesystem": "pond/public",
"repl_followdelete": false,
"repl_lastsnapshot": "",
"repl_limit": 0,
"repl_remote_cipher": "standard",
"repl_remote_dedicateduser": null,
"repl_remote_dedicateduser_enabled": false,
"repl_remote_hostkey": "",
"repl_remote_hostname": "",
"repl_remote_port": 22,
"repl_status": "Failed: cannot open 'ExtBackup_01/public': dataset does not exist\n",
"repl_userepl": false,
"repl_zfs": "ExtBackup_01"
}Task is now enabled ("repl_enabled": true) as shown in the result above and in the web interface but the hostname and key are gone.
Is this a bug or am I executing this wrong?
Also the API documentation lists repl_remote_cipher as boolean.
- repl_remote_cipher (boolean) – encryption cipher to use (standard, fast, disabled)