Hello,

Maybe you can try calling GET on 
vms/74a1a99f-87d1-4444-b394-f90e4f29f51f/diskattachments for testing purpose?
I suggest using REST client since it takes care of authentication when needed 
and to make sure the problem is not in the code. In dev environment ovirt uses 
basic authentication and that is something you have to set up when calling this 
API. For example, for admin user username would be admin@internal and password 
is whatever you specified during setup.

Fedor 

----- Original Message -----
From: [email protected]
To: [email protected]
Sent: Wednesday, September 18, 2019 3:39:28 PM
Subject: [ovirt-devel] [User is not authorized to perform this action.]

I am getting error as User is not authorized to perform this action.I am using 
oVirt api to manually attach a disk and snapshot  to another virtual 
machine.This the code i used.The API i followed is

'<disk_attachment>
                           <active>true</active>
                           <bootable>false</bootable>
                                <interface>virtio</interface>
                        <disk id="a94106b7-d348-4088-aaa1-5dfc46dc094e">
                    <snapshot id="6ecbb953-c4fb-4294-9988-e7cd2bd9b038"/>
                    <description>My disk</description>
                         <format>cow</format>
                                <name>mydisk</name>
                                  
                       </disk>
                        </disk_attachment>


==============================
The php code i have tried is ...

public function attachSnapshotandActivateDisk( ) {


        $data = array();

        $xmlStr = '<disk_attachment>
                           <active>true</active>
                           <bootable>false</bootable>
                                <interface>virtio</interface>
                        <disk id="a94106b7-d348-4088-aaa1-5dfc46dc094e">
                    <snapshot id="6ecbb953-c4fb-4294-9988-e7cd2bd9b038"/>
                    <description>My disk</description>
                         <format>cow</format>
                                <name>mydisk</name>
                                  
                       </disk>
                        </disk_attachment>
                                     ';

        $curlParam = array(
            "url" => "vms/74a1a99f-87d1-4444-b394-f90e4f29f51f/diskattachments",
            "method" => "POST",
            "data" => $xmlStr
        );

        //         $text = print_r($curlParam, true);
        //echo "<script>console.log( 'curl 
Parameter".json_encode($text)."');</script>";

        $data = $this->processCurlRequest($curlParam, "vm-create");

        // if instance update failed
        if ($data['status'] != 'success') {
            Common::ovirtLog(array(
                "requestParam" => $curlParam,
                "responseParam" => $data,
            ));
        }

// show the output of print_r function as a string
        //  $text = print_r($data, true);
        echo $data['message'];
        die;
        echo "<script type='text/javascript'> console.log('checking the attach 
snapshot activate disk function diskid=" . json_encode($data) . "') </script>";


        //Detach the disk
        //  $this->detachSnapshotDisk() ; 

        return $data;
    }


Please help me.
_______________________________________________
Devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Privacy Statement: https://www.ovirt.org/site/privacy-policy/
oVirt Code of Conduct: 
https://www.ovirt.org/community/about/community-guidelines/
List Archives: 
https://lists.ovirt.org/archives/list/[email protected]/message/42Z54W3JDZSTAN6PIOGWGGMVNZ5IDA47/
_______________________________________________
Devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Privacy Statement: https://www.ovirt.org/site/privacy-policy/
oVirt Code of Conduct: 
https://www.ovirt.org/community/about/community-guidelines/
List Archives: 
https://lists.ovirt.org/archives/list/[email protected]/message/LXAX63LLZCQKR4H2WCSCDCYGJRXGXYOQ/

Reply via email to