cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
528
Views
0
Helpful
7
Replies

Seperating Service and Actions into two packages leading into REST problems

lweddewer
Contributor
Contributor

After developing a service we are starting to think about possible operational actions to opterate and monitor the service.

To optimze the development process and to reduce the complexity of the code I had the idea to seperate service and actions into two packages expecting that the actions package will be updated many times more in the beginning.

The seperation was easy and the result works fine on CLI.

But when I test this via REST using Postman something went wrong.

<input>

  <ping />

</input>

The some call which works fine when service and action are part  of one package delivers an unspecific

<errors xmlns="http://tail-f.com/ns/tailf-rest-error">

    <error>

        <error-tag>malformed-message</error-tag>

        <error-urlpath>/api/running/services/rfscl:rfs_cl_services/CL1234567890123/azure/rfs_cl_azure_actions:check-cl</error-urlpath>

        <error-message>Internal error</error-message>

    </error>

</errors>

Sending an empty input

<input>

</input>

<errors xmlns="http://tail-f.com/ns/tailf-rest-error">

    <error>

        <error-tag>malformed-message</error-tag>

        <error-urlpath>/api/running/services/rfscl:rfs_cl_services/CL1234567890123/azure/rfs_cl_azure_actions:check-cl</error-urlpath>

        <error-message>/services/rfs_cl_services/azure/check-cl can not be empty.</error-message>

    </error>

</errors>

The YANG-Modell in the orgininal service

module rfs-cl-services {

  namespace "http://example.com/rfs-cl-services";

  prefix rfscl;

....

choice c_container {

     container azure {
         presence "this cl uses azure";
uses ncs:service-data;
ncs:servicepoint rfs-cl-services-servicepoint; 

.....

tailf:action check_cl {
tailf:actionpoint rfs-cls-action-cl-check;
input {
choice function {
leaf ping {
type empty;
}
}
}
output {
leaf result {
type string;
}
}
}

The code I copied form the original service into a seperate module:

module rfs_cl_azure_actions {

...

augment /ncs:services/rfscl:rfs_cl_services/rfscl:c_container/rfscl:azure/rfscl:azure {

tailf:action check_cl {

tailf:actionpoint rfs-cls-action-cl-check; 

input {

choice function {

leaf ping {

type empty;

}

}

}

output {

leaf result {

type string;

}

}

} // augment /ncs:services/rfs_cl_services/azure/ {

}

In both cases  there is no log in the action package.

If I drop the input tags in the inputfile I see the expected error logs in the action package.

Regards

Lothar

7 REPLIES 7

Jan Lindblad
Cisco Employee
Cisco Employee

The idea to separate the functionality into two packages makes sense, and I don't really think that is what is causing trouble here. It is hard to say what's wrong, however, based on only the information above. If you share which calls work fine, and what you tried that fails, add to that the relevant YANG, we may have a chance at commenting.

Hi Jan,

good to here I'm not totally on the wrong way.

Have inserted the path of the yang-files  with are related to the action.

To clearify it this was only a prof of concept for the idea of seperating services and actions.

And as I mentions both variants worked fine when making the request via cli. Same call, same result.

It was more per accident that I started the postman and tryed the old call worked fine before with all in one service ones again and it doesn't work.

I've tryed to find a solution by modifing different things ( Changing '_' to '-' in the name, preplacing leaf ping by container ping ...) but with no effect.

Regards

Lothar

Thanks for hinting at the YANG, that will be important in figuring out what's going on. It's not enough so that anyone could replicate your issues, but ok, it's not clear yet that that will be needed.

The error message says malformed-message, but you are still not providing the message you are sending, so it remains hard to say what's wrong with it. You should not be changing any names. Well, you may need to URL encode a few things.

Hi Jan,

here is the  call an the results:

1) action in the same package as the service code:

admin@ncs> request services rfs_cl_services CL1234567890123 azure check_cl ping

result Ping results:

ccr (simce8)

> ping 44.40.40.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 44.40.40.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/20/21 ms

simce8#

ccr (simce9)

> ping 44.40.40.6

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 44.40.40.6, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/20/21 ms

simce9#

[ok][2018-07-16 09:43:43]

admin@ncs>

the REST-Call

lab@NSO-VM1:~$ curl -i -u admin:admin http://10.213.80.171:8080/api/running/services/rfs_cl_services/CL1234567890123/azure/_operations/check_cl

     -X POST -H "Accept: application/vnd.yang.data+xml"

     -H "Content-Type: application/vnd.yang.operation+xml"

     -d "<input><ping /></input>"

HTTP/1.1 200 OK

Server:

Date: Mon, 16 Jul 2018 07:44:04 GMT

Cache-Control: private, no-cache, must-revalidate, proxy-revalidate

Content-Length: 586

Content-Type: application/vnd.yang.operation+xml

Vary: Accept-Encoding

Pragma: no-cache

<output xmlns='http://ipls.dtag.de/ucg/rfs-cl-services'>

  <result>Ping results:

ccr (simce8)

> ping 44.40.40.2&#13;

Type escape sequence to abort.&#13;

Sending 5, 100-byte ICMP Echos to 44.40.40.2, timeout is 2 seconds:&#13;

!!!!!&#13;

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/20/21 ms&#13;

simce8#

ccr (simce9)

> ping 44.40.40.6&#13;

Type escape sequence to abort.&#13;

Sending 5, 100-byte ICMP Echos to 44.40.40.6, timeout is 2 seconds:&#13;

!!!!!&#13;

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/20/21 ms&#13;

simce9#

</result>

</output>

lab@NSO-VM1:~$

And the same calls with the actions in a separate package:

admin@ncs> request services rfs_cl_services CL1234567890123 azure check_cl ping

result Ping results:

ccr (simce8)

> ping 44.40.40.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 44.40.40.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/20/21 ms

simce8#

ccr (simce9)

> ping 44.40.40.6

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 44.40.40.6, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/20/21 ms

simce9#

[ok][2018-07-16 09:39:13]

admin@ncs>

lab@NSO-VM1:~$ curl -i -u admin:admin http://10.213.80.171:8080/api/running/services/rfs_cl_services/CL1234567890123/azure/_operations/check_cl

     -X POST -H "Accept: application/vnd.yang.data+xml"

     -H "Content-Type: application/vnd.yang.operation+xml"

     -d "<input><ping /></input>"

HTTP/1.1 400 Bad Request

Server:

Date: Mon, 16 Jul 2018 07:39:33 GMT

Cache-Control: private, no-cache, must-revalidate, proxy-revalidate

Content-Length: 313

Content-Type: text/xml

Vary: Accept-Encoding

Pragma: no-cache

<errors xmlns="http://tail-f.com/ns/tailf-rest-error">

  <error>

    <error-tag>malformed-message</error-tag>

    <error-urlpath>/api/running/services/rfscl:rfs_cl_services/CL1234567890123/azure/rfs_cl_azure_actions:check_cl</error-urlpath>

    <error-message>Internal error</error-message>

  </error>

</errors>

lab@NSO-VM1:~$

Any idea?It is the same curl call in both tests!

(I added the new lines in the curl call afterwards to make the ruselt more readable. )

Regards

Lothar

Did you comment out/remove the original check_cl action, the one in rfs-cl-services? Otherwise there would be two check_cl at the same location in the tree, and you are not specifying which one to use in your curl call. One thing you could try is to actually specify rfs_cl_azure_actions:check_cl in your curl call. Another thing you could try is to switch from the non-standard REST API to the standard RESTCONF API instead.



Hi Jan,

yes I've commented out both the action in the service modell of the rfs-cl-services and the register_action in the python code.

I also tried your second idea. Same error:

lab@NSO-VM1:~$ curl -i -u admin:admin http://10.213.80.171:8080/api/running/services/rfs_cl_services/CL1234567890123/azure/_operations/rfs_cl_azure_actions:check_cl \

>     -X POST \

> -H "Accept: application/vnd.yang.data+xml" \

> -H "Content-Type: application/vnd.yang.operation+xml" \

> -d "<input><ping /></input>"

HTTP/1.1 400 Bad Request

Server:

Date: Mon, 16 Jul 2018 14:10:02 GMT

Cache-Control: private, no-cache, must-revalidate, proxy-revalidate

Content-Length: 313

Content-Type: text/xml

Vary: Accept-Encoding

Pragma: no-cache

<errors xmlns="http://tail-f.com/ns/tailf-rest-error">

  <error>

    <error-tag>malformed-message</error-tag>

    <error-urlpath>/api/running/services/rfscl:rfs_cl_services/CL1234567890123/azure/rfs_cl_azure_actions:check_cl</error-urlpath>

    <error-message>Internal error</error-message>

  </error>

</errors>

lab@NSO-VM1:~$

I'll try to test with the RESTCONF API tomorrow.

Regards

Lothar

Hi Jan,

same picture with restconf:

in one Serives:

lab@NSO-VM1:~$ curl -i -u admin:admin http://10.213.80.171:8080/restconf/data/services/rfs_cl_services=CL1234567890123/azure/check_cl -X POST -H "Accept: application/yang-data+xml" -H "Content-Type: application/yang-data+xml" -d "<input><ping /></input>"

HTTP/1.1 200 OK

Server:

Date: Mon, 16 Jul 2018 15:11:47 GMT

Cache-Control: private, no-cache, must-revalidate, proxy-revalidate

Content-Length: 586

Content-Type: application/yang-data+xml

Vary: Accept-Encoding

Pragma: no-cache

<output xmlns='http://ipls.dtag.de/ucg/rfs-cl-services'>

  <result>Ping results:

ccr (simce8)

> ping 44.40.40.2&#13;

Type escape sequence to abort.&#13;

Sending 5, 100-byte ICMP Echos to 44.40.40.2, timeout is 2 seconds:&#13;

!!!!!&#13;

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/20/21 ms&#13;

simce8#

ccr (simce9)

> ping 44.40.40.6&#13;

Type escape sequence to abort.&#13;

Sending 5, 100-byte ICMP Echos to 44.40.40.6, timeout is 2 seconds:&#13;

!!!!!&#13;

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/20/21 ms&#13;

simce9#

</result>

</output>

lab@NSO-VM1:~$

in two services:

lab@NSO-VM1:~$ curl -i -u admin:admin http://10.213.80.171:8080/restconf/data/services/rfs_cl_services=CL1234567890123/azure/check_cl \

> -X POST \

> -H "Accept: application/yang-data+xml" \

> -H "Content-Type: application/yang-data+xml" \

> -d "<input><ping /></input>"

HTTP/1.1 400 Bad Request

Server:

Date: Mon, 16 Jul 2018 15:09:09 GMT

Cache-Control: private, no-cache, must-revalidate, proxy-revalidate

Content-Length: 359

Content-Type: application/yang-data+xml

Vary: Accept-Encoding

Pragma: no-cache

<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">

  <error>

<error-message>Internal error</error-message>
<error-path>/tailf-ncs:services/rfs-cl-services:rfs_cl_services=CL1234567890123/azure/rfs_cl_azure_actions:check_cl</error-path>
<error-tag>malformed-message</error-tag>
<error-type>application</error-type>

  </error>

</errors>

lab@NSO-VM1:~$

Regards

Lothar

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: