POP 2 MPLS tags with OpenDayLight - rest

I am using Zodiac FX openflow switches controlled by ODL on a MPLS network and
I am trying to push 2 stacked MPLS labels on a single packet(MPLS tunnel) with this flow:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<flow
xmlns="urn:opendaylight:flow:inventory">
<flow-name>POP Z2</flow-name>
<instructions>
<instruction>
<order>0</order>
<apply-actions>
<action>
<pop-mpls-action>
<ethernet-type> 8847</ethernet-type>
</pop-mpls-action>
<order>0</order>
</action>
<action>
<pop-mpls-action>
<ethernet-type>2048</ethernet-type>
</pop-mpls-action>
<order>1</order>
</action>
<action>
<output-action>
<output-node-connector>2</output-node-connector>
<max-length>60</max-length>
</output-action>
<order>2</order>
</action>
</apply-actions>
</instruction>
</instructions>
<id>126</id>
<strict>false</strict>
<match>
<in-port>1</in-port>
</match>
<idle-timeout>0</idle-timeout>
<cookie>401</cookie>
<cookie_mask>255</cookie_mask>
<installHw>false</installHw>
<hard-timeout>0</hard-timeout>
<priority>200</priority>
<table_id>0</table_id>
But ODL donĀ“t move the flow to the operational datastore.
I have tried the same flow but with only one push action and it remove the first MPLS tag.
Is ODL limited to push only one MPLS label? What can I do?

Operational datastore is populated with what's actually programmed into the switch, it goes config--->switch--->operational. with various ODL components doing various things (OF plugin, Statsmgr, fwdrulesmgr..) it can be failing at any of theses points. you can look at karaf log (set DEBUG) to see whats going on from the controller internals prospective, tcpdump ofchan to see what the controller is trying to push and look at the switch flows/log to see what gets programmed.

Related

Visibility in popup menus

I have created an eclipse plugin project. I want this plugin to be available as a popup. Therefore I have created an extension point with "org.eclipse.ui.popupMenus" (I know it is deprecated now, ours is an old project.)
I want this popup option to appear only at the file level with certain extension (say xml). Currently, it is appearing anywhere on right click.
I have looked around the internet and got to know that I can add a "visibility" tag that can set rules where this popup should be visible. However, I do not know the syntax for that.
Can someone please help me out? How to set the visibility of the popup menu so that it is visible only when I right click ON the filename with extension xml?
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
objectClass="org.eclipse.core.resources.IFile"
nameFilter="*.*"
id="org.eclipse.lyo.tools.codegenerator.ui.popupMenus.contribution.IFile">
<menu id="org.eclipse.acceleo.module.menu" label="Acceleo Model Code Generator" path="additionsAcceleo">
<groupMarker name="acceleo"/>
</menu>
<action
class="org.eclipse.lyo.tools.codegenerator.ui.popupMenus.AcceleoGenerateCodegeneratorAction"
enablesFor="+"
id="org.eclipse.lyo.tools.codegenerator.ui.popupMenus.AcceleoGenerateCodegeneratorAction"
icon="icons/default.gif"
label="Generate Java Code from Model"
menubarPath="org.eclipse.acceleo.module.menu/acceleo"/>
<visibility>
//what should come here?
</visibility>
</objectContribution>
</extension>
</plugin>
(http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_popupMenus.html)
Regards,
Yash
visibility can only be a child of objectContribution not action.
In any case you can use the namefilter attribute to restrict the file name matching. You would only use visiblity to do more complex checks.
For example this is one of the JDT items:
<objectContribution
adaptable="true"
objectClass="org.eclipse.core.resources.IFile"
nameFilter="*.xml"
id="org.eclipse.jdt.internal.ui.javadocexport.JavadocWizard">
<visibility>
<objectState name="contentTypeId" value="org.eclipse.ant.core.antBuildFile"/>
</visibility>
In this
adaptable="true"
objectClass="org.eclipse.core.resources.IFile"
restricts the actions to a workspace file
nameFilter="*.xml"
restricts the actions to files ending in .xml
<visibility>
<objectState name="contentTypeId" value="org.eclipse.ant.core.antBuildFile"/>
</visibility>
further restricts the actions to files with a 'content type' of 'Ant build file'
To match multiple name patterns remove the nameFilter and use a visibility like:
<visibility>
<or>
<objectState name="name" value="*.xml"/>
<objectState name="name" value="*.java"/>
</or>
</visibility>

Set Allowed Countries on Store View

In Magento 1.4, I was able to set allowed countries on the Store View Level, therefore I could have a Website with one Store und multiple Store Views for each of my countries:
Now in Magento 2, I can only set the Allowed Countries on the Website and not on the Store View, the Store View setting looks as follows:
Why do I want to change that? I need to be able to set a different store contact address for each of these Store Views, because I e.g. have an Argentinien und a Bulgarian Store View, so I want to set the different addresses but use the same Website/Store.
Unfortunately, I'm also not able to change the Store Contact Address per Store View anymore, this also only works on Website Level.
Am I missing something? Was there a logical change from 1.X to 2.X about the Store Views?
I don't know why the allowed country option was removed from settings in store view. But looking in the code shows that the information is used if present. So you can just enter the data into core_config_data (scope: stores, scope_id: your_store_id, value: AT,AB,AC...
the correct answer that respects Magento 2 standardization is overloading the system.xml of the magento/Backend/etc/adminhtml.
you should try:
Vendor/ModuleName/etc/adminhtml/system.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="general">
<group id="country" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Country Options</label>
<field id="allow" translate="label" type="multiselect" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Allow Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
</field>
</group>
</section>
</system>
</config>
Remember to add overridden module - Magento_Backend
Vendor/ModuleName/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_YourModule" setup_version="1.0.0">
<sequence>
<module name="Magento_Backend"/>
</sequence>
</module>
</config>

XDT Transform: InsertBefore - Locator Condition is ignored

I have a web.config file in which I need to either insert the <configSections /> element or manipulate children of that node if it already exists.
If it already exists I don't want to insert it again (obviously, as it is only allowed to exist once).
Normally, that would not be a problem, however:
If this element is in a configuration file, it must be the first child element of the element.
Source: MSDN.
So if I use xdt:Transform="InsertIfMissing" the <configSections /> element will always be inserted after any existing child elements (and there are always some), violating the above restriction of it having to be the first child element of <configuration />
I attempted to make this work in the following way:
<configSections
xdt:Transform="InsertBefore(/configuration/*[1])"
xdt:Locator="Condition(not(.))" />
Which works perfect, if the <configSections /> element doesn't already exist. However, the condition I've specified seems to be ignored.
In fact, I've tried a few conditions like:
Condition(not(/configuration[configSections]))
Condition(/configuration[configSections] = false())
Condition(not(/configuration/configSections))
Condition(/configuration/configSections = false())
Finally, out of desperation, I tried:
Condition(true() = false())
It still inserted the <configSections /> element.
It is important to note that I'm trying to include this in a NuGet package, so I will be unable to use a custom transform (like the one AppHarbor uses).
Is there any other clever way to get my element in the right place only if it doesn't yet exist?
To test this out, use AppHarbors config transform tester. Replace the Web.config with the following:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="initialSection" />
</configSections>
</configuration>
And Web.Debug.config with the following:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<configSections
xdt:Transform="InsertBefore(/configuration/*[1])"
xdt:Locator="Condition(true() = false())" />
<configSections>
<section name="mySection" xdt:Transform="Insert" />
</configSections>
</configuration>
The result will show two <configSections /> elements, the one containing "mySection" being the first, as specified in the InsertBefore Transform.
Why was the Locator Condition not taken into account?
So after facing the same issue, I came up with a solution. It's not pretty nor elegant, but it works. (At least on my machine)
I just split the logic into 3 different statements. First, I add an empty configSections at the correct position (first). Then I insert the new config to the last configSections, which would be the new one if it is the only one, or a previously existing one otherwise.
Lastly I remove any empty configSections elemnt which might exist. I'm using RemoveAll for no good reason, you should probably use Remove.
The overall code looks like so:
<configSections xdt:Transform="InsertBefore(/configuration/*[1])" />
<configSections xdt:Locator="XPath(/configuration/configSections[last()])">
<section name="initialSection" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
</configSections>
<configSections xdt:Transform="RemoveAll" xdt:Locator="Condition(count(*)=0)" />
The question which still remains unanswered is why Locator conditions are not taken into account for InsertBefore. Or why I can't handle an empty match set for InsertBefore, because that would allowed me to do fun things such as
//configuration/*[position()=1 and not(local-name()='configSections')]
Which to be honest is a much clearer way of doing what I want to achieve.

How to rewrite the magento core-cache-model (Mage_Core_Model_Cache)

I have to rewrite the core cache model. And this doesn't work. My first attempt to solve the problem was to try the rewrite with another model...
In my config.xml I declared the following
<global>
<models>
<core>
<rewrite>
<**layout**>MyCompany_MyModule_Model_Core_Cache</**layout**>
</rewrite>
</core>
</models>
....
and in my class I died in the consturctor.
This works perfectly!
So my may in rewriting models is the right one.
But If I don't use the layout-node in the xml but using the cache-node instead this does not work.
So my attempt is the following and this is not working:
<global>
<models>
<core>
<rewrite>
<cache>MyCompany_MyModule_Model_Core_Cache</cache>
</rewrite>
</core>
</models>
....
My question now: is there a way to rewrite / overload the "cache-core-model"???
The cache will be initialized before module configurations (config.xml) are loaded. The cache-Model was instanciated with Mage::getModel, which caches the modelnames in the registry.
So all later tries to get the custom cache-model will also fail.
Solution: put this rewrite statement in the etc/local.xml. This is a bit dirty because the local.xml should only hold module independent stuff. But this is better than copying core files to local.
I had the same question, but my solution is a little bit different to yours ;-)
Magento will load the XML file from /app/etc/*.xml (this files will not be cached) before everything else in magento.
So i created my own file here "cache.xml" and the content is
<?xml version="1.0"?>
<config>
<global>
<models>
<core>
<rewrite>
<cache>MyCompany_MyModule_Model_Core_Cache</cache>
</rewrite>
</core>
</models>
</global>
</config>
works perfect in 1.6,1.7 and 1.8
I'm also trying to do the same thing and i don't think it's possible. If you var_dump out $this->_xml->group->models in the method: getGroupedClassName (app/code/core/Mage/Core/Model/Config.php) you'll notice that your rewrite it's not yet available, hence why it's skipped.
If you try to overwrite translate or layout: your_class_model you'll notice that the $this->_xml... dumps the initial core classes (with no rewrite) and you'll see your rewrite down the line well past the core/cache. So, it's probably being overridden but the class is already instantiated, set up and used; so it's really not going to fire anything.
Hence i don't think it's possible to override the core/cache. You'll have to move it to the app/code/local. Pitty.

Struts 2 - Persist property value for redirect action

I want to retain a property value after redirecting to a different action. I know that the value will go away since we are navigating to different action (request). But I need to some how that how can I achieve this ?
Here is my code :
<action name="save" class="saveAction" method="saveData">
<result name="success" type="redirectAction">redirectedPageAction</result>
<result name="successView" >successView.jsp</result>
<result name="error" >error.jsp</result>
</action>
<action name="redirectedPageAction" class="month" method="">
<result name="success">employeesList.jsp</result>
</action>
In save action class I am using addActionMessage(String msg) method to set a value. Also I have getter/setter for the same.
I tried this but didn't get success :
<action name="redirectedPageAction" class="month" method="">
<result name="success">employeesList.jsp>
<param name="msg">${msg}</param>
</result>
</action>
I want value which was set by adActionMessage(msg) in my employeelist.jsp page. I am getting null pointer struts exception.
Please help..
Actions are created per-request. If you don't actually pass anything from the first action to the second, there won't be anything for the second action to retrieve. Getters don't change HTTP mechanics.
If you're interested specifically in messages/etc., use the MessageStoreInterceptor, or do it manually.
Since you already mentioned that and you know that it will create a new request cycle and Actions and created per request since they work as Data object also ,which means your request/response parameters will be lost.
Now you have few option
Try using the Struts2 build in support for this message-store-interceptor.
This interceptor has been created to store a ValidationAware action's messages / errors and field errors into HTTP Session and is very useful in your use-case.
If you want wider scope either you can store data in the session and retrieve that at later stage or can pass values as query parameters.
I've faced this problem before, sometimes you need to show a whole new view after an action and the redirect result does not take into consideration any previous data (http request stuff).
We wanted to create a custom interceptor, but before doing it I found this
http://www.mail-archive.com/user#struts.apache.org/msg77854.html
It really helped us a lot.
Having said that, what version of Struts 2 are you using? We use Struts 2.2.3 and the parameters passed to the redirectAtion works fine.
Do you have setter and getters in both actions?
You can pass your property variable with redirectAction as a parameter like this
<action name="save" class="saveAction" method="saveData">
<result name="success" type="redirectAction">
<param name="actionName">redirectedPageAction</param>
<param name="msg">${msg}</param>
</result>
<result name="successView" >successView.jsp</result>
<result name="error" >error.jsp</result>
</action>
Also, dont miss to add getter/setter for msg variable in your redirectedPageAction action