Exemplo n.º 1
0
 def download_targetservers_snapshot(self):
     for environment in self.environments:
         try:
             self.snapshot_data.targetservers[environment] = Targetservers(
                 self.auth, self.org_name, None
             ).list_targetservers_in_an_environment(
                 environment, prefix=self.prefix, format='dict'
             )
         except HTTPError:
             self.snapshot_data.targetservers[environment] = []
         data = {
             'snapshot': self.snapshot_data.targetservers[environment],
             'target_path': self._gen_snapshot_path(
                 subpaths=['targetservers', environment, 'targetservers.json']
             ),
             'fs_write': self.fs_write,
             'indent': 2,
         }
         write_file(
             data['snapshot'],
             data['target_path'],
             fs_write=data['fs_write'],
             indent=data['indent'],
         )
     return self.snapshot_data.targetservers
Exemplo n.º 2
0
 def _func(ts):
     ts_file = str(Path(self._targetservers_dir) / ts)
     if not force:
         path_exists(os.path.relpath(ts_file))
     resp = Targetservers(self._auth, self._org_name,
                          ts).get_targetserver(environment).text
     console.echo(resp, expc_verbosity=1)
     with open(ts_file, 'w') as f:
         f.write(resp)
Exemplo n.º 3
0
def _list_targetservers_in_an_environment(username,
                                          password,
                                          mfa_secret,
                                          token,
                                          zonename,
                                          org,
                                          profile,
                                          environment,
                                          prefix=None,
                                          **kwargs):
    return Targetservers(
        gen_auth(username, password, mfa_secret, token, zonename), org,
        None).list_targetservers_in_an_environment(environment, prefix=prefix)
Exemplo n.º 4
0
 def download_targetservers_snapshot(self):
     for environment in self.environments:
         self.snapshot_data.targetservers[environment] = Targetservers(
             self.auth, self.org_name, None
         ).list_targetservers_in_an_environment(environment, prefix=self.prefix, format='dict')
         write_file(
             self.snapshot_data.targetservers[environment],
             Backups.generate_download_path(
                 self.org_path,
                 is_snapshot=True,
                 subpaths=['targetservers', environment, 'targetservers.json'],
             ),
             fs_write=self.fs_write,
             indent=2,
         )
Exemplo n.º 5
0
 def download_targetservers(self):
     for environment in self.environments:
         for targetserver in self.snapshot_data.targetservers[environment]:
             try:
                 write_file(
                     Targetservers(self.auth, self.org_name, targetserver)
                     .get_targetserver(environment)
                     .text,
                     Backups.generate_download_path(
                         self.org_path,
                         subpaths=['targetservers', environment, f'{targetserver}.json'],
                     ),
                     fs_write=self.fs_write,
                 )
             except HTTPError as e:
                 Backups.log_error(e, append_msg=' for TargetServer ({targetserver})')
             self._Backups__progress_callback(desc='TargetServers')
Exemplo n.º 6
0
 def download_targetservers(self):
     for environment in self.environments:
         for targetserver in self.snapshot_data.targetservers[environment]:
             try:
                 write_file(
                     Targetservers(self.auth, self.org_name, targetserver)
                     .get_targetserver(environment)
                     .text,
                     self._gen_download_path(
                         subpaths=['targetservers', environment, f'{targetserver}.json']
                     ),
                     fs_write=self.fs_write,
                 )
             except HTTPError as e:
                 console.echo(
                     f'Ignoring {type(e).__name__} {e.response.status_code} error for TargetServer ({targetserver})'
                 )
             self._progress_callback(desc='TargetServers')
     return self.snapshot_data.targetservers
Exemplo n.º 7
0
 def download_targetservers_snapshot(self):
     for environment in self.environments:
         try:
             self.snapshot_data.targetservers[environment] = Targetservers(
                 self.auth, self.org_name, None
             ).list_targetservers_in_an_environment(
                 environment, prefix=self.prefix, format='dict'
             )
         except HTTPError:
             self.snapshot_data.targetservers[environment] = []
         write_file(
             self.snapshot_data.targetservers[environment],
             self._gen_download_path(
                 is_snapshot=True, subpaths=['targetservers', environment, 'targetservers.json']
             ),
             fs_write=self.fs_write,
             indent=2,
         )
     return self.snapshot_data.targetservers
Exemplo n.º 8
0
def _get_targetserver(username, password, mfa_secret, token, zonename, org,
                      profile, name, environment, **kwargs):
    return (Targetservers(
        gen_auth(username, password, mfa_secret, token, zonename), org,
        name).get_targetserver(environment).text)
Exemplo n.º 9
0
def _push_targetserver(username, password, mfa_secret, token, zonename, org,
                       profile, environment, file, **kwargs):
    return Targetservers(
        gen_auth(username, password, mfa_secret, token, zonename), org,
        None).push_targetserver(environment, file)