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 887348 Details for
Bug 1089093
[RFE] Rework engine configuration
[?]
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.
convert.py
convert.py (text/x-python), 7.50 KB, created by
Alon Bar-Lev
on 2014-04-17 22:19:17 UTC
(
hide
)
Description:
convert.py
Filename:
MIME Type:
Creator:
Alon Bar-Lev
Created:
2014-04-17 22:19:17 UTC
Size:
7.50 KB
patch
obsolete
>#!/usr/bin/python > >import ConfigParser >import StringIO >import csv >import os >import subprocess >import sys > >PREFIX = sys.argv[1] >DATABASE = sys.argv[2] >USER = sys.argv[3] >OUTPUT = sys.argv[4] > >CURRENT_VERSION = '3.5' >QUERY = 'select * from vdc_options' >ENGINE_CONFIG = os.path.join( > PREFIX, > 'etc/ovirt-engine/engine-config/engine-config.properties' >) >COMMON_JAR = os.path.join( > PREFIX, > 'share/ovirt-engine/modules/org/ovirt/engine/core/common/main/common.jar' >) >VALUES_PROGRAM = """ >import java.lang.reflect.*; >import java.lang.annotation.*; >import org.ovirt.engine.core.common.config.*; >import org.ovirt.engine.core.common.queries.*; > >public class ConvertValues { > public static void main (String[] args) throws Exception { > for (ConfigValues v : ConfigValues.values()) { > Annotation[] as = v.getClass().getField( > v.toString() > ).getDeclaredAnnotations(); > for (Annotation a : as) { > if (a.annotationType().equals(TypeConverterAttribute.class)) { > TypeConverterAttribute xx = (TypeConverterAttribute)a; > System.out.println( > String.format( > "%s.type=%s", > v, > xx.value().getName().replaceAll(".*\\\\.", "") > ) > ); > } > else if ( > a.annotationType().equals(DefaultValueAttribute.class) > ) { > DefaultValueAttribute xx = (DefaultValueAttribute)a; > System.out.println( > String.format("%s.value=%s", v, xx.value()) > ); > } > else if (a.annotationType().equals(Reloadable.class)) { > System.out.println(String.format("%s.reloadable=1", v)); > } > else if (a.annotationType().equals(Deprecated.class)) { > System.out.println(String.format("%s.deprecated=1", v)); > } > else if ( > a.annotationType().equals(OptionBehaviourAttribute.class) > ) { > OptionBehaviourAttribute xx = (OptionBehaviourAttribute)a; > System.out.println( > String.format( > "%s.behaviour.type=%s", > v, > xx.behaviour() > ) > ); > if (xx.dependentOn() != ConfigValues.Invalid) { > System.out.println( > String.format( > "%s.behaviour.depend=%s", > v, > xx.dependentOn() > ) > ); > System.out.println( > String.format( > "%s.behaviour.realValue=%s", > v, > xx.realValue() > ) > ); > } > } > else { > System.err.println( > String.format("Missing handler for %s", a) > ); > System.exit(1); > } > } > } > > for (ConfigurationValues v : ConfigurationValues.values()) { > System.out.println( > String.format("%s.ui.role=%s", v, v.getConfigAuthType()) > ); > } > } >} >""" > > >def execute(args): > p = subprocess.Popen( > args, > stdout=subprocess.PIPE, > stderr=subprocess.PIPE, > close_fds=True, > ) > stdout, stderr = p.communicate() > if p.returncode != 0: > sys.stderr.write(stderr) > raise Exception('execute %s failed' % args) > return stdout > > >def loadSection(properties, section, public): > for k, v in config.items(section): > if '.' not in k: > sys.stderr.write( > 'WARNING: ignoring %s from engine-config.properties\n' % k > ) > continue > k1, k2 = k.split('.', 1) > if k2 == 'description': > v = v.strip('"') > properties.setdefault(k1, {'versions': {}}) > properties[k1]['public'] = public > if k2 == 'value': > properties[k1]['versions']['general'] = v > else: > properties[k1][k2] = v > > >with open('/tmp/ConvertValues.java', 'w') as f: > f.write(VALUES_PROGRAM) > >execute(['javac', '-cp', COMMON_JAR, '/tmp/ConvertValues.java']) >configValues = execute( > ( > 'java', > '-cp', '%s:/tmp' % COMMON_JAR, > 'ConvertValues', > ), >) > >config = ConfigParser.ConfigParser() >config.optionxform = str >config.readfp(StringIO.StringIO('[configValues]' + configValues)) >with open(ENGINE_CONFIG) as f: > config.readfp(StringIO.StringIO('[engineConfig]' + f.read())) > >properties = {} >loadSection(properties, 'configValues', 0) >loadSection(properties, 'engineConfig', 1) > >stdout = execute( > [ > 'psql', > '-h', 'localhost', > '-U', DATABASE, > '-d', USER, > '-c', 'copy (%s) to stdout with csv header;' % QUERY > ], >) >vdc_options = [x for x in csv.DictReader(stdout.splitlines(True))] >for option in vdc_options: > properties.setdefault( > option['option_name'], {'versions': {}} > )['versions'][option['version']] = option['option_value'] > >for option, info in properties.items(): > if 'deprecated' in info: > del properties[option] > elif 'behaviour.type' in info and 'Password' in info['behaviour.type']: > properties[option]['versions']['general'] = '' > elif ( > 'type' in info and > info['type'] == 'Boolean' and > 'validValues' in info > ): > del info['validValues'] > > if CURRENT_VERSION in info['versions']: > info['versions']['general'] = info['versions'][CURRENT_VERSION] > >for option, info in properties.iteritems(): > if 'type' not in info: > sys.stderr.write('ERROR: no type for option %s\n' % option) > >for option, value in [ > ('MacPoolRanges', '00:1A:4A:16:01:51-00:1A:4A:16:01:e6'), > ('OrganizationName', 'Test Organization'), > ('ProductRPMVersion', 'N/A'), >]: > properties[option]['versions']['general'] = value > >with open(OUTPUT, 'w') as f: > for option in sorted(properties.keys()): > info = properties[option] > for k, v in info.iteritems(): > if k == 'versions': > for ver in sorted(info['versions'].keys()): > val = info['versions'][ver] > suffix = '' > if ver != 'general': > suffix = '.version.%s' % ver > > if ( > ver != 'general' and > 'general' in info['versions'] and > val == info['versions']['general'] > ): > continue > > if '\n' in str(val): > f.write('%s.value%s=\\\n' % (option, suffix)) > for l in val.splitlines()[:-1]: > f.write(' %s\\n\\\n' % l) > f.write(' %s\n' % val.splitlines()[-1]) > elif val: > f.write('%s.value%s=%s\n' % (option, suffix, val)) > elif k == 'public': > if v != 0: > f.write('%s.%s=1\n' % (option, k)) > else: > if v: > f.write('%s.%s=%s\n' % (option, k, v))
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 Raw
Actions:
View
Attachments on
bug 1089093
: 887348