These forums are a place for learning, helping and sharing experiences with others about any of our products. Feel free to ask a question and get answers from our community and our most advanced users.
Note that these are public forums - anyone can view the discussions here.
VISIT OUR DIFFERENT FORUMS:
Announcements > | |
CloudShell > | TestShell > |
Developers > | BI (Business Inteligence) > |
This is where you can suggest your ideas to help and improve the product for everyone.
Please make sure to read the following article before posting a new idea, to get more information about the required information and ideas lifecycle.
Feel free to vote and comment on other ideas to promote them.
Thanks for everyone who suggested the ideas and voted for them.
Find, download and share integrations that can extend and enhance the CloudShell experience.
Integrations have several levels:
Certified - Officially tested and supported by Quali.
Preview - Provides a sneak peek to what the Quali team is developing. Officially supported by Quali. Feel free to experiment and comment, but please take into consideration that it is not yet tested and released.
Community - Integrations shared by community users. Feel free to look into what other users have contributed, please take into consideration that these integrations are not tested by Quali.
To learn more about creating Shells and integrating with CloudShell, use the following links:
CloudShell's Dev Guide > | Configuration Management > |
Getting started with Shells > | Extending CloudShell with Cloud Providers > |
Getting started with Orchestration > | API Guide > |
To share your integration, follow the instructions in this guide >.
I wrote a library that it takes data or puts data into our company(ViaSat) database(vCMDB). I am trying to change that library to service. I have a separate shell for the service and I am just calling one of the function from the shell service in setup script by running the "ExecuteCommand" api call, but It gave me this error "Unable to locate a valid command named '_find_relationship' " and "_find_relationship" is the name of my function. I am not able to find out where the problem is?
Thank you,
Golriz Javadi
Answer by Yaniv Kalsky · Jul 26, 2017 at 11:43 PM
try to use the json package to work with this json string:
import json js = json.loads(res.Output) child_name = js[0]['child_name']
Yaniv
Answer by Yaniv Kalsky · Jul 25, 2017 at 12:29 AM
Hi @gjavadi
A function name that starts with an underscore is considered an internal function in the class, hence you can't call them.
Try removing the underscore and load your driver again.
Yaniv
Answer by Chris Grabosky · Jul 25, 2017 at 12:57 PM
If you want to hide the command from users, you can also put it in the category "Hidden Commands" which means it is available from the API but not for view in the portal.
Answer by Golriz Javadi · Jul 25, 2017 at 05:49 PM
Thank you for your responses. I did whatever you have suggested and I passed that error but I got another one that it says: "The following inputs were specified more than once:" and I got this right after my api call and my api call is in forloop?
Can you share this part of the code?
An execute command sample can be found in our dev guide samples:
In the sample, there are no inputs, but notice that it should be a list of InputNameValue, which has a name and a value per input.
Something like this:
inputs = []
inputs.append(InputNameValue('input1', 'value1'))
inputs.append(InputNameValue('input2', 'value2'))
Yaniv
Answer by Golriz Javadi · Jul 25, 2017 at 10:22 PM
Thank you so much. I solved the problem. I was passing the wrong argument list to the ExecuteCommand.
Answer by Golriz Javadi · Jul 26, 2017 at 11:15 PM
I have a question regarding the parsing of the result of ExecuteCommand api call. I know that the returning result of the api call is string. I have a string representation of list after running the ExecuteCommand api call. I am trying to change that to the actual list by running the eval(res) but I got this error "eval() arg 1 must be a string or code object". I thought the "res" that keeps the result of ExecuteCommand api call is string. please look at my code below:
res = api.ExecuteCommand(self.reservation_id, cmdbAlias, "Service", "find_relationship",arg_list, printOutput=True) res_child = eval(res) res_child = res_child[0]['child_name'] InputNameValue1 = InputNameValue('resource_name',res_child) InputNameValue2 = InputNameValue('a_data',_data) arg_list1 = [InputNameValue1, InputNameValue2] res1 = api.ExecuteCommand(self.reservation_id, cmdbAlias, "Service", "put_config_attributes", arg_list1,printOutput=True)
my function "find_relationship" is returning this:
[ { "audit": false, "parent_name": "smac-pat6-s1-alpha", "created_ts": "2017-07-25T23:11:59.007480+00:00", "child_type": "ab_smac_service", "child_class": "service_1to1", "description": null, "parent_id": 260778, "child_name": "smac-pat6-s1", "child_data": { "audit": [], "administrative_state": "unlocked", "domain": "ab_access_network", "config_name": "default", "name": "smac-pat6-s1", "descr": "", "created": "2017-06-01T18:42:25.558928+00:00", "resource_class": "service_1to1", "updated": "2017-07-25T23:11:59.335601+00:00", "operational_state": "enabled", "managed_state": "unmanaged", "caption": "", "resource_type": "ab_smac_service", "config_role": null, "scope": "", "configured_state": "configured", "config": { "smac_id": "264", "playbook.protocol": "cli", "access_network_id": "103", "base_station_id": "0a:bc:de:0a:01:00", "config.path": "smac-pat6-s1", "smac_domain_id": "264" }]
and I am trying to parse the child_name which is smac-pat6-s1.
Hope this make sense and thank you for your help in advance.
Answer by Golriz Javadi · Jul 26, 2017 at 11:55 PM
Still getting same kind of error "expected string or buffer". :(
<type "tuple">:(expected string or buffer)
Answer by Golriz Javadi · Jul 27, 2017 at 12:07 AM
I think it doesn't like the return type of the ExecuteCommand which is:
CommandExecutionCompletedResultInfo |
based on Cloudshell documentation.
Right, you should use res.Output to access the string itself
Answer by Chris Grabosky · Jul 27, 2017 at 03:19 PM
try a slight modification to @Yaniv.K code:
import json
js = json.loads(res)
child_name = js[0]['child_name'].Name
Sorry, not in a place right now to test that myself so I'm going off of what that error looks like.
It was already solved (above), the problem was with using res which was an object instead of res.Output
These forums are a place for learning, helping and sharing experiences with others about any of our products. Feel free to ask a question and get answers from our community and our most advanced users.
Note that these are public forums - anyone can view the discussions here.
Announcements | |
CloudShell | TestShell |
Developers | BI (Business Inteligence) |
This is where you can suggest your ideas to help and improve the product for everyone.
Please make sure to read the following article before posting a new idea, to get more information about the required information and ideas lifecycle.
Feel free to vote and comment on other ideas to promote them.
Thanks for everyone who suggested the ideas and voted for them.
Find, download and share integrations that can extend and enhance the CloudShell experience.
Integrations have several levels:
Certified - Officially tested and supported by Quali.
Preview - Provides a sneak peek to what the Quali team is developing. Officially supported by Quali. Feel free to experiment and comment, but please take into consideration that it is not yet tested and released.
Community - Integrations shared by community users. Feel free to look into what other users have contributed, please take into consideration that these integrations are not tested by Quali.
To learn more about creating Shells and integrating with CloudShell, use the following links:
CloudShell's Dev Guide | Configuration Management |
Getting started with Shells | Extending CloudShell with Cloud Providers |
Getting started with Orchestration | API Guide |
To share your integration, follow the instructions in this guide.