[Engine-devel] ovirt-engine-sdk with C

wlbleaboy@126 wlbleaboy at 126.com
Fri Jun 7 09:47:48 UTC 2013


Hi, Jarod.W:

         Thanks for your demo, but I think you miss two fucntinos like this:

 

curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);

         curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);

 

the following new demo code on my ubuntu is work well:

#include <stdio.h>

#include <curl/curl.h>

 

int main(void)

{

    CURL *curl;

    CURLcode res;

 

    curl_global_init(CURL_GLOBAL_DEFAULT);

 

    curl = curl_easy_init();

    if(curl)

    {

        curl_easy_setopt(curl, CURLOPT_URL, "https://192.168.1.201/api/");

        curl_easy_setopt(curl, CURLOPT_USERPWD, "admin at internal:111111");

        curl_easy_setopt(curl, CURLOPT_CAINFO,"/tmp/ca.crt");

 

        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);

        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);

 

        res = curl_easy_perform(curl);

 

        if(res != CURLE_OK)

            fprintf(stderr, "curl_easy_perform() failed: %s\n",

                    curl_easy_strerror(res));

 

        curl_easy_cleanup(curl);

    }

 

    curl_global_cleanup();

 

    return 0;

}

 

when I add this two functions , it works well for admin at internal

but can’t work for user portal, I check the information sent by 

admin at internal and user portal, the only difference is Filter,

admin at internal is Filter:False, the user portal is Filter:True.

 

How can I use curl_easy_setopt to set Filter .

 

                            Thanks

                                               Leaboy

 

From: Jarod. w [mailto:work.iec23801 at gmail.com] 
Sent: Wednesday, June 05, 2013 11:35 AM
To: wlbleaboy at 126
Cc: engine-devel at ovirt.org
Subject: Re: Re: [Engine-devel] ovirt-engine-sdk with C

 

2013/6/5 wlbleaboy at 126 <wlbleaboy at 126.com>

Hi, Jarod. W:

         I got your demo, and a build libcurl, but I can’t get any info

from https://{ovirt-engine }/api .

my code like this:

Please try to run the below command:
--
curl https://YOURIP/api -u YOURNAME:YOURPASSWD --cacert /root/ca.crt
--

After, please parse the result.

ps, I run the program on centos 6.4, and it works.

thanks.
 

int main(void)

{

    CURL *curl;

    CURLcode res;

    curl = curl_easy_init();

 

    if (curl)

    {

        printf("enter....\n");

        curl_easy_setopt(curl, CURLOPT_URL, "https://192.168.1.201/api");

        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback_func);

        curl_easy_setopt(curl, CURLOPT_USERPWD, "admin at internal:111111");

        curl_easy_setopt(curl, CURLOPT_CAINFO,"/tmp/ca.crt");

        curl_easy_perform(curl);

        printf("exit.....\n");

 

        curl_easy_cleanup(curl);

    }

 

    return 0;

}

 

And when I run it, just outpu :

enter....

exit.....

 

I got the libcurl from http://curl.haxx.se/download.html and chosed curl-7.30.0.tar.gz <http://curl.haxx.se/download.html%20and%20chosed%20curl-7.30.0.tar.gz> 

and I use make and make install without any other options . I just guess maybe it need

other SSL library supported, but I don’t know how and which .

 

发件人: Jarod. w [mailto:work.iec23801 at gmail.com] 

发送时间: 2013年6月4日 18:14
收件人: wlbleaboy at 126
抄送: engine-devel at ovirt.org
主题: Re: 答复: [Engine-devel] ovirt-engine-sdk with C

 

2013/6/4 wlbleaboy at 126 <wlbleaboy at 126.com>

Hi, Jarod. W:

    Yes, I just want to use c to invoke ovirt engine RestAPI,

Just get vm’s id, host, port, secur-port, and ticket,

    How can I use libcurl to connect https, could give me

a simple demo to connect https://{ovirt-engine}/api <https://%7bovirt-engine%7d/api>  with 

--cafile, the ca.crt I get from http://{ovirt-engine}/ca.crt <http://%7bovirt-engine%7d/ca.crt> 

Please download the demo from the above url:
https://github.com/jarod-w/hglibraries/blob/master/demo/restapi.c
 

 

 

发件人: Jarod. w [mailto:work.iec23801 at gmail.com] 
发送时间: 2013年5月14日 10:27
收件人: leaboy at 126
抄送: engine-devel at ovirt.org
主题: Re: [Engine-devel] ovirt-engine-sdk with C

 

2013/5/13 leaboy at 126 <wlbleaboy at 126.com>

Hi,All

         I felt oivrt-engine-sdk coded with Python is slowly to connect

ovirt-engine and console vm when a user have many vms, So, I just

want to rewrite the sdk with C(ANSI C Language). Just rewrite a sdk

with C to connect overt-engine and console vm, would anyone give 

me some suggestion.

Do you want to use c to invoke ovirt engine RestAPI, right?

If yes, you can use libcurl to do the thing, and it'll make you happy.

 

 

         Now, the problem is how can I connect to ovit-engine with C, and

how can I get some information of vms, and how ovirrt-engine can 

respond my action(start,stop, .eg)

Agree with Michael Pasternak.

You should parse your code into the mail list, or someone can't help

you.

 

 

                                                                                    Leaboy at beijing

                                                                 Thinks


_______________________________________________
Engine-devel mailing list
Engine-devel at ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-devel




-- 
---
Best Regards
Jarod.W




-- 
---
Best Regards
Jarod.W




-- 
---
Best Regards
Jarod.W

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/devel/attachments/20130607/4f4bbf25/attachment-0001.html>


More information about the Devel mailing list