@Name : marvinRequest @Desc: Handles Marvin Requests @Input cmd: marvin's command from cloudstackAPI response_type: response type of the command in cmd method: HTTP GET/POST, defaults to GET @Output: Response received from CS
(self, cmd, response_type=None, method='GET', data='')
| 330 | return FAILED |
| 331 | |
| 332 | def marvinRequest(self, cmd, response_type=None, method='GET', data=''): |
| 333 | """ |
| 334 | @Name : marvinRequest |
| 335 | @Desc: Handles Marvin Requests |
| 336 | @Input cmd: marvin's command from cloudstackAPI |
| 337 | response_type: response type of the command in cmd |
| 338 | method: HTTP GET/POST, defaults to GET |
| 339 | @Output: Response received from CS |
| 340 | Exception in case of Error\Exception |
| 341 | """ |
| 342 | try: |
| 343 | ''' |
| 344 | 1. Verify the Inputs Provided |
| 345 | ''' |
| 346 | if (cmd is None or cmd == ''): |
| 347 | self.logger.exception("marvinRequest : Invalid Command Input") |
| 348 | raise InvalidParameterException("Invalid Parameter") |
| 349 | |
| 350 | ''' |
| 351 | 2. Sanitize the Command |
| 352 | ''' |
| 353 | sanitize_cmd_out = self.__sanitizeCmd(cmd) |
| 354 | |
| 355 | if sanitize_cmd_out == FAILED: |
| 356 | raise self.__lastError |
| 357 | |
| 358 | cmd_name, is_async, payload = sanitize_cmd_out |
| 359 | ''' |
| 360 | 3. Send Command to CS |
| 361 | ''' |
| 362 | cmd_response = self.__sendCmdToCS(cmd_name, |
| 363 | self.auth, |
| 364 | payload=payload, |
| 365 | method=method) |
| 366 | if cmd_response == FAILED: |
| 367 | raise self.__lastError |
| 368 | |
| 369 | ''' |
| 370 | 4. Check if the Command Response received above is valid or Not. |
| 371 | If not return Invalid Response |
| 372 | ''' |
| 373 | ret = self.__parseAndGetResponse(cmd_response, |
| 374 | response_type, |
| 375 | is_async) |
| 376 | if ret == FAILED: |
| 377 | raise self.__lastError |
| 378 | return ret |
| 379 | except Exception as e: |
| 380 | self.logger.exception("marvinRequest : CmdName: %s Exception: %s" % |
| 381 | (str(cmd), GetDetailExceptionInfo(e))) |
| 382 | raise e |
no test coverage detected