Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmid not auto set when creating from Foreman API #254

Closed
EddMCambs opened this issue Apr 6, 2023 · 1 comment · Fixed by #312 or #318
Closed

vmid not auto set when creating from Foreman API #254

EddMCambs opened this issue Apr 6, 2023 · 1 comment · Fixed by #312 or #318

Comments

@EddMCambs
Copy link

Describe the Bug
Creating hosts through the web ui works correctly, however attempting to do it through the api returns the error Backtrace for 'Action failed' error (ArgumentError): vmid is required for this operation

To Reproduce
Attempt to create a host through the API with a host group that defines using a proxmox compute resource. Sample python used:

import requests, json
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
retry_strategy = Retry(
    total=5,
    status_forcelist=[429, 502, 503, 504],
    allowed_methods=["POST","GET"],
    backoff_factor=10
)
adapter = HTTPAdapter(max_retries=retry_strategy)
forehttp = requests.Session()
forehttp.auth = ("<foremanusername>","<foremanPAT>")
forehttp.mount('https://', adapter)
create_params={
    'host':{
        'name': <hostname>,
        'hostgroup_id': 28, # Host group that is set to use a proxmox compute profile
        'location_id': 5,
        'organization_id': 3,
        'build': True,
        'compute_attributes': {
            'start': 1,
           # 'vmid': '123'
        }
    }
}
r = forehttp.post("<foremanurl>/api/hosts",data=json.dumps(create_params),headers={'Content-Type': 'application/json'})
r.raise_for_status()

Expected behavior
As with the webui, the plugin should get the next vmid automatically.

Additional context
If a valid VMID is specified manually (by uncommenting the 'vmid': 123 under compute_attributes) it works perfectly, but that is not easily workable for this script. Additionally passing any string to vmid that isn't a valid proxmox vmid results in the host being created in foreman, but silently failing to do anything in proxmox. Subsequent efforts to edit the VM in foreman will return the error

'<hostname>' not found on '<proxmox cluster>(Proxmox)' '<hostname>' could be deleted or '<proxmox cluster> (Proxmox)' is not responding.

Versions
Foreman: 3.6.1
rubygem-fog-proxmox.noarch: 0.15.0-1.el8
rubygem-foreman_fog_proxmox.noarch: 0.14.2-1.fm3_7.el8

@maximiliankolb
Copy link

I ran into the same issue when trying to provision a host on Promox using Hammer CLI:

Could not create the host:
  Failed to create a compute Proxmox (Proxmox) instance host.example.com: vmid is required for this operation

Manisha15 added a commit to ATIX-AG/foreman_fog_proxmox that referenced this issue Feb 12, 2024
Manisha15 added a commit to ATIX-AG/foreman_fog_proxmox that referenced this issue Feb 12, 2024
Manisha15 added a commit to ATIX-AG/foreman_fog_proxmox that referenced this issue Feb 12, 2024
Manisha15 added a commit to ATIX-AG/foreman_fog_proxmox that referenced this issue Feb 12, 2024
Manisha15 added a commit to ATIX-AG/foreman_fog_proxmox that referenced this issue Feb 12, 2024
Manisha15 added a commit to ATIX-AG/foreman_fog_proxmox that referenced this issue Feb 20, 2024
Manisha15 added a commit to ATIX-AG/foreman_fog_proxmox that referenced this issue Feb 21, 2024
Manisha15 added a commit to ATIX-AG/foreman_fog_proxmox that referenced this issue Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants