feat(cloudstack): fetch vm password using url_helper instead of wget
Proposed Commit Message
CloudStack vms use wget to fetch vm password from cloudstack VR However, wget is not installed in some cloud images. instead, curl is installed This PR uses url_helper to fetch vm password instead of wget
Additional Context
Test Steps
Merge type
- [x] Squash merge using "Proposed Commit Message"
- [ ] Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)
thanks @blackboxsw for your reply and guidance. much helpful. I will update this pull request later.
@weizhouapache Additionally, calling an external tool isn't desirable or even necessary for datasources - in fact this is the only datasource using an external tool to do http requests. I think that an ideal alternate implementation to wget would use the internal url_helper module, which is what the other datasources use.
@weizhouapache Additionally, calling an external tool isn't desirable or even necessary for datasources - in fact this is the only datasource using an external tool to do http requests. I think that an ideal alternate implementation to wget would use the internal url_helper module, which is what the other datasources use.
thanks @holmanb , good suggestion
@blackboxsw @holmanb I made some changes as you suggested. thanks
let me know if you have any questions.
@weizhouapache can you please attach logs from testing this on cloudstack?
@weizhouapache can you please attach logs from testing this on cloudstack?
sure @holmanb
tested with rocky9 cloud image:
- prior to this change
2025-12-03 19:24:27,171 - DataSourceCloudStack.py[DEBUG]: Crawl of metadata service took 0 seconds
2025-12-03 19:24:27,171 - subp.py[DEBUG]: Running command ['wget', '--quiet', '--tries', '3', '--timeout', '20', '--output-document', '-', '--header', 'DomU_Request: send_my_password', '10.1.1.1:8080'] with allowed return codes [0] (shell=False, capture=True)
2025-12-03 19:24:27,175 - log_util.py[WARNING]: Failed to fetch password from virtual router 10.1.1.1
2025-12-03 19:24:27,175 - log_util.py[DEBUG]: Failed to fetch password from virtual router 10.1.1.1
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/cloudinit/subp.py", line 263, in subp
sp = subprocess.Popen(
File "/usr/lib64/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib64/python3.9/subprocess.py", line 1837, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: b'wget'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceCloudStack.py", line 226, in _get_data
set_password = password_client.get_password()
File "/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceCloudStack.py", line 68, in get_password
password = self._do_request("send_my_password")
File "/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceCloudStack.py", line 50, in _do_request
output, _ = subp.subp(
File "/usr/lib/python3.9/site-packages/cloudinit/subp.py", line 274, in subp
raise ProcessExecutionError(
cloudinit.subp.ProcessExecutionError: Unexpected error while running command.
Command: ['wget', '--quiet', '--tries', '3', '--timeout', '20', '--output-document', '-', '--header', 'DomU_Request: send_my_password', '10.1.1.1:8080']
Exit code: -
Reason: [Errno 2] No such file or directory: b'wget'
Stdout: -
Stderr: -
2025-12-03 19:24:27,272 - util.py[DEBUG]: Writing to /run/cloud-init/cloud-id-cloudstack - wb: [644] 11 bytes
- after this change
2025-12-03 19:27:52,005 - DataSourceCloudStack.py[DEBUG]: Crawl of metadata service took 0 seconds
2025-12-03 19:27:52,006 - url_helper.py[DEBUG]: [0/4] open 'http://10.1.1.1:8080' with {'url': 'http://10.1.1.1:8080', 'stream': False, 'allow_redirects': True, 'method': 'GET', 'timeout': 20.0, 'headers': {'DomU_Request': 'send_my_password', 'User-Agent': 'Cloud-Init/24.4-4.el9.0.1'}} configuration
2025-12-03 19:27:52,014 - url_helper.py[DEBUG]: Read from http://10.1.1.1:8080 (200, 6b) after 1 attempts
2025-12-03 19:27:52,014 - url_helper.py[DEBUG]: [0/4] open 'http://10.1.1.1:8080' with {'url': 'http://10.1.1.1:8080', 'stream': False, 'allow_redirects': True, 'method': 'GET', 'timeout': 20.0, 'headers': {'DomU_Request': 'saved_password', 'User-Agent': 'Cloud-Init/24.4-4.el9.0.1'}} configuration
2025-12-03 19:27:52,021 - url_helper.py[DEBUG]: Read from http://10.1.1.1:8080 (200, 14b) after 1 attempts
2025-12-03 19:27:52,023 - util.py[DEBUG]: Writing to /run/cloud-init/cloud-id-cloudstack - wb: [644] 11 bytes
can log in with default user rocky and password provided by cloudstack