apache / cloudstack-cloudmonkey

Apache Cloudstack Cloudmonkey
Apache License 2.0
91 stars 60 forks source link

Allow cmk to pass * as parameter value #128

Closed rohityadavcloud closed 1 year ago

rohityadavcloud commented 1 year ago

In some APIs, the value * isn't encoded properly (for example, setting up global setting values). This has been fixed for the cloudstack-go SDK here: https://github.com/apache/cloudstack-go/pull/52

We should look at changes on https://github.com/apache/cloudstack-go/pull/52/files#diff-866d8df59b9cf9a2319595a38dd83789af4cc7666722d1fde09c1b9e7816bfd2R543 to encode the params at correctly https://github.com/apache/cloudstack-cloudmonkey/blob/main/cmd/network.go#L194 for such cases.

davidjumani commented 1 year ago

Hi @rohityadavcloud Could you please provide an example ? I tried createing a user / account with * in the name as well as updating a global setting with * in the value and the result was as expected Although the * character was encoded in the request url, the resuling change / response is as expected

Eg:

(localhost) 🐱 > update configuration name=consoleproxy.url.domain value=*.turboio.com
[debug] ExecLine line:update configuration name=consoleproxy.url.domain value=*.turboio.com
[debug] ExecCmd args: update, configuration, name=consoleproxy.url.domain, value=*.turboio.com
[debug] Login POST URL:http://localhost:8080/client/apimap[command:[login] domain:[/] password:[password] response:[json] username:[admin]]
[debug] Login POST response status code:200
[debug] Login sessionkey:IYtbd90sWYjnfk-wjOLEl5h9NtA
[debug] NewAPIRequest API request URL:http://localhost:8080/client/api?command=updateConfiguration&name=consoleproxy.url.domain&response=json&sessionkey=IYtbd90sWYjnfk-wjOLEl5h9NtA&value=%2A.turboio.com
[debug] NewAPIRequest response status code:200
[debug] NewAPIRequest response body:{"updateconfigurationresponse":{"configuration":{"category":"Console Proxy","group":"System VMs","subgroup":"ConsoleProxyVM","name":"consoleproxy.url.domain","value":"*.turboio.com","defaultvalue":"","description":"Console proxy url domain","isdynamic":false,"component":"AgentManager","displaytext":"Consoleproxy url domain","type":"String"}}}
{
  "configuration": {
    "category": "Console Proxy",
    "component": "AgentManager",
    "defaultvalue": "",
    "description": "Console proxy url domain",
    "displaytext": "Consoleproxy url domain",
    "group": "System VMs",
    "isdynamic": false,
    "name": "consoleproxy.url.domain",
    "subgroup": "ConsoleProxyVM",
    "type": "String",
    "value": "*.turboio.com"
  }
}
rohityadavcloud commented 1 year ago

@davidjumani can you check https://github.com/apache/cloudstack-go/pull/52 and for testing just pass * as value to the global setting both in cli and via shell script to cmk.