[erlang-questions] ct_netconfc.erl: is this the expected behavior or is it a bug?

Siri Hansen <>
Tue Mar 11 13:58:45 CET 2014


Would this also work ?

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<rpc message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
    <edit-config>
        <target>
            <running/>
        </target>
        <config>
            <ElementA>
                <elementAId>1</elementAId>
                <elementB>
                    <elementB>1</elementB>
                    <elementC operation=\"delete\">
                        <elementCId>6</elementCId>
                    </elementC>
                </elementB>
            </ElementA>
        </config>
    </edit-config>
</rpc>


 i.e. without the 'xc' prefix (the netconf base namespace is the default
anyway). It's probably up to your netconf server if it can handle that or
not.

Ideally it should be something like:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<rpc message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
    <edit-config>
        <target>
            <running/>
        </target>
        <config>
            <ElementA xmlns=\"mynamespace\"
xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
                <elementAId>1</elementAId>
                <elementB>
                    <elementB>1</elementB>
                    <elementC xc:operation=\"delete\">
                        <elementCId>6</elementCId>
                    </elementC>
                </elementB>
            </ElementA>
        </config>
    </edit-config>
</rpc>

where "mynamespace" defines your own config data. This can be expressed in
the erlang term like this:

Config =
{'ElementA',[{xmlns,"mynamespace"},{'xmlns:xc',"urn:ietf:params:xml:ns:netconf:base:1.0"}],
                     [{elementAId,[],["1"]},
                      {elementB,[],
                                [{elementB,[],["1"]},
                                 {elementC,[{'xc:operation',"delete"}],
                                           [{elementCId,[],["6"]}]}]}]},

(but you can probably skip the whole "mynamespace" business and just add
the {'xmlns:xc',..} part.

/siri


2014-03-11 11:15 GMT+01:00 Alexander Poulikakos <
>:

>  Hi erlang users
>
>
>
> I use the ct_netconfc client, from within Common Test.
>
>
>
> I'm communicating with a System Under Test (SUT), with the NETCONF
> protocol and I want to send a "delete" operation to delete some object.
> Example of my code:
>
> Config = {'ElementA',[],
>
>                      [{elementAId,[],["1"]},
>
>                       {elementB,[],
>
>                                 [{elementB,[],["1"]},
>
>                                  {elementC,[{'xc:operation',"delete"}],
>
>                                            [{elementCId,[],["6"]}]}]}]},
>
> {ok, Client}=ct_netconfc:open([{ssh, "some-ip-address"}, {port,
> some-port}, {user, "some-username"},{password,"some-password"}]),
>
> ct_netconfc:edit_config(Client, running, Config),
>
>
>
> Which gives me the following error message:
>
>
>
> {error,[{'error-type',[{xmlns,"urn:ietf:params:xml:ns:netconf:base:1.0"}],
>
>                       ["protocol"]},
>
>         {'error-tag',[{xmlns,"urn:ietf:params:xml:ns:netconf:base:1.0"}],
>
>                      ["operation-failed"]},
>
>
> {'error-severity',[{xmlns,"urn:ietf:params:xml:ns:netconf:base:1.0"}],
>
>                           ["error"]},
>
>
> {'error-message',[{xmlns,"urn:ietf:params:xml:ns:netconf:base:1.0"},
>
>                           {'xml:lang',"en"}],
>
>                          ["Malformed XML!!!"]}]}
>
>
>
>
>
> And the actual XML document (after processed by ct_netconfc) sent to my
> SUT looks as follow:
>
>
>
> <?xml version=\"1.0\" encoding=\"UTF-8\"?>
>
> <rpc message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
>
>     <edit-config>
>
>         <target>
>
>             <running/>
>
>         </target>
>
>         <config>
>
>             <ElementA>
>
>                 <elementAId>1</elementAId>
>
>                 <elementB>
>
>                     <elementB>1</elementB>
>
>                     <elementC xc:operation=\"delete\">
>
>                         <elementCId>6</elementCId>
>
>                     </elementC>
>
>                 </elementB>
>
>             </ElementA>
>
>         </config>
>
>     </edit-config>
>
> </rpc>
>
>
>
>
>
> According to examples in RFC6241 [ http://tools.ietf.org/html/rfc6241  June 2011 page 41] the config element contains a namespace attribute xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0".
>
> So if I add it to the xml document (as below) and manually send it to my SUT, then it works.
>
>
>
> <?xml version=\"1.0\" encoding=\"UTF-8\"?>
>
> <rpc message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
>
>     <edit-config>
>
>         <target>
>
>             <running/>
>
>         </target>
>
>         <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
>
>             <ElementA>
>
>                 <elementAId>1</elementAId>
>
>                 <elementB>
>
>                     <elementB>1</elementB>
>
>                     <elementC xc:operation=\"delete\">
>
>                         <elementCId>6</elementCId>
>
>                     </elementC>
>
>                 </elementB>
>
>             </ElementA>
>
>         </config>
>
>     </edit-config>
>
> </rpc>
>
>
>
> So question is, how do I add the namespace attribute using
> ct_netconfc:edit_config/3? Or is there any other way of doing it?
>
>  Regards,
>
> Alex (erlang newbie)
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140311/3a84766c/attachment.html>


More information about the erlang-questions mailing list