I'm playing with GCP, specially with VM Instances.
I successfully Start / Stop instances by the Python API. But I cannot get the live operation status.
This is what I do to, for example, stop an instance :
instance_client = compute_v1.InstancesClient()
operation = instance_client.stop( project=PROJECT_NAME, zone=ZONE, instance=vm_name )
The VM is stopping, by the web ui I can see that. But when I want to get operation status programmatically I get something like that :
>>> operation
id: *******
kind: "compute#operation"
name: "operation-****-****-***"
user: "*****@appspot.gserviceaccount.com"
zone: "******"
target_link: "******"
progress: 0
operation_type: "stop"
status: RUNNING
target_id: *****
insert_time: "*****"
self_link: "*****"
It's OK during the first execution seconds but it's never updating. So even if the VM is successfully stopped, the method return the same response.
What I am missing ?
Versions :
google-cloud-compute 0.7.0
google-api-core 2.8.2
google-api-python-client 2.55.0
Note 1 : I cannot execute the docs method because my operation object don't have a result method :
>>> dir(operation)
['Status', '__bool__', '__class__', '__contains__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'client_operation_id', 'creation_timestamp', 'description', 'end_time', 'error', 'http_error_message', 'http_error_status_code', 'id', 'insert_time', 'kind', 'name', 'operation_group_id', 'operation_type', 'progress', 'region', 'self_link', 'start_time', 'status', 'status_message', 'target_id', 'target_link', 'user', 'warnings', 'zone']
Note 2 : I have the same behaviour with the instance.status method :
>>> vm.status
<Status.RUNNING: 250018339>
The result never change even if the VM successfully stopped.