cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
736
Views
5
Helpful
2
Replies

How to Python actionpoint to return a list of objects

lnunesdo
Cisco Employee
Cisco Employee

Hi team!

 

I have an actionpoint developed in Python that should return a list of strings.

Here's the piece from YANG:

module teste {
    namespace "http://example.com/teste";
    prefix teste;

    import ietf-inet-types { prefix inet; }

    import tailf-common { prefix tailf; }
    
    import tailf-ncs { prefix ncs; }

    augment /ncs:services {

        container action {
          
            tailf:action check {
                tailf:actionpoint teste-action;
                input {
                    leaf-list keypaths {
                        type string;
                    }
                }
                output {
                    container result {
                        list service-types {
                            leaf name {
                                type string;
                            }

                        }
                    }
                }
            }
        }
    }
}

But I'm not able to find a way to return that list. The expected result is something like this:

<output xmlns='http://cisco.com'>
    <result>
        <service-types>
            <name>STAGING</name>
        </service-types>
        <service-types>
            <name>OSPF-OVERLAP</name>
        </service-types>
    </result>
</output>

In the action point Class, the output parameter is a Container. 

 

Can anybody help me?

 

Thanks in advance!

1 Accepted Solution

Accepted Solutions

I found the issue! In the YANG, the list service-types hadn't the key, so the output container had a keyless list which didn't permit including result names.

 

I fixed it and everything is working now!

 

Tks

View solution in original post

2 Replies 2

snovello
Cisco Employee
Cisco Employee
you need something like

output.staging_parameter.create(‘STAGING”)
output.staging_parameter.create(‘OSPF-OVERLAP”)

just use the maagic API to populate the content of that output container.

I found the issue! In the YANG, the list service-types hadn't the key, so the output container had a keyless list which didn't permit including result names.

 

I fixed it and everything is working now!

 

Tks