示例#1
0
 def make_container_options(
     temporary=None,
     name=None,
     user=None,
     ports=None,
     env=None,
     volumes=None,
     links=None,
     hosts=None,
     network=None,
     restart_policy=None,
     stop_signal=None,
     options=None,
 ):
     options = Options(options or ())
     options.update((
         ('name', name),
         ('user', user),
         ('publish', ports),
         ('env', env),
         ('volume', volumes),
         ('link', links),
         ('add-host', hosts),
         ('net', network),
         ('restart', restart_policy),
         ('stop-signal', stop_signal),
         ('rm', temporary),
         ('tty', temporary),
         ('detach', temporary is not None and not temporary),
     ))
     return options
示例#2
0
 def make_restore_command(self, backup_filename):
     options = Options(self.db_connection_options)
     options.update(self.db_restore_options)
     options.update([
         ('dbname', 'template1'),  # use any existing DB
         ('jobs', str(self.db_restore_workers)),
         ('file', os.path.join(self.db_backup_dir, backup_filename)),
     ])
     return 'pg_restore {options}'.format(options=options)
示例#3
0
 def make_restore_command(self, backup_filename):
     options = Options(self.db_connection_options)
     options.update(self.db_restore_options)
     options.update([
         ('dbname', 'template1'),  # use any existing DB
         ('jobs', self.db_restore_workers),
         ('file', os.path.join(self.db_backup_dir, backup_filename)),
     ])
     return 'pg_restore {options}'.format(options=options)
示例#4
0
 def make_backup_command(self):
     options = Options(self.db_connection_options)
     options.update(self.db_backup_options)
     options.update([
         ('format', self.db_backup_format),
         ('dbname', self.db_name),
         ('compress', self.db_backup_compress_level),
         ('jobs', self.db_backup_workers),
         ('file', os.path.join(
             self.db_backup_dir,
             self.db_backup_filename.format(datetime=datetime.utcnow())
         )),
     ])
     return 'pg_dump {options}'.format(options=options)
示例#5
0
 def make_backup_command(self):
     options = Options(self.db_connection_options)
     options.update(self.db_backup_options)
     options.update([
         ('format', self.db_backup_format),
         ('dbname', self.db_name),
         ('compress', self.db_backup_compress_level),
         ('jobs', self.db_backup_workers),
         ('file', os.path.join(
             self.db_backup_dir,
             self.db_backup_filename.format(datetime=datetime.utcnow())
         )),
     ])
     return 'pg_dump {options}'.format(options=options)
示例#6
0
 def make_container_options(cls, temporary=None, name=None, options=()):
     options = dict(options)
     container_options = Options()
     for remap, option in cls.container_options_mapping:
         container_options[remap] = options.pop(option, None)
     container_options.update(
         (
             ('name', name),
             ('rm', temporary),
             ('tty', temporary),
             ('interactive', temporary),
             ('detach', temporary is not None and not temporary),
         ),
         **options
     )
     if temporary:
         # temporary containers can't be restarted
         container_options['restart'] = None
     return container_options