Bug 1568750 - ovirt-engine API is not supported to create vm with clustername is not default and templates is not blank?
Summary: ovirt-engine API is not supported to create vm with clustername is not defaul...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: ovirt-engine-sdk-python
Classification: oVirt
Component: General
Version: 3.6.0.0
Hardware: x86_64
OS: Linux
unspecified
medium vote
Target Milestone: ---
: ---
Assignee: Ondra Machacek
QA Contact: meital avital
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-04-18 08:44 UTC by 曾浩
Modified: 2018-04-19 01:01 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-19 01:01:11 UTC
oVirt Team: Virt


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.