Add full repo backup
Required for backup repositories in master node if there aren't
deployed environment.
Usage:
octane fuel-repo-backup --to backup_path --full
Change-Id: Ic9560edd3390f63ff015d68c0b5747351b19cf66
(cherry picked from commit c6dc22cdea
)
This commit is contained in:
parent
1c3b0b53ce
commit
4daa7a8caa
|
@ -71,3 +71,17 @@ class BackupCommand(BaseBackupCommand):
|
|||
class BackupRepoCommand(BaseBackupCommand):
|
||||
|
||||
archivators = backup_restore.REPO_ARCHIVATORS
|
||||
full_archivators = backup_restore.FULL_REPO_ARCHIVATORS
|
||||
|
||||
def get_parser(self, *args, **kwargs):
|
||||
parser = super(BackupRepoCommand, self).get_parser(*args, **kwargs)
|
||||
parser.add_argument(
|
||||
"--full",
|
||||
action='store_true',
|
||||
help="Backup all repositories")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
if parsed_args.full:
|
||||
self.archivators = self.full_archivators
|
||||
super(BackupRepoCommand, self).take_action(parsed_args)
|
||||
|
|
|
@ -46,6 +46,11 @@ REPO_ARCHIVATORS = [
|
|||
mirrors.RepoBackup,
|
||||
]
|
||||
|
||||
FULL_REPO_ARCHIVATORS = [
|
||||
mirrors.FullMirrorsBackup,
|
||||
mirrors.FullRepoBackup,
|
||||
]
|
||||
|
||||
|
||||
class NailgunCredentialsContext(object):
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import urlparse
|
|||
|
||||
from octane.handlers.backup_restore import base
|
||||
|
||||
from octane import magic_consts
|
||||
from octane.util import helpers
|
||||
from octane.util import sql
|
||||
|
||||
|
@ -64,3 +65,24 @@ class RepoBackup(NaigunWWWBackup):
|
|||
|
||||
def _get_values_list(self, data):
|
||||
return data['provision']['image_data'].values()
|
||||
|
||||
|
||||
class FullMirrorsBackup(NaigunWWWBackup):
|
||||
|
||||
name = "mirrors"
|
||||
sql = "select array_to_json(array_agg(distinct version)) from releases;"
|
||||
|
||||
def _get_mirrors(self):
|
||||
results = sql.run_psql_in_container(self.sql, self.db)
|
||||
releases = []
|
||||
for dir_name in magic_consts.MIRRORS_EXTRA_DIRS:
|
||||
if os.path.exists(os.path.join(self.path, dir_name)):
|
||||
releases.append(dir_name)
|
||||
for line in results:
|
||||
releases.extend(json.loads(line))
|
||||
return releases
|
||||
|
||||
|
||||
class FullRepoBackup(base.PathArchivator):
|
||||
name = 'repos/targetimages'
|
||||
path = '/var/www/nailgun/targetimages'
|
||||
|
|
|
@ -78,3 +78,5 @@ OSD_REPOS_UPDATE = [
|
|||
),
|
||||
]
|
||||
COBBLER_DROP_VERSION = "7.0"
|
||||
|
||||
MIRRORS_EXTRA_DIRS = ["ubuntu-full", "mos-ubuntu"]
|
||||
|
|
Loading…
Reference in New Issue