cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1196
Views
1
Helpful
14
Replies

NSO REST API - Adding VNFD/VNFR/VNF-INFO/ESC-Template

akaliwod@cisco.com
Cisco Employee
Cisco Employee

Hey, I would like to use REST API to add new deployment to NSO.

As far as I understand, depending on the NFVO package version, I can either use VNFD/VNFR/ESC-Template or VNFD/VNF-Info/ESC-Template. How can I check (via REST API) what type of XML files I should use?

Is there any way I can run syntax/dry-run checks on my files using NSO REST API?

Lastly, how can I upload these XML files using REST API?

Thank you very much for help

Kali

1 Accepted Solution

Accepted Solutions

I think i narrowed down the problem. Things are working fine unless I have to use xmlns in the XML payload. So for example if I need to send something like:

<internal-connection-point-descriptor>

<id>right-int</id>

<external-connection-point-descriptor>right-ext</external-connection-point-descriptor>

<layer-protocol>IPv4</layer-protocol>

<interface-id xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo-esc">2</interface-id>

</internal-connection-point-descriptor>

Then REST API throws error. If I do _NOT_ have xmlns in XML code, then payload is accepted and added to running config.

However, if I don’t use xmlns in <interface-id> or <management> then these lines throw an error too. So effectively I have no clue how I can add these configuration lines via REST API.

I have tried to escape this xmlns, remove the “, change “ to ‘… none works.

Any advice please?

Thanks

Kali

View solution in original post

14 Replies 14

frjansso
Cisco Employee
Cisco Employee

Hi!

I've attached a Postman collection that demonstrates a few interactions with NFVO using REST.

The VNFR interface is deprecated and if you install NFVO-rel2, it's not available.

Hi Fredrik, thank you very much for answer.

The example REST APIs that you posted use json format when uploading NSINFO. Is it possible to upload VNFD and other files in XML format too (using REST API)?

Thanks

Yes!

Easiest is to export to XML from the CLI and use as a starting point:

(show XXX | display xml | save xxx.xml)

Modify the XML (you'll see what tags to keep if you compare to the JSON examples) and change the content-type in the request and you should be good to go.

Following your postman examples, I would need to do something like the following:

"url": "http://localhost:8080/api/running/nfvo/ns-info/esc/ns-info/MyNSInfo",

"method": "PUT",

...

"value": "application/vnd.yang.data+xml"

...

then in body i just put the content of xml file?

Kali

That sounds about right.

Something is wrong and i have no clue what's going on...

I have taken working vnfd using "display xml" and saved it to file.

then i loaded the file as body to POST and this is what i get:

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

  <error>

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

    <error-urlpath>/api/running/nfvo</error-urlpath>

    <error-message>unknown element: nfvo in /nfvo-rel2:nfvo/nfvo-rel2:nfvo</error-message>

  </error>

</errors>

Do you know why?

Thanks

Kali

I think it might have to do where i post (url) and what exactly i post (syntax)

so here are the details

http://192.168.23.23:8080/api/running/nfvo

running

{'Content-Type': 'application/vnd.yang.data+xml'}

<config xmlns="http://tail-f.com/ns/config/1.0">

  <nfvo xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo">

  <vnfd>

    <id>vrouter-vnfd</id>

    <provider>Cisco</provider>

    <product-name>vCSR</product-name>

    <version>1.0</version>

    <product-info-name>vCSR</product-info-name>

    <product-info-description>Router based on virtual appliance</product-info-description>

    <vdu>

      <id>CSR</id>

      <internal-connection-point-descriptor>

        <id>left-int</id>

        <external-connection-point-descriptor>left-ext</external-connection-point-descriptor>

        <layer-protocol>IPv4</layer-protocol>

        <interface-id xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo-esc">1</interface-id>

      </internal-connection-point-descriptor>

      <internal-connection-point-descriptor>

        <id>mgmt-int</id>

        <external-connection-point-descriptor>mgmt-ext</external-connection-point-descriptor>

        <layer-protocol>IPv4</layer-protocol>

        <interface-id xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo-esc">0</interface-id>

      </internal-connection-point-descriptor>

      <internal-connection-point-descriptor>

        <id>right-int</id>

        <external-connection-point-descriptor>right-ext</external-connection-point-descriptor>

        <layer-protocol>IPv4</layer-protocol>

        <interface-id xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo-esc">2</interface-id>

      </internal-connection-point-descriptor>

    </vdu>

    <external-connection-point-descriptor>

      <id>left-ext</id>

      <layer-protocol>IPv4</layer-protocol>

    </external-connection-point-descriptor>

    <external-connection-point-descriptor>

      <id>mgmt-ext</id>

      <layer-protocol>IPv4</layer-protocol>

      <management xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo-esc"/>

    </external-connection-point-descriptor>

    <external-connection-point-descriptor>

      <id>right-ext</id>

      <layer-protocol>IPv4</layer-protocol>

    </external-connection-point-descriptor>

    <deployment-flavor>

      <id>basic</id>

      <vdu-profile>

        <vdu>CSR</vdu>

        <min-number-of-instances>2</min-number-of-instances>

        <max-number-of-instances>4</max-number-of-instances>

      </vdu-profile>

      <instantiation-level>

        <id>basic</id>

        <vdu-level>

          <vdu>CSR</vdu>

          <number-of-instances>2</number-of-instances>

        </vdu-level>

      </instantiation-level>

    </deployment-flavor>

    <deployment-flavor>

      <id>minimal</id>

      <vdu-profile>

        <vdu>CSR</vdu>

        <min-number-of-instances>1</min-number-of-instances>

        <max-number-of-instances>5</max-number-of-instances>

      </vdu-profile>

      <instantiation-level>

        <id>minimal</id>

        <vdu-level>

          <vdu>CSR</vdu>

          <number-of-instances>1</number-of-instances>

        </vdu-level>

      </instantiation-level>

    </deployment-flavor>

  </vnfd>

  </nfvo>

</config>

Thanks!

You have to modify the XML, see the JSON examples.

I've updated the Postman file with a new example, "Create NS Info - XML".

I managed to do one step ahead but still it is not full success.

I have executed PUT REST API method. actually, i did not have to change the XML content. Previously, i was doing POST REST API.

However, the VNFD that I created, removed all other VNFDs that were in NSO before executing PUT. not sure why and not sure how i can successfully add VNFD.

Unfortunately i still don't undertstand what you exactly mean by changing the XML and why i need to modify it. I take this XML from show running | display xml. why even i would need to change it?

Thanks for help

Kali

Did you try the call as in the Postman collection?

When exporting the XML you get the entire tree from the root, the REST just wants the the sub-tree where you're posting/putting.

I have no clue how to use the example from postman file that you attached. I am using python code and send message to NSO using requests package.

On top of that, your example show NS-INFO. If you could give me the working example on how i can add new VNFD in XML format, maybe and hopefully that would help me to understand what i might be doing wrong...

Let me also ask differently.

when i PUT the content of XML file, it works however it replaces all VNFD entries.

when i POST the exactly same content of XML file, so the only change is from PUT to POST, then i have the errors... i completely fail to understand why...

I think i narrowed down the problem. Things are working fine unless I have to use xmlns in the XML payload. So for example if I need to send something like:

<internal-connection-point-descriptor>

<id>right-int</id>

<external-connection-point-descriptor>right-ext</external-connection-point-descriptor>

<layer-protocol>IPv4</layer-protocol>

<interface-id xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo-esc">2</interface-id>

</internal-connection-point-descriptor>

Then REST API throws error. If I do _NOT_ have xmlns in XML code, then payload is accepted and added to running config.

However, if I don’t use xmlns in <interface-id> or <management> then these lines throw an error too. So effectively I have no clue how I can add these configuration lines via REST API.

I have tried to escape this xmlns, remove the “, change “ to ‘… none works.

Any advice please?

Thanks

Kali

Fredrik,

Thank you for help. My mistake was not to include xmlns in the top level vnfd.

For reference the XML below works perfectly fine now.

Thanks

Kali

  <vnfd xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo">

    <id>test2-vnfd</id>

    <provider>Cisco</provider>

    <product-name>vCSR</product-name>

    <version>1.0</version>

    <product-info-name>vCSR</product-info-name>

    <product-info-description>Router based on virtual appliance</product-info-description>

    <external-connection-point-descriptor>

      <id>mgmt-ext</id>

      <layer-protocol>IPv4</layer-protocol>

      <management xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo-esc"/>

    </external-connection-point-descriptor>

    <external-connection-point-descriptor>

      <id>left-ext</id>

      <layer-protocol>IPv4</layer-protocol>

    </external-connection-point-descriptor>

    <external-connection-point-descriptor>

      <id>right-ext</id>

      <layer-protocol>IPv4</layer-protocol>

    </external-connection-point-descriptor>

    <deployment-flavor>

      <id>basic</id>

      <vdu-profile>

        <vdu>CSR</vdu>

        <min-number-of-instances>2</min-number-of-instances>

        <max-number-of-instances>4</max-number-of-instances>

      </vdu-profile>

      <instantiation-level>

        <id>basic</id>

        <vdu-level>

          <vdu>CSR</vdu>

          <number-of-instances>2</number-of-instances>

        </vdu-level>

      </instantiation-level>

    </deployment-flavor>

    <vdu>

      <id>CSR</id>

      <internal-connection-point-descriptor>

        <id>mgmt-int</id>

        <external-connection-point-descriptor>mgmt-ext</external-connection-point-descriptor>

        <interface-id xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo-esc">0</interface-id>

        <layer-protocol>IPv4</layer-protocol>

      </internal-connection-point-descriptor>

      <internal-connection-point-descriptor>

        <id>left-int</id>

        <external-connection-point-descriptor>left-ext</external-connection-point-descriptor>

        <interface-id xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo-esc">1</interface-id>

        <layer-protocol>IPv4</layer-protocol>

      </internal-connection-point-descriptor>

      <internal-connection-point-descriptor>

        <id>right-int</id>

        <external-connection-point-descriptor>right-ext</external-connection-point-descriptor>

        <interface-id xmlns="http://tail-f.com/pkg/tailf-etsi-rel2-nfvo-esc">2</interface-id>

        <layer-protocol>IPv4</layer-protocol>

      </internal-connection-point-descriptor>

    </vdu>

  </vnfd>

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 NSO Developer community: