summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2008-09-09 17:31:47 +0000
committerTed Ross <tross@apache.org>2008-09-09 17:31:47 +0000
commitc513257dc8159a6ba70298e00926a45666840a91 (patch)
treee2684a7e1ec0b4717e8cfef34724be6274315c6e
parentde1bf14f00b02ad95239e14e761f5d8775a2137e (diff)
downloadqpid-python-c513257dc8159a6ba70298e00926a45666840a91.tar.gz
QPID-1274 - qmf-gen can now generate code from multiple schema files. Uses __file__ as a better way to locate data files. Added code generation for ACL schema.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@693523 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/examples/qmf-agent/Makefile2
-rwxr-xr-xqpid/cpp/managementgen/qmf-gen49
-rwxr-xr-xqpid/cpp/managementgen/qmf/generate.py5
-rwxr-xr-xqpid/cpp/managementgen/qmf/schema.py4
-rw-r--r--qpid/cpp/src/Makefile.am5
-rw-r--r--qpid/cpp/src/qpid/acl/management-schema.xml48
-rw-r--r--qpid/cpp/src/qpid/acl/management_schema.xml31
7 files changed, 79 insertions, 65 deletions
diff --git a/qpid/cpp/examples/qmf-agent/Makefile b/qpid/cpp/examples/qmf-agent/Makefile
index 6c4d9a867e..0759644670 100644
--- a/qpid/cpp/examples/qmf-agent/Makefile
+++ b/qpid/cpp/examples/qmf-agent/Makefile
@@ -51,7 +51,7 @@ all: gen
@$(MAKE)
gen:
- $(MGEN) $(SCHEMA_FILE) $(GEN_DIR)
+ $(MGEN) -o $(GEN_DIR) $(SCHEMA_FILE)
clean:
rm -rf $(GEN_DIR) $(OUT_FILE) *.d *.o
diff --git a/qpid/cpp/managementgen/qmf-gen b/qpid/cpp/managementgen/qmf-gen
index 10750f2a34..a6f022926c 100755
--- a/qpid/cpp/managementgen/qmf-gen
+++ b/qpid/cpp/managementgen/qmf-gen
@@ -24,27 +24,12 @@ from qmf.schema import PackageSchema, SchemaClass
from qmf.generate import Generator
from optparse import OptionParser
-dataPath = os.path.dirname(sys.argv[0]) + "/qmf/"
-defaultTypeFile = dataPath + "management-types.xml"
-defaultTemplateDir = dataPath + "templates"
-found = True
-
-try:
- s = os.stat(defaultTypeFile)
-except:
- found = False
-
-if not found:
- path = sys.path
- for item in path:
- if os.path.basename(item) == "site-packages":
- found = True
- dataPath = item + "/qmf/"
- defaultTypeFile = dataPath + "management-types.xml"
- defaultTemplateDir = dataPath + "templates"
+dataPath = os.path.dirname(Generator.getModulePath())
+defaultTypeFile = dataPath + "/management-types.xml"
+defaultTemplateDir = dataPath + "/templates"
# Set command line options
-usage = "usage: %prog [options] schema-document out-directory"
+usage = "usage: %prog [options] schema-document..."
parser = OptionParser (usage=usage)
parser.add_option ("-m", "--makefile", dest="makefile", metavar="FILE",
help="Makefile fragment")
@@ -52,26 +37,28 @@ parser.add_option ("-t", "--typefile", dest="typefile", metavar="FILE", default=
help="Type descriptor file")
parser.add_option ("-d", "--templatedir", dest="templatedir", metavar="DIR", default=defaultTemplateDir,
help="Template directory")
+parser.add_option ("-o", "--outputdir", dest="outputdir", metavar="DIR", default="./",
+ help="Output directory")
(opts, args) = parser.parse_args ()
-if len (args) < 2:
- parser.error ("Too few arguments")
-
typefile = opts.typefile
templatedir = opts.templatedir
+outdir = opts.outputdir
+gen = Generator (outdir, templatedir)
-schemafile = args[0]
-outdir = args[1]
+if len(args) == 0:
+ print "no input files"
+ parser.exit()
-gen = Generator (outdir, templatedir)
-schema = PackageSchema (typefile, schemafile, opts)
+for schemafile in args:
+ schema = PackageSchema (typefile, schemafile, opts)
-gen.makeClassFiles ("Class.h", schema)
-gen.makeClassFiles ("Class.cpp", schema)
-gen.makeMethodFiles ("Args.h", schema)
-gen.makePackageFile ("Package.h", schema)
-gen.makePackageFile ("Package.cpp", schema)
+ gen.makeClassFiles ("Class.h", schema)
+ gen.makeClassFiles ("Class.cpp", schema)
+ gen.makeMethodFiles ("Args.h", schema)
+ gen.makePackageFile ("Package.h", schema)
+ gen.makePackageFile ("Package.cpp", schema)
if opts.makefile != None:
gen.makeSingleFile ("Makefile.mk", opts.makefile, force=True)
diff --git a/qpid/cpp/managementgen/qmf/generate.py b/qpid/cpp/managementgen/qmf/generate.py
index 70735b208a..e977ce2e9d 100755
--- a/qpid/cpp/managementgen/qmf/generate.py
+++ b/qpid/cpp/managementgen/qmf/generate.py
@@ -298,3 +298,8 @@ class Generator:
self.templateFiles.append (templateFile)
stream = template.expand (makefile)
self.writeIfChanged (stream, target, force)
+
+ @staticmethod
+ def getModulePath():
+ return __file__
+
diff --git a/qpid/cpp/managementgen/qmf/schema.py b/qpid/cpp/managementgen/qmf/schema.py
index e666bdbb39..9263c29543 100755
--- a/qpid/cpp/managementgen/qmf/schema.py
+++ b/qpid/cpp/managementgen/qmf/schema.py
@@ -656,6 +656,7 @@ class SchemaEvent:
self.name = None
self.desc = None
self.args = []
+ self.defaultSeverity = None
attrs = node.attributes
for idx in range (attrs.length):
@@ -667,6 +668,9 @@ class SchemaEvent:
elif key == 'desc':
self.desc = val
+ elif key == 'defaultSeverity':
+ self.defaultSeverity = val
+
else:
raise ValueError ("Unknown attribute in event '%s'" % key)
diff --git a/qpid/cpp/src/Makefile.am b/qpid/cpp/src/Makefile.am
index d4214ad052..f0d1ea04c9 100644
--- a/qpid/cpp/src/Makefile.am
+++ b/qpid/cpp/src/Makefile.am
@@ -28,8 +28,9 @@ $(rgen_generator):
# Management generator.
mgen_dir=$(top_srcdir)/managementgen
-mgen_cmd=$(mgen_dir)/qmf-gen -m $(srcdir)/managementgen.mk \
- $(top_srcdir)/../specs/management-schema.xml gen/qpid/management
+mgen_cmd=$(mgen_dir)/qmf-gen -m $(srcdir)/managementgen.mk -o gen/qpid/management \
+ $(top_srcdir)/../specs/management-schema.xml \
+ $(srcdir)/qpid/acl/management-schema.xml
$(srcdir)/managementgen.mk $(mgen_broker_cpp) $(dist_qpid_management_HEADERS): mgen.timestamp
mgen.timestamp: $(mgen_generator)
diff --git a/qpid/cpp/src/qpid/acl/management-schema.xml b/qpid/cpp/src/qpid/acl/management-schema.xml
new file mode 100644
index 0000000000..4f633f6a06
--- /dev/null
+++ b/qpid/cpp/src/qpid/acl/management-schema.xml
@@ -0,0 +1,48 @@
+<schema package="ACL">
+
+<!--
+ * Copyright (c) 2008 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+ <class name="plugin">
+ <property name="brokerRef" type="objId" references="qpid.Broker" access="RO" index="y" parentRef="y"/>
+ <property name="policyFile" type="sstr" access="RO" desc="Name of the policy file"/>
+ <property name="enforcingAcl" type="bool" access="RO" desc="Currently Enforcing ACL"/>
+ <property name="transferAcl" type="bool" access="RO" desc="Any transfer ACL rules in force"/>
+ <property name="lastAclLoad" type="absTime" access="RO" desc="Timestamp of last successful load of ACL"/>
+ <statistic name="aclDenyCount" type="count64" unit="record" desc="Number of ACL requests denied"/>
+
+ <method name="reloadACLFile" desc="Reload the ACL file"/>
+
+ <event name="aclEvent" defaultSeverity="info" desc="Event generated by the ACL policy">
+ <arg name="denied" type="bool"/>
+ <arg name="authId" type="sstr"/>
+ <arg name="action" type="sstr"/>
+ <arg name="objType" type="sstr"/>
+ <arg name="name" type="sstr"/>
+ <arg name="params" type="map"/>
+ </event>
+
+ <event name="fileLoaded" defaultSeverity="warning" desc="ACL file successfully loaded - New policy in effect">
+ <arg name="authId" type="sstr" desc="Name of user who initiated the file load"/>
+ </event>
+
+ <event name="fileNotLoaded" defaultSeverity="error" desc="Replacement ACL file could not be loaded">
+ <arg name="authId" type="sstr" desc="Name of user who initiated the file load"/>
+ <arg name="reason" type="sstr" desc="Reason for failure"/>
+ </event>
+ </class>
+
+</schema>
diff --git a/qpid/cpp/src/qpid/acl/management_schema.xml b/qpid/cpp/src/qpid/acl/management_schema.xml
deleted file mode 100644
index 8dc9ce41b7..0000000000
--- a/qpid/cpp/src/qpid/acl/management_schema.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<schema package="ACL">
-
-<!--
- * Copyright (c) 2008 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
--->
-
- <class name="plugin">
- <property name="brokerRef" type="objId" references="qpid.Broker" access="RO" index="y" parentRef="y"/>
- <property name="policyFile" type="sstr" access="RO" desc="Name of the policy file"/>
- <property name="EnforcingACL" type="bool" access="RO" desc="Currently Enfocing ACL"/>
- <property name="TransferACL" type="bool" access="RO" desc="Any transfer ACL rules in force"/>
- <property name="LastACLLoad" type="absTime" access="RO" desc="Timestamp last load of ACL"/>
- <statistic name="ACLDenyCount" type="count64" unit="record" desc="Number of ACL requests denied"/>
-
- <method name="reloadACLFile" desc="Reload the ACL file">
- </method>
- </class>
-
-</schema>