VMware {code} Community
admin
Immortal
Immortal
Jump to solution

Struggeling with the first steps on php vcloud sdk

hi,

i tried to run a sample (login.php) from the vcloud sdk for php sample kit.

when try i get the following message:

root@lamp vcloudPHP-1.5.0/samples# php login.php -s <myserver> -u <admin@org> -p <password> -c='ssl_verify_peer=>false, ssl_verify_host=>false'
PHP Warning:  strpos() expects parameter 1 to be string, array given in /tmp/vcloudPHP-1.5.0/library/VMware/VCloud/Service.php on line 97
PHP Fatal error:  Uncaught exception 'VMware_VCloud_SDK_Http_Exception' with message 'HTTP_Request2 needs an absolute HTTP(S) request URL, 'Array/api/login' given' in /tmp/vcloudPHP-1.5.0/library/VMware/VCloud/Http/Client.php:157
Stack trace:
#0 /tmp/vcloudPHP-1.5.0/library/VMware/VCloud/Http/Client.php(191): VMware_VCloud_SDK_Http_Client->sendRequest('Array/api/login', 'POST', Array, NULL)
#1 /tmp/vcloudPHP-1.5.0/library/VMware/VCloud/ServiceAbstract.php(136): VMware_VCloud_SDK_Http_Client->post('Array/api/login', Array, NULL)
#2 /tmp/vcloudPHP-1.5.0/library/VMware/VCloud/Service.php(108): VMware_VCloud_SDK_Service_Abstract->post('Array/api/login', 200)
#3 /tmp/vcloudPHP-1.5.0/samples/login.php(73): VMware_VCloud_SDK_Service->login(Array, Array, Array)
#4 {main}
  thrown in /tmp/vcloudPHP-1.5.0/library/VMware/VCloud/Http/Client.php on line 157

it's my first try so i think it's really something easy and stupid.

thanks a lot for your help !

chris

ps: php works fine on that machine

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

For your -s argument did you use "myserver" or "https://myserver"? It requires the latter, also if you take a look at the source code for login.php, you'll notice it only accepts 3 command line args: server, user and paswd. The SSL peer/host are already set to false by default, so you don't need to call that from the command line as it's not a valid argument and will just be ignored. I think the error is due to missing "https://"

Also in the future, you can post in the dedicated vCloud SDK for PHP forum - http://communities.vmware.com/community/vmtn/developer/forums/vcloudsdkphp if you have any future questions regarding the PHP SDK

View solution in original post

0 Kudos
5 Replies
lamw
Community Manager
Community Manager
Jump to solution

For your -s argument did you use "myserver" or "https://myserver"? It requires the latter, also if you take a look at the source code for login.php, you'll notice it only accepts 3 command line args: server, user and paswd. The SSL peer/host are already set to false by default, so you don't need to call that from the command line as it's not a valid argument and will just be ignored. I think the error is due to missing "https://"

Also in the future, you can post in the dedicated vCloud SDK for PHP forum - http://communities.vmware.com/community/vmtn/developer/forums/vcloudsdkphp if you have any future questions regarding the PHP SDK

0 Kudos
Carmageddon
Contributor
Contributor
Jump to solution

William - the page you linked to only has the SDK on it and some (quite useless) "documentation".

There is no sub-forum there for VCloud SDK for PHP - perhaps it has been removed/merged since you posted, or perhaps I am too stupid to use the intuitive GUI of vmWare's website.

Either way, I too am having a lot of fundamental problems with understanding the SDK and how to work with it.

The only available documentation is the one generated from PHP comments which pretty much sums the methods, variables, classes and groups them together.

This is a reference which helps  a little bit on the technical aspect of classes and how they relate to each other, but it DOES NOT tell me, for example from one of the sample files:

echo "     -c|--netmoref <netmoref>  [opt] Vim portgroup MoRef. Required for creating.\n";

Thats from the sample script which creates an External Network, which I need to do in order to provision a new customer Organization.

Another unknown thing, is what is a "fence Mode" in this:  $config->setFenceMode($fenceMode);

Another basic concept of the SDK I could not really grasp yet - is why some of the classes begin as VMware_VCloud_API* while others are VMware_VCloud_SDK*

Another example? in the GUI's New Organization scree, under Policies section, there is a "Limits" section - I searched thoroughly, and did not find any corresponding SDK/API methods in the documentation!

Also, I did not find a way to Delete organization (when a customer cancels subscription for example).

I apologize if my attitude comes over a bit on the irritated side, but I've been at it for some time now, and each time I get more and more irritated looking at the "documentation" trying to figure out something Smiley Happy

Regardless, Kimberly Wang's code is simply outstanding and well written, I just wish for some help figuring out how to put this huge puzzel together (even in the sample code I dont understand for example, how to come up with the right order of objects within objects nesting in order to get something done such as VMware_VCloud_API_OrgSettingsType class object for the settings, then feed it into a VMware_VCloud_API_AdminOrgType (along with other settings - why are they not in the $settings object? And finally another VMware_VCloud_SDK_Admin object is the one to actually create the organization! why the VMware_VCloud_API_AdminOrgType couldnt be the class doing the organization creation?)

This is a brief summary of the things I am trying to figure out.

Perhaps I missed some kind of guide for this? and if not, I would be very grateful if someone could explain in a few words to help me understand this puzzel so I could start doing my job and build something out of these awesome (even if cryptic) building blocks!

Thanks Smiley Happy

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

Can you please start a new thread on the vCloud SDK for PHP which is located with the same URL in my previous post - http://communities.vmware.com/community/vmtn/developer/forums/vcloudsdkphp This helps with tracking and I can have Kimberly or someone help answer some of your questions

On the landing page, you should see a big green button on the right that says "Start a Discussion". Let me know if you don't see that and I can have the site admin take a look. The vCloud forums is broken down into 4 sections:

  • vCloud API - REST API questions or API questions in general WRT to vCloud Director
  • vCloud SDK for Java - Java SDK questions
  • vCloud SDK for .NET - .NET SDK questions
  • vCloud SDK for PHP - PHP SDK questions

Thanks for your patience

0 Kudos
Carmageddon
Contributor
Contributor
Jump to solution

Thanks William, I posted: http://communities.vmware.com/thread/342817

However I should rephrase my question regarding the forum use: indeed creating thread is easy with the big green button.

But I meant, that I wanted to BROWSE that forum, see what other questions were asked and see if any of them would shed any light on my issues and give me better undestanding.

However, I only found there the "Recent Content" under the above link, and no link leading to a forum in its classic sense.

Only after posting the new thread, I saw the link in the forum categories "bread crumbs" called "Discussions" leading to this:

http://communities.vmware.com/community/vmtn/developer/forums/vcloudsdkphp?view=discussions

Otherwise I could not find any other way to reach that forum.

I hope this is something which can be fixed Smiley Happy

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

I've forwarded your feedback to the right folks

Thanks

0 Kudos