05-30-2017 12:22 AM - edited 03-01-2019 03:51 AM
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
Solved! Go to Solution.
05-31-2017 08:49 AM
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
05-30-2017 03:06 AM
05-30-2017 03:14 AM
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
05-30-2017 03:20 AM
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.
05-30-2017 03:25 AM
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
05-30-2017 04:52 AM
That sounds about right.
05-30-2017 10:56 AM
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
05-30-2017 11:05 AM
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!
05-30-2017 11:24 AM
05-30-2017 12:54 PM
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
05-30-2017 01:00 PM
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.
05-30-2017 01:07 PM
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...
05-30-2017 01:09 PM
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...
05-31-2017 08:49 AM
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
05-31-2017 10:35 AM
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>
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide