OpenDayLight Oxygen Netconf mount data-missing error - opendaylight

I am using ODL oxygen release to connect a netopeer-server (NETCONF host) using the below curl command. I see the following error being returned. May I know what exactly is wrong? netopeer server supports netconf-monitoring.
{"errors":{"error":[{"error-type":"protocol","error-tag":"data-missing","error-message":"Mount point does not exist."}]}}
curl -H "Content-Type: application/xml" -u admin:admin -X POST -d "<?xml version=\"1.0\" encoding=\"UTF-8\"> <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">prefix:sal netconf-connector</type>
<name>netopeer</name>
<address xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">192.168.56.101</address>
<port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">830</port>
<username xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">netopeer-server</username>
<password xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">pass</password>
<tcp-only xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">true</tcp-only>
<event-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
<name>global-event-executor</name>
</event-executor>
<binding-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
<name>binding-osgi-broker</name>
</binding-registry>
<dom-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
<name>dom-broker</name>
</dom-registry>
<client-dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
<name>global-netconf-dispatcher</name>
</client-dispatcher>
<processing-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
<name>global-netconf-processing-executor</name>
</processing-executor>
<keepalive-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:scheduled-threadpool</type>
<name>global-netconf-ssh-scheduled-executor</name>
</keepalive-executor>
</module>" http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules
I did try the suggested changes. COuld you please tell me what is wrong with the input? I do not see anything obvious!
curl -H "Content-Type: application/xml" -u admin:admin -X PUT -d "<?xml version=\"1.0\" encoding=\"UTF-8\"><node xmlns=\"urn:TBD:params:xml:ns:yang:network-topology\">
<node-id>netopeer</node-id>
<host xmlns=\"urn:opendaylight:netconf-node-topology\">192.168.56.101</host>
<port xmlns=\"urn:opendaylight:netconf-node-topology\">830</port>
<username xmlns=\"urn:opendaylight:netconf-node-topology\">netopeergui</username>
<password xmlns=\"urn:opendaylight:netconf-node-topology\">netopeergui</password>
<tcp-only xmlns=\"urn:opendaylight:netconf-node-topology\">false</tcp-only>
</node>" http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/netopeer
{"errors":{"error":[{"error-type":"protocol","error-tag":"malformed-message","error-message":"**Error parsing input: A pseudo attribute name is expected.** ","error-info":"A pseudo attribute name is expected. "}]}}shrikanth#mds:~/Applications/karaf-0.8.1/bin$
This worked after adding the ? at to the xml tag as below
curl -H "Content-Type: application/xml" -u admin:admin -X PUT -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><node xmlns=\"urn:TBD:params:xml:ns:yang:network-topology\">
<node-id>netopeer</node-id>
<host xmlns=\"urn:opendaylight:netconf-node-topology\">192.168.56.101</host>
<port xmlns=\"urn:opendaylight:netconf-node-topology\">830</port>
<username xmlns=\"urn:opendaylight:netconf-node-topology\">netopeergui</username>
<password xmlns=\"urn:opendaylight:netconf-node-topology\">netopeergui</password>
<tcp-only xmlns=\"urn:opendaylight:netconf-node-topology\">false</tcp-only>
</node>" http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/netopeer

This seems like old way of mounting devices through config sub-system, can you try with this more recent API: http://docs.opendaylight.org/en/stable-oxygen/user-guide/netconf-user-guide.html#netconf-connector-configuration-with-md-sal

Related

Send data to API containing special characters

I am trying to send JSON data containing a mac address to an api using this command:
$value={ "pcModel": "KAT12", "displayType": "DELL U2311H", "graphicsType": "Microsoft Remote Display Adapter", "displayServiceTag": "HV8XP08Q079L", "ipAddress": "172.16.4.194", "recDate": "2022-10-06 16:57:55", "serviceTag": "18LQ9X1;Diskwear:(4.91TBW ; 15393 Hours)", "wolMode": "lanwithpxeboot;CC:101010-0118ZH;os:Ubuntu", "sleepState": "disable", "macAddress": "90:B1:1C:8E:D5:11", "hostName": "CI-KR95-05", "diskMode": "raid", "diskType": "Samsung SSD 850 PRO 512GB;TBW+Hrs:(4.91TB;15393 HrH) ;Clock:3.4GHz;Max Clock:3.67GHz(108%);RAM:32GB" }
curl -X "PUT" -H "Accept: application/json" -H "Authorization: Token 62d85330rf562c4cd6c1fb1a64d1" -d "$value" --url "https://my_api.org/api/inventory/84:2b:2b:a0:0s2:18
but I get the following answer:
user#ubuntu:~$ curl -X "PUT" -H "Accept: application/json" -H "Authorization: Token 62d85df90210cd1a827bc1518c4cd6c1fb1a64d1" -d "$value" --url "https:/my_api/api/inventory/84:2b:2b:a0:0s2:18"
curl: (3) URL using bad/illegal format or missing URL
I tried to escape the ":" colon characters with \ like this
curl -X "PUT" -H "Accept: application/json" -H "Authorization: Token 62d85330rf562c4cd6c1fb1a64d1" -d "$value" --url "https://my_api.org/api/inventory/84\:2b\:2b\:a0\:0s\:18"
but I get no output and it sends nothing.
any Idea how to send this data without having the bad format error?
Thanks a lot
I removed the "?" from $value and added single quotes.
Try this:
#!/bin/bash
value='{ "pcModel": "KAT12", "displayType": "DELL U2311H", "graphicsType": "Microsoft Remote Display Adapter", "displayServiceTag": "HV8XP08Q079L", "ipAddress": "172.16.4.194", "recDate": "2022-10-06 16:57:55", "serviceTag": "18LQ9X1;Diskwear:(4.91TBW ; 15393 Hours)", "wolMode": "lanwithpxeboot;CC:101010-0118ZH;os:Ubuntu", "sleepState": "disable", "macAddress": "90:B1:1C:8E:D5:11", "hostName": "CI-KR95-05", "diskMode": "raid", "diskType": "Samsung SSD 850 PRO 512GB;TBW+Hrs:(4.91TB;15393 HrH) ;Clock:3.4GHz;Max Clock:3.67GHz(108%);RAM:32GB" }'
curl -X "PUT" -H "Accept: application/json" -H "Authorization: Token 62d85330rf562c4cd6c1fb1a64d1" -d "$value" --url "https://my_api.org/api/inventory/84:2b:2b:a0:0s2:18"
Didn't your mother teach you how to format?
value='{
"pcModel": "KAT12",
"displayType": "DELL U2311H",
"graphicsType": "Microsoft Remote Display Adapter",
"displayServiceTag": "HV8XP08Q079L",
"ipAddress": "172.16.4.194",
"recDate": "2022-10-06 16:57:55",
"serviceTag": "18LQ9X1;Diskwear:(4.91TBW ; 15393 Hours)",
"wolMode": "lanwithpxeboot;CC:101010-0118ZH;os:Ubuntu",
"sleepState": "disable",
"macAddress": "90:B1:1C:8E:D5:11",
"hostName": "CI-KR95-05",
"diskMode": "raid",
"diskType": "Samsung SSD 850 PRO 512GB;TBW+Hrs:(4.91TB;15393 HrH) ;Clock:3.4GHz;Max Clock:3.67GHz(108%);RAM:32GB"
}'
$value is not a legal variable name in bash for declaration, only when you want to look it up. use value=
Also, you are missing a " after the URL.
$ curl "http:/cake.com/nom-nom
> "
curl: (3) URL using bad/illegal format or missing URL
The protocol schema is followed by colon-slash-slash ://. so you need one more:
https://
Maybe you want to read the URL rfc:
https://www.ietf.org/rfc/rfc2718.txt
2.1.2 Improper use of "//" following ":"
Contrary to some examples set in past years, the use of double
slashes as the first component of the of a URL
is not simply an artistic indicator that what follows is a URL:
Double slashes are used ONLY when the syntax of the URL's contains a hierarchical structure as described in RFC
2396. In URLs from such schemes, the use of double slashes indicates that what follows is the top hierarchical element for a
naming authority. (See section 3 of RFC 2396 for more details.)
URL schemes which do not contain a conformant hierarchical
structure in their should not use double
slashes following the ":" string.
Thanks for your answers.
I found the reasons why my code was not updating the API
1 - I needed to specify the "Content-Type: "application/json" parameter to tell the API that the data sent hat JSON format otherwise I saw in verbose mode that the data has a "x-www-form-urlencoded" format that the API can't understand.
2 - The data sent with curl must accept a value with the format like this
value='{
"pcModel": "KAT12",
"displayType": "DELL U2311H",
"diskType": "Samsung SSD .."
}'
3 - The curl request must be sent with double quotes around the url and the data ""
So the end request looks like this:
curl -k -X "PUT" -H "Content-Type: application/json"\
-H "Accept: application/json" -H "Authorization: Token 62d85df902101828g84kc4cd6c1fb1a64d1" \
--url "https://my_api.org/api/inventory/84:2b:2b:a0:0s2:18" \
-d "$value"

Call variable in CURL Command

I am trying to define a variable for a curl command.
curl --location -k --request GET 'https://myprojt.test9.abc.com/api/part/config=8594&select=parts,Action,refernceNumber&SalesID=333&partNumber=789-635'
I want to call a variable for &partNumber=789-635
Tried defining $part='#option.partnumber#', this is the input parameter which takes a value.
curl --location -k --request GET 'https://myprojt.test9.abc.com/api/part/config=8594&select=parts,Action,refernceNumber&SalesID=333&partNumber=$part'
I even tried replacing single quotes (') by double (") but not working, kindly help.
You can assign directly like MYVAR=#option.myoption#
I leave a working example:
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='myoption' value='world' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<executionEnabled>true</executionEnabled>
<id>e781836f-e0f8-4ccb-b03f-a384be306860</id>
<loglevel>INFO</loglevel>
<name>JobInlineScript</name>
<nodeFilterEditable>false</nodeFilterEditable>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<fileExtension>.sh</fileExtension>
<script><![CDATA[# starting
MYVAR=#option.myoption#
# print
echo "hello $MYVAR"]]></script>
<scriptargs />
<scriptinterpreter>/bin/bash</scriptinterpreter>
</command>
</sequence>
<uuid>e781836f-e0f8-4ccb-b03f-a384be306860</uuid>
</job>
</joblist>
And here the result.

Content-Type header [application/x-www-form-urlencoded] is not support error when import json data into elastic

MY Code below
curl -XPOST "http://localhost:9200/test/p
ost/_bulk/" -d #City_collection.json
error:
{"error":"Content-Type header [application/x-www-form-urlencoded] is not support
ed","status":406}
You need to specify the content-type header like this
curl -XPOST "http://localhost:9200/test/post/_bulk/" -H "Content-Type: application/json" -d #City_collection.json
^
|
add this

Performing multiple requests using curl, with different options

I'm trying to use curl to upload a file to sharepoint. I can do this successfully in three steps (ie. 3 separate invocations of curl to check the file out, upload it, and check it back in), using the suggestions in the following post:
How to check-out a file from sharepoint document library using curl?
My individual requests look like:
# Checkout the index.html file
curl --ntlm --user ${USER} \
--data #- \
-H "SOAPAction: http://schemas.microsoft.com/sharepoint/soap/CheckOutFile" \
-H "Content-Type: text/xml; charset=utf-8" \
${SHAREPOINT}/_vti_bin/Lists.asmx << EOF
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<CheckOutFile xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<pageUrl>${FILE}</pageUrl>
<checkoutToLocal>false</checkoutToLocal>
<lastmodified/>
</CheckOutFile>
</soap:Body>
</soap:Envelope>
EOF
# upload the file
curl --ntlm -u ${USER} \
-T HTML/2015/index.html \
${FOLDER}
curl --ntlm --user ${USER} \
--data #- \
-H "SOAPAction: http://schemas.microsoft.com/sharepoint/soap/CheckInFile" \
-H "Content-Type: text/xml; charset=utf-8" \
${SHAREPOINT}/_vti_bin/Lists.asmx << EOF
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CheckInFile xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<pageUrl>${FILE}</pageUrl>
<comment>Automagic update</comment>
<checkinType>0</checkinType>
</CheckInFile>
</soap:Body>
</soap:Envelope>
EOF
Unfortunately, this results in cUrl asking me for my password 3 times (and it's a long password! :-) ). I also don't like the idea of a .netrc file, since writing passwords to disk is not a great idea.
So, what I thought I might be able to do is combine all of the requests into a single command line, setting and deleting headers as necessary, supplying the request bodies as appropriate using bash process substitution, etc.
curl --ntlm --user ${USER} \
--trace-ascii publish.log \
--data #<(echo "$CHECKOUT") \
-H "SOAPAction: http://schemas.microsoft.com/sharepoint/soap/CheckOutFile" \
-H "Content-Type: text/xml; charset=utf-8" \
${SHAREPOINT}/_vti_bin/Lists.asmx \
-H "SOAPAction:" \
-H "Content-Type:" \
-T HTML/2015/index.html \
${FOLDER} \
--data #<(echo "$CHECKIN") \
-H "SOAPAction: http://schemas.microsoft.com/sharepoint/soap/CheckInFile" \
-H "Content-Type: text/xml; charset=utf-8" \
${SHAREPOINT}/_vti_bin/Lists.asmx
Unfortunately, what happens is that cUrl seems to process all of the options at once, and only then attempt to request the URL's, resulting in options for one URL overwriting options for another URL, and ultimately nothing working. A snippet from the log file:
> 0000: PUT /xxx/xxx/_vti_bin/Lists.asmx HTTP/1.1
> 0033: Authorization: NTLM AAAAAAAAAAA=
> 0075: User-Agent: curl/7.30.0
> 008e: Host: example.com
> 00a8: Accept: */*
> 00b5: SOAPAction: http://schemas.microsoft.com/sharepoint/soap/CheckOu
> 00f5: tFile
> 00fc: Content-Type: text/xml; charset=utf-8
> 0123: SOAPAction: http://schemas.microsoft.com/sharepoint/soap/CheckIn
> 0163: File
> 0169: Content-Type: text/xml; charset=utf-8
> 0190: Content-Length: 0
> 01a3: Expect: 100-continue
Notice the duplicated SOAPAction header, while I was hoping to only have the first options applied.
Is there any way to say "stop processing options now, do this URL, then carry on"?
If typing password three times is your only concern, you can prompt for the password and read it in a variable and use it in curl command as like below.
echo "Password: "
read -s PASSWORD
# Checkout the index.html file
curl --ntlm --user ${USER}:${PASSWORD} \
--data #- \
-H "SOAPAction: http://schemas.microsoft.com/sharepoint/soap/CheckOutFile" \
-H "Content-Type: text/xml; charset=utf-8" \
${SHAREPOINT}/_vti_bin/Lists.asmx << EOF
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CheckOutFile xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<pageUrl>${FILE}</pageUrl>
<checkoutToLocal>false</checkoutToLocal>
<lastmodified/>
</CheckOutFile>
</soap:Body>
</soap:Envelope>
EOF
# upload the file
curl --ntlm -u ${USER}:${PASSWORD} \
-T HTML/2015/index.html \
${FOLDER}
curl --ntlm --user ${USER}:${PASSWORD} \
--data #- \
-H "SOAPAction: http://schemas.microsoft.com/sharepoint/soap/CheckInFile" \
-H "Content-Type: text/xml; charset=utf-8" \
${SHAREPOINT}/_vti_bin/Lists.asmx << EOF
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CheckInFile xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<pageUrl>${FILE}</pageUrl>
<comment>Automagic update</comment>
<checkinType>2</checkinType>
</CheckInFile>
</soap:Body>
</soap:Envelope>
EOF

Quickblox trying to get a sesssion

I've been trying to create a session, even with curl it's giving me something weird (I wiped app id and auth key out in this post):
curl -X POST \
-H "Content-Type: application/json" \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-d '{"application_id": "XXX", "auth_key": "XXXXXXXXXXXXXX", "timestamp": $(date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"), "nonce": "1236221330", "signature": "b51f77e6a233db78a3785e3cf8b27aa4e151bd96"}' \
https://api.quickblox.com/session.json
With this I'm getting back this HTML body:
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<h1>We're sorry, but something went wrong.</h1>
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
</div>
</body>
The example is pretty much straight from the doc, except the time stamp part. The signature has Anything I'm doing wrong?
Try this params format
-d "application_id=140&auth_key=7quWEh-k6TqghXe&timestamp=1326964049&nonce=414546828&signature=e6e603c251a569e70a2f27a8c71b5017e81e05d5"
not json body
This CURL example works OK
curl -X POST -H "Content-Type: application/json" -H "QuickBlox-REST-API-Version: 0.1.0"
-d '{"application_id":"1","auth_key":"gHT98dDU2zpkKej","nonce":"33432","timestamp":"1375384935","signature":"242f6407b4cd6f0b06d1bca67faac4b57eb21c26"}' http://api.quickblox.com/session.json
just type it in terminal

Resources