← 输入框|github.com|刷新
Skip to content

instantiate VM from template #36

Open

Description

@dipietro-salvatore

Hi,
I am new on this project and I am trying to using it to instantiate and deploy some VMs from an existing template.
I managed to retrieve the template details from OpenNebula but I have some problems to instantiate a VM.
This is my python code:

vm_templ = oca.VmTemplatePool(client)
vm_templ.info()

for templ in vm_templ:
    if templ.name == "Ubuntu 14.04 - KVM":
        t_xml = ET.tostring(templ.xml)
        n_vm =  oca.VmTemplate(t_xml, client)
        n_vm.instantiate("oca-test")

However the library return me this error:

Traceback (most recent call last):
  File "test.py", line 26, in <module>
    n_vm.instantiate("oca-test")
  File "build/bdist.linux-x86_64/egg/oca/template.py", line 89, in instantiate
  File "build/bdist.linux-x86_64/egg/oca/__init__.py", line 113, in call
  File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1591, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1306, in single_request
    return self.parse_response(response)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1482, in parse_response
    return u.close()
  File "/usr/lib/python2.7/xmlrpclib.py", line 794, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault -501: 'Parameter that is supposed to be integer is not'>

I printed my t_xml variables and this is the output:

<VMTEMPLATE><ID>109</ID><UID>15</UID><GID>0</GID><UNAME>xxxxx</UNAME><GNAME>oneadmin</GNAME><NAME>Ubuntu 14.04 - KVM</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNE
R_A><GROUP_U>0</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>0</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><REGTIME>1476705414</REGTIME><TEMPLATE><CONTEXT><ETH0_C
ONTEXT_FORCE_IPV4>$NETWORK[CONTEXT_FORCE_IPV4,NETWORK_ID="2"]</ETH0_CONTEXT_FORCE_IPV4><ETH0_DNS>$NETWORK[DNS,NETWORK_ID="2"]</ETH0_DNS><ETH0_GATEWAY>$NETWORK[GATEWAY,NETWORK_ID="2"]</ETH0_GATE
WAY><ETH0_GATEWAY6>$NETWORK[GATEWAY6,NETWORK_ID="2"]</ETH0_GATEWAY6><ETH0_IP>$NIC[IP,NETWORK_ID="2"]</ETH0_IP><ETH0_IPV6>$NIC[IP6_GLOBAL,NETWORK_ID="2"]</ETH0_IPV6><ETH0_MASK>$NETWORK[NETWORK_M
ASK,NETWORK_ID="2"]</ETH0_MASK><ETH0_NETWORK>$NETWORK[NETWORK_ADDRESS,NETWORK_ID="2"]</ETH0_NETWORK><NETWORK>YES</NETWORK><SSH_PUBLIC_KEY></SSH_PUBLIC_KEY></CONTEXT><CPU>1</CPU><DISK><IMAGE>Ubuntu-14.04</IMAGE><IMAGE_UNAME>xxxxx</IMAGE_UNAME></DISK><FROM_APP>53e7c1b28fb81d6a69000003</FROM_APP><FROM_APP_NAME>Ubuntu 14.04
 - KVM</FROM_APP_NAME><GRAPHICS><LISTEN>0.0.0.0</LISTEN><TYPE>vnc</TYPE></GRAPHICS><LOGO>images/logos/ubuntu.png</LOGO><MEMORY>2048</MEMORY><NIC><MODEL>e1000</MODEL><NETWORK>private-vnet</NETWO
RK><NETWORK_UNAME>oneadmin</NETWORK_UNAME></NIC><OS><ARCH>x86_64</ARCH></OS><SUNSTONE_CAPACITY_SELECT>YES</SUNSTONE_CAPACITY_SELECT><SUNSTONE_NETWORK_SELECT>YES</SUNSTONE_NETWORK_SELECT></TEMPL
ATE></VMTEMPLATE>

What I am doing wrong?

Thanks

Activity

  1. mguezuraga commented on Nov 7, 2016

    @mguezuraga
    Contributor

    You already have the template you need to instantiate! Don't need to do this:

    t_xml = ET.tostring(templ.xml)
    n_vm =  oca.VmTemplate(t_xml, client)
    

    Just do it like this:

    vm_templ = oca.VmTemplatePool(client)
    vm_templ.info()
    
    for templ in vm_templ:
        if templ.name == "Ubuntu 14.04 - KVM":
            templ.instantiate("oca-test")
    
  2. Demonsthere commented on Mar 23, 2017

    @Demonsthere

    Hi there, sorry for highjacking this, but how can I now get the ID of the newly created machine from
    templ.instantiate("oca-test") ?

  3. mguezuraga commented on Apr 4, 2017

    @mguezuraga
    Contributor

    @Demonsthere:

    The template method 'instantiate' is returning the ID of the VM instantiated since #50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions