- url = f"{self.base_url()}/toscaControlLoop/putToscaInstantiationStateChange"
- response = self.send_message_json('PUT',
- 'Update tosca instance status',
- url,
- data=body,
- headers=self.header,
- basic_auth=self.basic_auth)
- return response
+ url = f"{self.base_url()}/acm/putToscaInstantiationStateChange"
+ try:
+ response = self.send_message_json('PUT',
+ 'Update tosca instance status',
+ url,
+ data=body,
+ headers=self.header,
+ basic_auth=self.basic_auth)
+ except RequestError:
+ self._logger.error("Change Instance Status request returned failed. Will query the instance status to double check whether the request is successful or not.")
+
+ # There's a bug in Clamp code, sometimes it returned 500, but actually the status has been changed successfully
+ # Thus we verify the status to determine whether it was successful or not
+ time.sleep(2)
+ response = self.get_template_instance()
+ return response["automationCompositionList"][0]["orderedState"]
+
+ def verify_instance_status(self, new_status):
+ """
+ Verify whether the instance changed to the new status.
+
+ Args:
+ new_status : the new status of the instance
+ Returns:
+ the boolean value indicating whether status changed successfully
+ """
+ response = self.get_template_instance()
+ if response["automationCompositionList"][0]["state"] == new_status:
+ return True
+ return False