Netconf edit-config - ietf-netmod-yang

Is this RPC valid?
<rpc>
<edit-config>
<target>
<candidate/>
</target>
<config>
<interfaces>
<interface operation="delete">
<name>fe-0/0/0</name>
<description>test-test</description>
</interface>
</interfaces>
</config>
</edit-config>
</rpc>
Should the leaf "description" be present in above RPC? The parent itself gets deleted and specifying "description" does not make sense. If a controller sends an XML to NE like this, should NE honour this XML? I believe it should be treated as a bug in controller.

As you said, the RPC doesn't really make sense, but that doesn't make it invalid.
In this particular case, the description should not be present in the deleted interface (only keys need to be present).
A flexible NETCONF server would ignore the description leaf and proceed with deleting the interface.
For more complex scenarios, you can have 'continue-on-error' error-option (https://www.rfc-editor.org/rfc/rfc6241#page-39), where operations are handled in best effort. In this case, it could happen that the delete itself would fail, in which case the description leaf would be processed, based on the default operation (which is 'merge'). In this case, it would behave as "delete interface-fe-0/0/0; if not possible, set description to 'test-test' ".

Related

Transformation of machineKey tag

We have to transform tag in which "decryptionKey" and "validationKey" will be different for our development and test environments.
We have tried to give different variables for validationKey and decryptionKey but confused with the xdt: Transform and xdt: Locator attribute as they will occur once in the same tag.
Suppose following is the web.config machineKey tag,
<machineKey decryptionKey="012345678910111213141516"
validation="SHA1" validationKey="235487512547896321458778996325456965542126364586965" />
We have to give transformation something like following,
<machineKey decryptionKey="#{DecryptionKey}#"
validation="SHA1"
validationKey="#{ValidationKey}#"
xdt:Transform="SetAttributes"
xdt:Locator="Match(decryptionKey)"
xdt:Transform="SetAttributes"
xdt:Locator="Match(validationKey)" />
Need this kind of a solution in which we have to give multiple variables within a single tag.
To set multiple attributes, you need to pass them into SetAttributes as a comma-delimited list.
This is documented here
However, if you are actually replacing all of the attributes, it might just be easier/cleaner to use xdt:Transform="Replace" and set the entire tag value in each configuration.

Problem with rule validation - valid on save, invalid on load

While testing the unchanged CodeEffects asp.net core demo application (Editor 5.0.4.8, Engine 5.0.2.6) I've found an interesting problem.
If I create an execution rule that checks for example if FirstName contains two spaces, I can save this rule without a problem, and in SaveRule action it passes the validation using editor.Rule.IsValid. Here is an example of the rule definition:
<if>
<clause>
<condition type="contains" stringComparison="OrdinalIgnoreCase">
<property name="FirstName" />
<value> </value>
</condition>
</clause>
<then>
<method name="Register">
<value>aaaa</value>
</method>
</then>
</if>
But when refreshing the editor and trying to load this saved rule it won't load into editor. The reason is that the LoadRule controller action returns empty json.
While investigating this further it looks that the editor.GetClientRuleData returns null because the rule is invalid. If I check editor.Rule.IsValid just before calling editor.GetClientRuleData I can see it return false and the editor.Rule.InvalidElements holds one element:
{{c:"",h:"v120"}}
The error message would be "The only allowed operators for empty string values are IS and IS NOT" but of course it's not shown in the editor in the demo project as this is not expected to happen.
Not sure if this is in any way related to the problem, but one obvious difference between LoadRule and SaveRule actions is how the rule is loaded.
When saving the rule, the rule data (coming from the UI) is loaded into editor with
editor.LoadClientData(data.Data);
and when loading the rule it's loaded using the xml (from the storage) effectively calling this:
editor.Rule = Rule.Models.RuleModel.Create(ruleXml, typeof(Models.Patient))
So my question is why can invalid rule pass the validation on save, and then the same rule fails the validation on load? Any fix I can try or a workaround?
This issue has been fixed in the latest version of Rule Editor. You need to update Code Effects references from NuGet:
CodeEffects.Rule.Common - 5.0.2.4, CodeEffects.Rule.Editor.Core - 5.0.4.1 (this is the assembly that contains that fix), CodeEffects.Rule.Editor.Web.Core - 5.0.4.8

Creating a working copy for Plone 4 custom content types

I have created a custom Plone content type in my package i.e. my.product.
I am in need of integrating a working copy support: so that a "published" document (in my case, a published content type) stays online while it is being edited. Basically, I want to take advantage of 'Working Copy Support (Iterate)' provided by plone.app.iterate to achieve what is explained here. This will provide me with ability to check-in/check-out my changes.
Is this possible in Plone 4 with custom content types using Archetypes? How would one go about it if yes?
I added the following two files inside my.product/my/product/profiles/default folder and it appears to work:
diff_tool.xml
<?xml version="1.0"?>
<object>
<difftypes>
<type portal_type="MyCustomType">
<field name="any" difftype="Compound Diff for AT types"/>
</type>
</difftypes>
</object>
repositorytool.xml
<?xml version="1.0"?>
<repositorytool>
<policymap>
<type name="MyCustomType">
<policy name="at_edit_autoversion"/>
<policy name="version_on_revert"/>
</type>
</policymap>
</repositorytool>
I have never used plone.app.iterate, but this is the generic approach how to solve the problem.
Actions are installed by plone.app.iterate GenericSetup profile. You can see actions here:
https://github.com/plone/plone.app.iterate/blob/master/plone/app/iterate/profiles/default/actions.xml
Pay note to the line *available_expr* which tells when to show the action or not. It points to helper view with the conditition.
The view is defined here
https://github.com/plone/plone.app.iterate/blob/master/plone/app/iterate/browser/configure.zcml#L7
The checks that are performed for the content item if it's archiveable
https://github.com/plone/plone.app.iterate/blob/master/plone/app/iterate/browser/control.py#L47
Most likely the failure comes from if not interfaces.IIterateAware.providedBy condition. Your custom contennt must declare this interface. However, you can confirm this putting a pdb breakpoint in checkin_allowed(self) and step it though line-by-line and see what happens with your content type.

WiX: Preserve on major upgrade, remove on uninstall

I have defined a component to cleanup a generated (not installed) file on uninstall but leave intact on a major upgrade after reading this post
<Component Id="C_RemoveOnUninstall" Guid="XXX">
<RemoveFile Id="DeleteGeneratedFile" Name="ProgramGeneratedFile" On="uninstall"/>
<Condition>REMOVE="ALL" AND NOT UPGRADINGPRODUCTCODE</Condition>
</Component>
With condition above, the file is left behind for both upgrade and uninstall.
Without the condition, the file is deleted for both upgrade and uinstall.
I have tried RemoveFile for each of On="install/uninstall/both" but it does not seem to matter. Have read this post but I am hoping to make component conditions work and avoid writing custom action for this.
Does this code look correct? Any solutions or work around?
This approach assumes the RemoveFiles action ignores an item in the RemoveFile table when the property DirProperty referrers to has a value of null. The property DirProperty referrers to will be set during uninstall though not during an upgrade.
Conditionally set the property:
<SetProperty Id="prop_GeneratedFileDir" Value="[GeneratedFileDir]" After="InstallInitialize" Sequence="execute">
REMOVE="ALL" AND NOT UPGRADINGPRODUCTCODE
</SetProperty>
Define an element for the RemoveFile table:
<Component Id="C_RemoveOnUninstall" Guid="XXX">
<RemoveFile Id="DeleteGeneratedFile" Property="prop_GeneratedFileDir" Name="ProgramGeneratedFile" On="uninstall"/>
<CreateFolder/>
</Component>
Some helpful links:
wix-users, RemoveFile Table, RemoveFile Element, RemoveFolderEx Element

How to load specific rule (.drl) from Guvnor web-app?

For example, I have added two rules (rule1.drl and rule2.drl) in Guvnor.
Normally I can retrieve those rules combined by creating a changeset.xml like:
<change-set ...>
<add>
<resource source='http://localhost/guvnor/org.drools.guvnor.Guvnor/package/name/LATEST.drl' type='DRL' basicAuthentication="enabled" username="username" password="password" />
</add>
</change-set>
And load the changeset.xml by codes:
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("Test Agent", kaconf);
kagent.applyChangeSet(ResourceFactory.newClassPathResource("changeset.xml"));
knowledgeBase = kagent.getKnowledgeBase();
But how I can retrieve specific rule only? e.g. rule2.drl
Of course I can change the url in changeset.xml to
<resource source='http://localhost/guvnor/org.drools.guvnor.Guvnor/package/name/LATEST/rule2.drl' type='DRL' basicAuthentication="enabled" username="username" password="password" />
But I found that the response file miss the package name and all the import statements, for example:
package com.packname;
import namespace.EntityA;
When we need to execute especific drl package we use diferent changeset for each package/snapshot.
If the rules are related use different pojos for separate the rule, because you know the guvnor compile all your rules from a package in one big .drl, this could be slow if you have a hundred of rule-then-end's and iterate it with different pojo instances.
The URL patterns for packages and individual assets is different. For assets (e.g. DRLs) the pattern is:
<resource source='http://localhost:9090/drools-guvnor/rest/packages/test/assets/MyRule/source' type='DRL' />
My workaround to this problem is to create two different packages, one for rule1.drl and one for rule2.drl. So my program read these two rule by two different changeset.