def save_updated_config(self, save_config_locally=False, dry_run=False): config_before = prettify(self.__initial_config) config_after = prettify(self.config) if save_config_locally: open('config-before.xml', 'w').write(config_before.encode('utf-8')) open('config-after.xml', 'w').write(config_after.encode('utf-8')) def has_kdiff3(): try: return subprocess.call(["kdiff3", "-version"]) == 0 except: return False if dry_run and config_before != config_after and has_kdiff3(): subprocess.call(["kdiff3", "config-before.xml", "config-after.xml"]) data = { 'xmlFile': self.config, 'md5': self._initial_md5 } if not dry_run and config_before != config_after: headers = { "Confirm": "true", } self.__host_rest_client.post('/go/admin/restful/configuration/file/POST/xml', data, headers) self.__set_initial_config_xml()
def save_updated_config(self, save_config_locally=False, dry_run=False): config_before = prettify(self.__initial_config) config_after = prettify(self.config) if save_config_locally: open('config-before.xml', 'w').write(config_before) open('config-after.xml', 'w').write(config_after) def has_kdiff3(): try: return subprocess.call(["kdiff3", "-version"]) == 0 except: return False if dry_run and config_before != config_after and has_kdiff3(): subprocess.call(["kdiff3", "config-before.xml", "config-after.xml"]) data = { 'xmlFile': self.config, 'md5': self._initial_md5 } if not dry_run and config_before != config_after: headers = { "Confirm": "true", } if self.__host_rest_client.access_token is not None: headers["Authorization"] = "Bearer %s" % self.__host_rest_client.access_token self.__host_rest_client.post('/go/api/admin/config.xml', data, headers) self.__set_initial_config_xml()
def save_updated_config(self, save_config_locally=False, dry_run=False): config_before = prettify(self.__initial_config) config_after = prettify(self.config) if save_config_locally: open('config-before.xml', 'w').write(config_before.encode('utf-8')) open('config-after.xml', 'w').write(config_after.encode('utf-8')) def has_kdiff3(): try: return subprocess.call(["kdiff3", "-version"]) == 0 except: return False if dry_run and config_before != config_after and has_kdiff3(): subprocess.call(["kdiff3", "config-before.xml", "config-after.xml"]) data = { 'xmlFile': self.config, 'md5': self._initial_md5 } if not dry_run and config_before != config_after: self.__host_rest_client.post('/go/admin/restful/configuration/file/POST/xml', data) self.__set_initial_config_xml()
def has_changes(self): return prettify(self.__initial_config) != prettify(self.config)