Skip to content

Commit

Permalink
Merge pull request #479 from mykaul/remove_mark_used
Browse files Browse the repository at this point in the history
Remove the whole marking of usage of templates
  • Loading branch information
ovirt-infra authored Mar 20, 2017
2 parents 2ab669f + e3f968d commit 4cf0197
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 57 deletions.
1 change: 0 additions & 1 deletion lago/prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,6 @@ def _handle_lago_template(
)
template_store.download(template_version)

template_store.mark_used(template_version, self.paths.uuid())
disk_metadata.update(
template_store.get_stored_metadata(template_version, ),
)
Expand Down
56 changes: 0 additions & 56 deletions lago/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import os
import posixpath
import shutil
import time
import urllib
import sys

Expand Down Expand Up @@ -684,28 +683,6 @@ def download(self, temp_ver, store_metadata=True):
if result:
raise RuntimeError(result.err)

self._init_users(temp_ver)

def _init_users(self, temp_ver):
"""
Initializes the user access registry
Args:
temp_ver (TemplateVersion): template version to update registry
for
Returns:
None
"""
with open('%s.users' % self.get_path(temp_ver), 'w') as f:
utils.json_dump(
{
'users': {},
'last_access': int(time.time()),
},
f,
)

def get_stored_metadata(self, temp_ver):
"""
Retrieves the metadata for the given template version from the store
Expand Down Expand Up @@ -733,36 +710,3 @@ def get_stored_hash(self, temp_ver):
"""
with open(self._prefixed('%s.hash' % temp_ver.name)) as f:
return f.read().strip()

def mark_used(self, temp_ver, key_path):
"""
Adds or updates the user entry in the user access log for the given
template version
Args:
temp_ver (TemplateVersion): template version to add the entry for
key_path (str): Path to the prefix uuid file to set the mark for
"""
dest = self.get_path(temp_ver)

with lockfile.LockFile(dest):
with open('%s.users' % dest) as f:
users = json.load(f)

updated_users = {}
for path, key in users['users'].items():
try:
with open(path) as f:
if key == f.read():
updated_users[path] = key
except OSError:
pass
except IOError:
pass

with open(key_path) as f:
updated_users[key_path] = f.read()
users['users'] = updated_users
users['last_access'] = int(time.time())
with open('%s.users' % dest, 'w') as f:
utils.json_dump(users, f)

0 comments on commit 4cf0197

Please sign in to comment.