Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Updated sync to always copy new images and manifests to HIDDEN repo #59

Merged
merged 1 commit into from
Jun 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions bin/dock-pulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,10 @@ def do_copy(bopts, bargs):
parser.error('You must provide a destination repository and image-id')
p = pulp_login(bopts)
for img in args[1:]:
p.copy(args[0], img, opts.source)
if opts.source:
p.copy(args[0], img, opts.source)
else:
p.copy(args[0], img)
log.info('copying successful')

def do_create(bopts, bargs):
Expand Down Expand Up @@ -860,32 +863,25 @@ def do_sync(bopts, bargs):
env = args[0]
repo = args[1]

repoinfo = p.syncRepo(env, repo, bopts.config_file)
repoinfo = repoinfo[0]

if len(repoinfo['images'].keys()) == 0:
oldimgs = []
else:
oldimgs = repoinfo['images'].keys()

repoinfo = p.listRepos(repo, True)
repoinfo = repoinfo[0]
newimgs = repoinfo['images'].keys()
imgs = list(set(newimgs) - set(oldimgs))
imgs.sort()
imgs, manifests = p.syncRepo(env, repo, bopts.config_file)

log.info(repoinfo['id'])
log.info('-' * len(repoinfo['id']))
log.info(repo)
log.info('-' * len(repo))
log.info('synced images:')

if len(imgs) == 0:
log.info(' No new images')
else:
for img in imgs:
log.info(img)
for img in imgs:
p.copy('redhat-everything', img, repo)
log.info('')
log.info('')

if len(manifests) == 0:
log.info(' No new manifests')
else:
for manifest in manifests:
log.info(manifest)
log.info('')

def do_tag(bopts, bargs):
"""
Expand Down
35 changes: 33 additions & 2 deletions dockpulp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ def syncRepo(self, env=None, repo=None, config_file=DEFAULT_CONFIG_FILE,
'feed': feed,
'upstream_name': upstream_name,
'basic_auth_username': basic_auth_username,
'basic_auth_password': basic_auth_password
'basic_auth_password': basic_auth_password,
'enabled_v1': True
}
}
else:
Expand All @@ -902,6 +903,7 @@ def syncRepo(self, env=None, repo=None, config_file=DEFAULT_CONFIG_FILE,
'ssl_validation': ssl_validation,
'feed': feed,
'upstream_name': upstream_name,
'enabled_v1': True
}
}

Expand All @@ -911,7 +913,36 @@ def syncRepo(self, env=None, repo=None, config_file=DEFAULT_CONFIG_FILE,
data=json.dumps(data))
self.watch(tid)

return repoinfo
# Need to maintain HIDDEN
repoinfo = repoinfo[0]

if len(repoinfo['images'].keys()) == 0:
oldimgs = []
else:
oldimgs = repoinfo['images'].keys()

if len(repoinfo['manifests'].keys()) == 0:
oldmanifests = []
else:
oldmanifests = repoinfo['manifests'].keys()

repoinfo = self.listRepos(repo, True)
Copy link
Collaborator

@twaugh twaugh Jun 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you already have this from line 879?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you need to do it twice to see which units are new, I see now.

repoinfo = repoinfo[0]

newimgs = repoinfo['images'].keys()
imgs = list(set(newimgs) - set(oldimgs))
imgs.sort()

newmanifests = repoinfo['manifests'].keys()
manifests = list(set(newmanifests) - set(oldmanifests))
manifests.sort()

for img in imgs:
self.copy(HIDDEN, img, repo)
for manifest in manifests:
self.copy(HIDDEN, manifest, repo)

return (imgs, manifests)

def updateRepo(self, rid, update):
"""
Expand Down