Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 834858 Details for
Bug 696641
Provide way how to put files into recipes
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
beah.patch
beah.patch (text/plain), 6.23 KB, created by
Pavel Holica
on 2013-12-10 16:46:28 UTC
(
hide
)
Description:
beah.patch
Filename:
MIME Type:
Creator:
Pavel Holica
Created:
2013-12-10 16:46:28 UTC
Size:
6.23 KB
patch
obsolete
>diff --git a/beah/backends/beakerlc.py b/beah/backends/beakerlc.py >index f3451d6..65e4675 100644 >--- a/beah/backends/beakerlc.py >+++ b/beah/backends/beakerlc.py >@@ -59,6 +59,13 @@ import base64 > import hashlib > import simplejson as json > import logging >+import tempfile >+import zlib >+import tarfile >+import pwd, grp >+import selinux >+import subprocess >+import cStringIO > from xml.dom import minidom > try: > set >@@ -155,6 +162,9 @@ else > exit > fi > fi >+# update test from task files >+mv $TEST_UPDATESDIR/* $TESTPATH >+rmdir $TEST_UPDATESDIR > # This is a workaround for /distribution/reservesys test: > touch /mnt/tests/runtests.sh > chmod a+x /mnt/tests/runtests.sh >@@ -193,6 +203,11 @@ def xml_first_node(node, tag): > return n > return None > >+def xml_cdata(node, tag, default=''): >+ try: >+ return '\n'.join([ n.data for n in xml_first_node(node, tag).childNodes if n.nodeType == n.CDATA_SECTION_NODE]) >+ except: >+ return default > > def find_recipe(node, recipe_id): > for er in node.getElementsByTagName('recipe'): >@@ -203,6 +218,81 @@ def find_recipe(node, recipe_id): > return er > return None > >+def extract_file(file_info, taskfile_dir, update_dir): >+ destination_dir = taskfile_dir >+ if file_info['update']: >+ if file_info['name'].startswith('/'): >+ destination_dir = '' >+ else: >+ destination_dir = update_dir >+ # don't allow updates for files without update >+ elif file_info['name'].startswith('/'): >+ file_info['name'].lstrip('/') >+ file_path = os.path.join(destination_dir, file_info['name']) >+ final_destination = os.path.dirname(file_path) >+ try: >+ os.makedirs(final_destination) >+ except OSError: >+ pass >+ data = file_info['data'] >+ if file_info['encoding']: >+ for encoding in file_info['encoding'].split('/'): >+ if encoding == 'base64': >+ data = base64.b64decode(data) >+ elif encoding == 'gz': >+ data = zlib.decompress(data, 16+zlib.MAX_WBITS) >+ else: >+ return None >+ if file_info['type'] in ('text/plain', 'application/octet-stream'): >+ f = open(file_path, 'w') >+ f.write(data) >+ f.close() >+ elif file_info['type'] == 'application/x-tar': >+ try: >+ os.makedirs(file_path) >+ except OSError: >+ pass >+ tar_data = cStringIO.StringIO(data) >+ tar = tarfile.open(fileobj=tar_data) >+ for member in tar.getmembers(): >+ tar.extract(member, file_path) >+ else: >+ return None >+ if file_info['acl']: >+ acl = file_info['acl'] >+ subprocess.Popen(['setfacl', '-M-', file_path], >+ stdin=subprocess.PIPE).communicate(input=acl) >+ if file_info['attrs']: >+ for attr in file_info['attrs'].split(';'): >+ key = attr >+ if '=' in attr: >+ (key,value) = attr.split('=', 1) >+ if key == 'mode': >+ try: >+ os.chmod(file_path, int(value, 8)) >+ except: >+ continue >+ elif key == 'owner': >+ try: >+ uid = int(value) >+ except ValueError: >+ uid = pwd.getpwnam(value)[2] >+ except: >+ continue >+ os.chown(file_path, uid, -1) >+ elif key == 'group': >+ try: >+ gid = int(value) >+ except ValueError: >+ gid = grp.getgrnam(value)[2] >+ except: >+ continue >+ os.chown(file_path, -1, gid) >+ elif key == 'selinux': >+ selinux.setfilecon(file_path, value) >+ if not file_info['update']: >+ return file_path >+ return None > > class RecipeException(Exception): > pass >@@ -396,6 +486,21 @@ class TaskParser(object): > answ[xml_attr(p, 'name')]=xml_attr(p, 'value') > return answ > >+ def get_files(self): >+ files = [] >+ for f in self.task_node.getElementsByTagName('file'): >+ file = { >+ 'name' : xml_attr(f, 'name'), >+ 'update' : xml_attr(f, 'update', 'False') == 'True', >+ 'type' : xml_attr(f, 'type', 'text/plain'), >+ 'encoding' : xml_attr(f, 'encoding', 'none'), >+ 'attrs' : xml_attr(f, 'attrs'), >+ 'acl' : xml_cdata(f, 'acl'), >+ 'data' : xml_cdata(f, 'data'), >+ } >+ files.append(file) >+ return files >+ > def parse(self): > > if not self._env: >@@ -415,6 +520,8 @@ class TaskParser(object): > > self._env.update(self.get_params()) > >+ self.files = self.get_files() >+ > if self._env.has_key('TESTORDER'): > self._env['TESTORDER'] = str(8*int(self._env['TESTORDER']) + 4) > else: >@@ -445,7 +552,7 @@ class TaskParser(object): > def task_data(self): > if self.parse(): > return dict(task_env=self.get_env(), executable=self.executable, >- args=self.args, ewd=self.ewd) >+ args=self.args, ewd=self.ewd, task_files=self.files) > else: > return None > >@@ -570,6 +677,18 @@ def run_task(runtime, check_task=None, get_roles=None, env_overrides=None): > all_members.update(hostnames) > task_data['task_env']['RECIPE_MEMBERS'] = ' '.join(all_members) > log.debug("about to run task(task=%s, task_data=%s)", parsed_task, task_data) >+ # task files >+ taskfiles_dir = tempfile.mkdtemp() >+ update_dir = tempfile.mkdtemp() >+ file_paths = [] >+ for file_info in task_data['task_files']: >+ file_path = extract_file(file_info, taskfiles_dir, update_dir) >+ if file_path != None: >+ file_paths.append(file_path) >+ if len(file_paths) > 0: >+ task_data['task_env'].update({'TESTFILES' : ','.join(file_paths)}) >+ task_data['task_env'].update({'TEST_UPDATESDIR' : update_dir}) >+ # environment overrides > if env_overrides: > task_data['task_env'].update(env_overrides) > # get run cmd:
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 696641
:
834853
|
834854
|
834855
|
834856
|
834857
| 834858