Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1568750

Summary: ovirt-engine API is not supported to create vm with clustername is not default and templates is not blank?
Product: [oVirt] ovirt-engine-sdk-python Reporter: 曾浩 <754267513>
Component: GeneralAssignee: Ondra Machacek <omachace>
Status: CLOSED NOTABUG QA Contact: meital avital <mavital>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 3.6.0.0CC: bugs, juan.hernandez
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-19 01:01:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description 曾浩 2018-04-18 08:44:07 UTC
Description of problem:

version :3.6.7.5-1.el6

ovirt-engine API is not supported to create vm with clustername is not default and templates is not blank.

Version-Release number of selected component (if applicable):

3.6.7.5-1.el6

How reproducible:


Steps to Reproduce:

    vm_cluster = api.clusters.get(name="node1")
    vm_template = api.templates.get(name="Blank")



[root@it-ovirtm01-manager scripts]# sh create_vm.sh 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fault>
    <reason>Operation Failed</reason>
    <detail>[Cannot add VM. Physical Memory Guaranteed cannot exceed Memory Size.]</detail>
</fault>
[root@it-ovirtm01-manager scripts]# python create_vm.py 
Adding virtual machine 'api_test_vm' failed: 
status: 400
reason: Bad Request
detail: Cannot add VM. Physical Memory Guaranteed cannot exceed Memory Size.
[root@it-ovirtm01-manager scripts]# 



Actual results:


Expected results:


Additional info:

Comment 1 Ondra Machacek 2018-04-18 08:46:51 UTC
Can you please share the script create_vm.sh and create_vm.py?

Comment 2 曾浩 2018-04-18 09:59:08 UTC
from ovirtsdk.api import API
from ovirtsdk.xml import params

try:
    api = API (url="https://ovirtm-bg",
               username="admin@internal",
               password="!@#!@#@!",
               ca_file="ca.crt"
               )

    vm_name = "api_test_vm"
    vm_memory = 1
    vm_cluster = api.clusters.get(name="node1")
    vm_template = api.templates.get(name="templates")

    vm_os = params.OperatingSystem(boot=[params.Boot(dev="hd")])

    vm_params = params.VM(name="api_test_vm",
                         memory=vm_memory,
                         cluster=vm_cluster,
                         template=vm_template,
                         os=vm_os)

    try:
        api.vms.add(vm=vm_params)
        print "Virtual machine '%s' added." % vm_name
    except Exception as ex:
        print "Adding virtual machine '%s' failed: %s" % (vm_name, ex)

    api.disconnect()
except Exception as ex:
    print "Unexpected error: %s" % ex

Comment 3 Ondra Machacek 2018-04-18 10:29:08 UTC
You are passing 'vm_memory = 1'. This value is in bytes, so if you want to have VM with one GiB you have to pass 'vm_memory = 1073741824'.

Comment 4 曾浩 2018-04-19 01:01:11 UTC
TKS