Title: deployVirtualMachine build unexpected query string for parameter iptonetworklist · Issue #32 · PCextreme/cloudstack-php · GitHub
Open Graph Title: deployVirtualMachine build unexpected query string for parameter iptonetworklist · Issue #32 · PCextreme/cloudstack-php
X Title: deployVirtualMachine build unexpected query string for parameter iptonetworklist · Issue #32 · PCextreme/cloudstack-php
Description: Hello there, I got the very same problem reported on issue #1 but here I'll try to explain how to reproduce the case. On deployVirtualMachine command the API accepts an array for parameter iptonetworklist, which is formatted this way if ...
Open Graph Description: Hello there, I got the very same problem reported on issue #1 but here I'll try to explain how to reproduce the case. On deployVirtualMachine command the API accepts an array for parameter iptonetw...
X Description: Hello there, I got the very same problem reported on issue #1 but here I'll try to explain how to reproduce the case. On deployVirtualMachine command the API accepts an array for parameter ipto...
Opengraph URL: https://github.com/PCextreme/cloudstack-php/issues/32
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"deployVirtualMachine build unexpected query string for parameter iptonetworklist","articleBody":"Hello there, I got the very same problem reported on issue #1 but here I'll try to explain how to reproduce the case.\r\n\r\nOn `deployVirtualMachine` command the API accepts an array for parameter `iptonetworklist`, which is formatted this way if you create a VM directly from CloudStack UI: `\u0026iptonetworklist[0].networkid=b6170452-820c-4a5b-bb76-6a22a0266c0d\u0026iptonetworklist[0].ip=10.1.1.100\u0026iptonetworklist[0].mac=DC-FE-49-00-66-0D`. The key [0] on this array can be incremented when you associate more than one network to the new VM.\r\n\r\nThe point is that the method `protected function buildQueryString(array $params)` on `PCextreme\\Cloudstack\\Client` is not able to build the query string array like expected by CloudStack API on this command, giving `Notice: Undefined index: key` if we try to send the array data with something like this:\r\n\r\n```php\r\n \"iptonetworklist\" =\u003e array:1 [\r\n 0 =\u003e array:3 [\r\n \"mac\" =\u003e \"54-77-2F-BA-67-74\"\r\n \"networkid\" =\u003e \"b6170452-820c-4a5b-bb76-6a22a0266c0d\"\r\n \"ip\" =\u003e \"10.1.1.50\"\r\n ]\r\n ]\r\n```\r\n\r\nOtherwise, if we try to send the array as expected by the method, like the example bellow:\r\n\r\n```php\r\n \"iptonetworklist\" =\u003e array:3 [\r\n 0 =\u003e array:2 [\r\n \"key\" =\u003e \"mac\"\r\n \"value\" =\u003e \"54-77-2F-BA-67-74\"\r\n ]\r\n 1 =\u003e array:2 [\r\n \"key\" =\u003e \"networkid\"\r\n \"value\" =\u003e \"b6170452-820c-4a5b-bb76-6a22a0266c0d\"\r\n ]\r\n 2 =\u003e array:2 [\r\n \"key\" =\u003e \"ip\"\r\n \"value\" =\u003e \"10.1.1.50\"\r\n ]\r\n ]\r\n```\r\n\r\nWe get the query string as this: `\u0026iptonetworklist[0].key=mac\u0026iptonetworklist[0].value=54-77-2F-BA-67-74\u0026iptonetworklist[1].key=networkid\u0026iptonetworklist[1].value=b6170452-820c-4a5b-bb76-6a22a0266c0d\u0026iptonetworklist[2].key=ip\u0026iptonetworklist[2].value=10.1.1.50`\r\n\r\nThis way the method will not give the notice, but CloudStack API will treat each key on the array as a different entry in the map, returning this error:\r\n\r\n```php\r\nClientException {#3412\r\n #response: array:1 [\r\n \"deployvirtualmachineresponse\" =\u003e array:4 [\r\n \"uuidList\" =\u003e []\r\n \"errorcode\" =\u003e 431\r\n \"cserrorcode\" =\u003e 4350\r\n \"errortext\" =\u003e \"Unable to translate and find entity with networkId: null\"\r\n ]\r\n ]\r\n #message: \"Unable to translate and find entity with networkId: null\"\r\n #code: 431\r\n #file: \"/var/www/html/vendor/pcextreme/cloudstack/src/Client.php\"\r\n #line: 405\r\n```\r\n\r\nI'm not sure if this is the only endpoint treating array on request this way, but the way `buildQueryString()` method parses input and build query string is not working for the command `deployVirtualMachine`.\r\n\r\nIf you could confirm if there are other commands receiving and parsing arrays for requests I could eventually send a PR to fix this, but I'm afraid we fix for this command and break for others.\r\n\r\nPlease let me know if I can help sending other evidences of the case.\r\n\r\nFor the reference, I'm using **CloudStack 4.15.0.0** here.","author":{"url":"https://github.com/danielcosta","@type":"Person","name":"danielcosta"},"datePublished":"2021-06-10T17:20:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/32/cloudstack-php/issues/32"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:98450501-5709-c0e0-9a82-bba774cc5739 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B4A:DA11A:38F5B99:4BDD33E:6981A989 |
| html-safe-nonce | acf07a2a7a6f09ac1b34b481af7d6ceb371011a1f42c9fd58632e6b6fc67c9ce |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjRBOkRBMTFBOjM4RjVCOTk6NEJERDMzRTo2OTgxQTk4OSIsInZpc2l0b3JfaWQiOiI2MzQ1MDIyNjM1MDY4Mzk5NDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | dcfb295e5dbc7bdde5e63aa897942207a239e4bdfbf94e96825707147198a2b0 |
| hovercard-subject-tag | issue:917597314 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PCextreme/cloudstack-php/32/issue_layout |
| twitter:image | https://opengraph.githubassets.com/65f712a40d55b1f386ff686408b0e25dc6f170eb4f83f0b48d236ea600a3f359/PCextreme/cloudstack-php/issues/32 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/65f712a40d55b1f386ff686408b0e25dc6f170eb4f83f0b48d236ea600a3f359/PCextreme/cloudstack-php/issues/32 |
| og:image:alt | Hello there, I got the very same problem reported on issue #1 but here I'll try to explain how to reproduce the case. On deployVirtualMachine command the API accepts an array for parameter iptonetw... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danielcosta |
| hostname | github.com |
| expected-hostname | github.com |
| None | e137814e266030874fd2c86863529d0622b13889eeda04148c57654b6ea84ad6 |
| turbo-cache-control | no-preview |
| go-import | github.com/PCextreme/cloudstack-php git https://github.com/PCextreme/cloudstack-php.git |
| octolytics-dimension-user_id | 5224940 |
| octolytics-dimension-user_login | PCextreme |
| octolytics-dimension-repository_id | 65943685 |
| octolytics-dimension-repository_nwo | PCextreme/cloudstack-php |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 65943685 |
| octolytics-dimension-repository_network_root_nwo | PCextreme/cloudstack-php |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dd58d68a7813bbec9c91422c8c35f4af33832d70 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width