self.host = s['host']
self.username = s.get('username', 'admin')
self.password = s['password']
- self.version = int(s.get('version', '12'))
+ self.version = s.get('version', '13.1')
self.base_url = 'https://' + self.host + '/' # This never changes
# Sanity check the numerical version.
- if self.version not in [9, 10, 11, 12]:
- msg = 'Invalid version "' + str(self.version) + '" '
+ if self.version not in ['9', '10', '11', '12', '13', '13.1']:
+ msg = 'Invalid version "' + self.version + '" '
msg += 'in section "' + s.name + '"'
raise configparser.ParsingError(msg)
Version-agnostic get-me-a-backup method. Dispatches to the
actual implementation based on ``self.version``.
"""
- if self.version == 9:
+ if self.version == '9':
return self.get_backup_v9()
- elif self.version in [10, 11, 12]:
- # The procedure for v11 or v12 is the same as for v10.
+ elif self.version in ['10', '11', '12', '13']:
+ # The procedure for v11, v12, or v13 is the same as for v10.
return self.get_backup_v10()
+ elif self.version == '13.1':
+ # But the minor update v13.1 moved the backup URL.
+ return self.get_backup_v13_1()
def get_backup_v9(self):
post_data = urllib.parse.urlencode(post_vars).encode('ascii')
with self.opener.open(url, post_data) as response:
return response.read()
+
+
+ def get_backup_v13_1(self):
+ """
+ Retrieve a backup from Untangle version 13.1. This
+ differs from v13 (and v12, and v11,...) by only one word
+ in the URL: "webui" becomes "admin".
+
+ Returns the binary HTTPS response (i.e. the file).
+ """
+ url = self.base_url + '/admin/download'
+ post_vars = {'type': 'backup'}
+ post_data = urllib.parse.urlencode(post_vars).encode('ascii')
+ with self.opener.open(url, post_data) as response:
+ return response.read()