- Acceleo
- Xtend
- Jet
I have started this work on Acceleo, and find the editor's content assist is pretty good and and straight forward way to apply launcher menu for mib files - almost no coding except the template declaration which is based on MOFM2T.
I will try to detail the steps clearly as I could for others to benefit. I struggled to get these end to end steps correct as most of tutorials out there are by features and less based on use-case (on top of that I used Xcore for model, hence it was a blocker at start).
- Install Acceleo from Modelling Component place (Version: 3.5.1), and change to Acceleo perspective, this makes lots of handy tool/wizard simple to find as oppose continue working on Java perspective.
- Acceleo Create Project wizard does not recognize Xcore as model. Therefore, I had to generate Ecore model first. Choose Mib.xcore from Package Explorer, and click "new -> Other..", choose EMF Generator Model. This will generate both Ecore and genmodel.
- Create a new Acceleo project "com.ravi.mib.acceleo.module.oid". On second wizard page - "Create a new Acceleo generation file", change module name to "oid" and search for Mib model from "Runtime Version" (http://www.ravi.com/ibm/xtext/Mib). Change template name to "generateOid" and type to "MibModel"
- Once the project created, edit com/ravi/mib/acceleo/module/oid/common/oid.mtl file and apply following template.
- There will be an error afterwards for "oid.common" package to be exported. Do as suggested.
- Now for launcher menu, select earlier created Acceleo project from Package Explorer and choose new Acceleo UI Launcher project, On "Acceleo UI Launcher settings", change model file name filter to "*.mib" and target folder access to "...getFolder("oid")".
- Finally modify label for menu as "Mib Generator"
- Once eclipse instance is launched, Generate Oid option should available for mib files.
oid.mtl |
---|
[comment encoding = UTF-8 /] [module oid('http://www.ravi.com/mib/xtext/Mib')] [template public generateOID(model : MibModel)] [comment @main /] [for (d : Definition | model.definitions)] [file (d.name.toString().concat('.oid'), false, 'UTF-8')] [for (oid : Identifier | d.identifiers)] [if (isValidObjectType(oid))] [oid.name/],[oid.value.oid/],[getPrimitive(oid)/],[getDerived(oid)/] [/if] [/for] [/file] [/for] [/template] [query private isValidObjectType(oid : Identifier) : Boolean = oid.oclIsTypeOf(ObjectType) and not oid.oclAsType(ObjectType).type.typeName.oclIsUndefined() and oid.oclAsType(ObjectType).type.typeName.toString().strcmp('OBJECT IDENTIFIER') <> 0 /] [query private getPrimitive(oid : Identifier) : String = if oid.oclAsType(ObjectType).type.dataType.derived.name.oclIsUndefined() then '' else oid.oclAsType(ObjectType).type.dataType.derived.name.toString() endif /] [query private getDerived(oid : Identifier) : String = oid.oclAsType(ObjectType).type.typeName.toString() /] |
RFC1213-MIB.oid |
---|
sysDescr,1.3.6.1.2.1.1.1,DisplayString,OCTET STRING sysUpTime,1.3.6.1.2.1.1.3,TimeTicks,INTEGER sysContact,1.3.6.1.2.1.1.4,DisplayString,OCTET STRING sysName,1.3.6.1.2.1.1.5,DisplayString,OCTET STRING sysLocation,1.3.6.1.2.1.1.6,DisplayString,OCTET STRING sysServices,1.3.6.1.2.1.1.7,,INTEGER ifNumber,1.3.6.1.2.1.2.1,,INTEGER ifIndex,1.3.6.1.2.1.2.2.1.1,,INTEGER ifDescr,1.3.6.1.2.1.2.2.1.2,DisplayString,OCTET STRING ifType,1.3.6.1.2.1.2.2.1.3,,INTEGER ifMtu,1.3.6.1.2.1.2.2.1.4,,INTEGER ifSpeed,1.3.6.1.2.1.2.2.1.5,Gauge,INTEGER ifPhysAddress,1.3.6.1.2.1.2.2.1.6,PhysAddress,OCTET STRING ifAdminStatus,1.3.6.1.2.1.2.2.1.7,,INTEGER ifOperStatus,1.3.6.1.2.1.2.2.1.8,,INTEGER ifLastChange,1.3.6.1.2.1.2.2.1.9,TimeTicks,INTEGER ifInOctets,1.3.6.1.2.1.2.2.1.10,Counter,INTEGER ifInUcastPkts,1.3.6.1.2.1.2.2.1.11,Counter,INTEGER ifInNUcastPkts,1.3.6.1.2.1.2.2.1.12,Counter,INTEGER ifInDiscards,1.3.6.1.2.1.2.2.1.13,Counter,INTEGER ifInErrors,1.3.6.1.2.1.2.2.1.14,Counter,INTEGER ifInUnknownProtos,1.3.6.1.2.1.2.2.1.15,Counter,INTEGER ifOutOctets,1.3.6.1.2.1.2.2.1.16,Counter,INTEGER ifOutUcastPkts,1.3.6.1.2.1.2.2.1.17,Counter,INTEGER ifOutNUcastPkts,1.3.6.1.2.1.2.2.1.18,Counter,INTEGER ifOutDiscards,1.3.6.1.2.1.2.2.1.19,Counter,INTEGER ifOutErrors,1.3.6.1.2.1.2.2.1.20,Counter,INTEGER ifOutQLen,1.3.6.1.2.1.2.2.1.21,Gauge,INTEGER atIfIndex,1.3.6.1.2.1.3.1.1.1,,INTEGER |
TODO: Is there any way for Xcore to register its model URI so that Acceleo able to recognize without going through Ecore generation?
TODO: How to limit OID list down to the selected mib file alone?
TODO: How to limit OID list down to the selected mib file alone?
No comments:
Post a Comment