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 834853 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]
beaker.patch
beaker.patch (text/plain), 12.47 KB, created by
Pavel Holica
on 2013-12-10 16:38:24 UTC
(
hide
)
Description:
beaker.patch
Filename:
MIME Type:
Creator:
Pavel Holica
Created:
2013-12-10 16:38:24 UTC
Size:
12.47 KB
patch
obsolete
>diff --git a/Common/bkr/common/schema/beaker-job.rng b/Common/bkr/common/schema/beaker-job.rng >index 9a393e6..b234d78 100644 >--- a/Common/bkr/common/schema/beaker-job.rng >+++ b/Common/bkr/common/schema/beaker-job.rng >@@ -380,6 +380,88 @@ > </zeroOrMore> > </element> > </optional> >+ <optional> >+ <element name="files"> >+ <zeroOrMore> >+ <element name="file"> >+ <a:documentation xml:lang="en"> >+ File can be given to task as parameter. Such files will be >+ created and paths to those files are available in TESTFILES >+ environmet variable, where paths are in comma separated list. >+ Another way to use file is for temporary update test or file >+ (more information in update parameter). >+ </a:documentation> >+ <attribute name="name"/> >+ <optional> >+ <attribute name="update"> >+ <a:documentation xml:lang="en"> >+ When True, and name is absolute path, file is created on >+ location specified by name, when name is relative path, file >+ is created in directory where test is located. >+ </a:documentation> >+ <choice> >+ <value>True</value> >+ <value>False</value> >+ </choice> >+ </attribute> >+ </optional> >+ <optional> >+ <attribute name="type"> >+ <a:documentation xml:lang="en"> >+ Mime type of file telling harness to additionaly process >+ file. text/plain and application/octet-stream leave file as >+ is. application/x-tar takes file and untars it's content to >+ directory specified by name. For more accepted types, >+ consult with harness used to run recipe. >+ </a:documentation> >+ </attribute> >+ </optional> >+ <optional> >+ <attribute name="encoding"> >+ <a:documentation xml:lang="en"> >+ Encoding used for file content. Slash separated list of >+ used encodings for data. eg. base64/gz means that data were >+ gzipped and then encoded by base64. It basicly tells harness >+ order of decoding to get final file content. >+ </a:documentation> >+ </attribute> >+ </optional> >+ <optional> >+ <attribute name="attrs"> >+ <a:documentation xml:lang="en"> >+ Semicolon separated list of pairs: key1=value1;key2=value2 >+ specifying file attributes that should be applied on file. >+ Such attrs may be: mode - octal number of file permissions, >+ owner - uid or username of owner, group - gid or group name, >+ selinux - selinux label. For more attrs, consult with >+ harness used to run recipe. >+ </a:documentation> >+ </attribute> >+ </optional> >+ <interleave> >+ <optional> >+ <element name="acl"> >+ <a:documentation xml:lang="en"> >+ Acl used by setfacl -M option to apply acl on file(s). >+ </a:documentation> >+ <text /> >+ </element> >+ </optional> >+ <element name="data"> >+ <a:documentation xml:lang="en"> >+ Data of file. Due to XML nature, use only unicode >+ characters for data. If you need to pass binary file, use >+ base64 encoding together with encoding file parameter. When >+ you need to pass directory with data, use gzipped tar, and >+ set encoding and type parameters with corresponding values. >+ </a:documentation> >+ <text /> >+ </element> >+ </interleave> >+ </element> >+ </zeroOrMore> >+ </element> >+ </optional> > </element> > </define> > <define name="distroreq"> >diff --git a/Server/bkr/server/jobs.py b/Server/bkr/server/jobs.py >index 04384da..a78d09c 100644 >--- a/Server/bkr/server/jobs.py >+++ b/Server/bkr/server/jobs.py >@@ -17,6 +17,7 @@ > # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > from turbogears.database import session > from turbogears import expose, flash, widgets, validate, validators, redirect, paginate, url >+from turbogears.config import get > from cherrypy import response > from formencode.api import Invalid > from sqlalchemy import and_ >@@ -41,9 +42,9 @@ > TaskPriority, User, Group, MachineRecipe, > DistroTree, TaskPackage, RecipeRepo, > RecipeKSAppend, Task, Product, GuestRecipe, >- RecipeTask, RecipeTaskParam, RecipeSetResponse, >- Response, StaleTaskStatusException, >- RecipeSetActivity) >+ RecipeTask, RecipeTaskParam, RecipeTaskFile, >+ RecipeSetResponse, Response, >+ StaleTaskStatusException, RecipeSetActivity) > > from bkr.common.bexceptions import BeakerException, BX > >@@ -571,6 +572,7 @@ def _job_search(self,task,**kw): > return job_search.return_results() > > def handleRecipe(self, xmlrecipe, user, guest=False, ignore_missing_tasks=False): >+ taskfile_maxsize = int(get('beaker.task.file.maxsize', 0)) > if not guest: > recipe = MachineRecipe(ttasks=0) > for xmlguest in xmlrecipe.iter_guests(): >@@ -633,6 +635,18 @@ def handleRecipe(self, xmlrecipe, user, guest=False, ignore_missing_tasks=False) > param = RecipeTaskParam( name=xmlparam.name, > value=xmlparam.value) > recipetask.params.append(param) >+ for xmlfile in xmltask.iter_files(): >+ if len(xmlfile.data) > taskfile_maxsize: >+ raise BX(_("Task file too large, size: %d, max: %d") % >+ (len(xmlfile.data), taskfile_maxsize)) >+ file = RecipeTaskFile( name=xmlfile.name, >+ update=xmlfile.update, >+ type=xmlfile.type, >+ encoding=xmlfile.encoding, >+ attrs=xmlfile.attrs, >+ acl=xmlfile.acl, >+ data=xmlfile.data) >+ recipetask.files.append(file) > recipe.tasks.append(recipetask) > if not recipe.tasks: > raise BX(_('No Tasks! You can not have a recipe with no tasks!')) >diff --git a/Server/bkr/server/jobxml.py b/Server/bkr/server/jobxml.py >index c3dc3a1..8397305 100644 >--- a/Server/bkr/server/jobxml.py >+++ b/Server/bkr/server/jobxml.py >@@ -216,6 +216,11 @@ def iter_params(self): > for param in params['param':]: > yield XmlParam(param) > >+ def iter_files(self): >+ for files in self.wrappedEl['files':]: >+ for file in files['file':]: >+ yield XmlFile(file) >+ > def __getattr__(self, attrname): > if attrname == 'role': > return self.get_xml_attr('role', unicode, u'None') >@@ -279,6 +284,30 @@ def __getattr__(self, attrname): > return self.get_xml_attr('value', unicode, u'None') > else: raise AttributeError, attrname > >+class XmlFile(ElementWrapper): >+ def __getattr__(self, attrname): >+ if attrname == 'name': >+ return self.get_xml_attr('name', unicode, None) >+ elif attrname == 'update': >+ return self.get_xml_attr('update', unicode, 'False') != 'False' >+ elif attrname == 'type': >+ return self.get_xml_attr('type', unicode, u'text/plain') >+ elif attrname == 'encoding': >+ return self.get_xml_attr('encoding', unicode, None) >+ elif attrname == 'attrs': >+ return self.get_xml_attr('attrs', unicode, None) >+ elif attrname == 'data': >+ try: >+ return u''.join([t for t in self.wrappedEl['data']]) >+ except Exception: >+ return None >+ elif attrname == 'acl': >+ try: >+ return u''.join([t for t in self.wrappedEl['acl']]) >+ except Exception: >+ return None >+ else: raise AttributeError, attrname >+ > class XmlRpm(ElementWrapper): > def __getattr__(self, attrname): > if attrname == 'name': >@@ -313,8 +342,20 @@ def __getattr__(self, attrname): > for task in guest.iter_tasks(): > for params in task.iter_params(): > print "%s = %s" % (params.name, params.value) >+ for file in task.iter_files(): >+ print "File: %s" % (file.name) >+ print "Data:" >+ print file.data >+ print "EOF" >+ print > print "%s %s" % (task.role, task.name) > for task in recipe.iter_tasks(): > for params in task.iter_params(): > print "%s = %s" % (params.name, params.value) >+ for file in task.iter_files(): >+ print "File: %s" % (file.name) >+ print "Data:" >+ print file.data >+ print "EOF" >+ print > print "%s %s" % (task.role, task.name) >diff --git a/Server/bkr/server/model.py b/Server/bkr/server/model.py >index 1c453cf..0a53a0a 100644 >--- a/Server/bkr/server/model.py >+++ b/Server/bkr/server/model.py >@@ -1283,6 +1283,20 @@ def node(element, value): > mysql_engine='InnoDB', > ) > >+recipe_task_file_table = Table('recipe_task_file', metadata, >+ Column('id', Integer, primary_key=True), >+ Column('recipe_task_id', Integer, >+ ForeignKey('recipe_task.id')), >+ Column('name',Unicode(255)), >+ Column('update', Boolean()), >+ Column('type', Unicode(255)), >+ Column('encoding', Unicode(255)), >+ Column('attrs', Unicode(255)), >+ Column('acl', Unicode(2048)), >+ Column('data', UnicodeText()), >+ mysql_engine='InnoDB', >+) >+ > recipe_task_comment_table = Table('recipe_task_comment',metadata, > Column('id', Integer, primary_key=True), > Column('recipe_task_id', Integer, >@@ -6357,6 +6371,11 @@ def to_xml(self, clone=False, *args, **kw): > for p in self.params: > params.appendChild(p.to_xml()) > task.appendChild(params) >+ files = xmldoc.createElement("files") >+ for f in self.files: >+ f_xml = f.to_xml() >+ files.appendChild(f_xml) >+ task.appendChild(files) > if self.results and not clone: > results = xmldoc.createElement("results") > for result in self.results: >@@ -6618,6 +6637,43 @@ def to_xml(self): > return param > > >+class RecipeTaskFile(MappedObject): >+ """ >+ File parameters for task execution. >+ """ >+ >+ def __init__(self, name, update, type, encoding, attrs, acl, data): >+ # Intentionally not chaining to super(), to avoid session.add(self) >+ self.name = name >+ self.update = update >+ self.type = type >+ self.encoding = encoding >+ self.attrs = attrs >+ self.acl = acl >+ self.data = data >+ >+ def to_xml(self): >+ file = xmldoc.createElement("file") >+ file.setAttribute("name", "%s" % self.name) >+ if self.update != None: >+ file.setAttribute("update", "%s" % self.update) >+ if self.type != None: >+ file.setAttribute("type", "%s" % self.type) >+ if self.encoding != None: >+ file.setAttribute("encoding", "%s" % self.encoding) >+ if self.attrs != None: >+ file.setAttribute("attrs", "%s" % self.attrs) >+ if self.acl != None: >+ acl = xmldoc.createElement("acl") >+ acl_data = xmldoc.createCDATASection('%s' % self.acl) >+ acl.appendChild(acl_data) >+ file.appendChild(acl) >+ data = xmldoc.createElement("data") >+ data_data = xmldoc.createCDATASection('%s' % self.data) >+ data.appendChild(data_data) >+ file.appendChild(data) >+ return file >+ > class RecipeRepo(MappedObject): > """ > Custom repos >@@ -8106,6 +8162,7 @@ def __init__(self, *args, **kw): > 'comments':relation(RecipeTaskComment, > backref='recipetask'), > 'params':relation(RecipeTaskParam), >+ 'files':relation(RecipeTaskFile), > 'bugzillas':relation(RecipeTaskBugzilla, > backref='recipetask'), > 'task':relation(Task, uselist=False), >@@ -8116,6 +8173,7 @@ def __init__(self, *args, **kw): > ) > > mapper(RecipeTaskParam, recipe_task_param_table) >+mapper(RecipeTaskFile, recipe_task_file_table) > mapper(RecipeTaskComment, recipe_task_comment_table, > properties = {'user':relation(User, uselist=False, backref='comments')}) > mapper(RecipeTaskBugzilla, recipe_task_bugzilla_table)
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