Commit ad3e7ef
authored
fix(ibm): Fix get_instance (#488)
## Description
IBM library get_instance returns a DetailedResponse object, not an
instance dict directly. This fix gets the instance dict result from that
object before passing it to from_existing.
## Additional Context and Relevant Issues
Previous behavior throws a TypeError
```
File "/home/shammer/Canonical/git/tools/ubuntu-old-fashioned/scripts/ubuntu-bartender/ibm-provider.py", line 34, in <module>
delete(args.id)
File "/home/shammer/Canonical/git/tools/ubuntu-old-fashioned/scripts/ubuntu-bartender/ibm-provider.py", line 22, in delete
instance = ibm.get_instance(instance_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shammer/ubuntu-bartender-multipass.pedbPM1KcM/.venv/lib/python3.12/site-packages/pycloudlib/ibm/cloud.py", line 230, in get_instance
return IBMInstance.find_existing(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shammer/ubuntu-bartender-multipass.pedbPM1KcM/.venv/lib/python3.12/site-packages/pycloudlib/ibm/instance.py", line 702, in find_existing
return cls.from_existing(
^^^^^^^^^^^^^^^^^^
File "/home/shammer/ubuntu-bartender-multipass.pedbPM1KcM/.venv/lib/python3.12/site-packages/pycloudlib/ibm/instance.py", line 675, in from_existing
floating_ip = kwargs.pop("floating_ip", None) or cls._discover_floating_ip(client, instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shammer/ubuntu-bartender-multipass.pedbPM1KcM/.venv/lib/python3.12/site-packages/pycloudlib/ibm/instance.py", line 773, in _discover_floating_ip
nic_id = instance["primary_network_interface"]["id"]
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'DetailedResponse' object is not subscriptable
```
## Test Steps
Create an instance and perform a get_instance
```python
import pycloudlib
ibm = pycloudlib.IBM("test")
imge = ibm.daily_image(release="noble")
instance = ibm.launch(image_id=daily, instance_type="bx3d-2x10", name="test")
id = instance._instance["id"]
instance_find = ibm.get_instance(id) # previously would throw an exception here
```1 parent 00a20b9 commit ad3e7ef
2 files changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
692 | 692 | | |
693 | 693 | | |
694 | 694 | | |
695 | | - | |
| 695 | + | |
| 696 | + | |
696 | 697 | | |
697 | | - | |
| 698 | + | |
| 699 | + | |
698 | 700 | | |
699 | 701 | | |
700 | 702 | | |
| |||
0 commit comments