Hi, 

Can you try the following below?

ssh_key = types.Ssh(public_key=my_ssh_key_string, authentication_method=types.SshAuthenticationMethod('publickey'))
host = hosts_service.add_using_ssh(
                types.Host(
                    name=name,
                    description='',
                    address=address,
                    port=22,
                    ssh=ssh_key,
                    cluster=types.Cluster(
                        name=cluster,
                    ),
                ),
            )



Thanks,
Saif

On Wed, Dec 8, 2021 at 6:28 PM Grace Chen <hippoqian@gmail.com> wrote:
I am writing a script to create a host using public ssh key
the function I am using is add_using_ssh:
my ssh_key is a an Ssh type already
ssh_key = types.Ssh(public_key=my_ssh_key_string)

host = hosts_service.add_using_ssh(
                types.Host(
                    name=name,
                    description='',
                    address=address,
                    root_password=None,
                    port=22,
                    ssh=ssh_key,
                    cluster=types.Cluster(
                        name=cluster,
                    ),
                ),
            )
When I choose from GUI, it doesn't ask me to put in root password, so I set it as None (Not sure if this is correct)

I got error:
ovirtsdk4.Error: Fault reason is "Request syntactically incorrect.". Fault detail is "For correct usage, see: ovirt-engine/apidoc#services/hosts/methods/add". HTTP response code is 400.

looks like I didn't get all the parameters assigned?
Can anybody help with this?


_______________________________________________
Devel mailing list -- devel@ovirt.org
To unsubscribe send an email to devel-leave@ovirt.org
Privacy Statement: https://www.ovirt.org/privacy-policy.html
oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/
List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/MWDE4JADQRXCGYBH53BGJJTHCCU4H5UV/