Hi,

Thank you for sharing the out of APIs.
I checked it with the code and unfortunately the current code cannot import VMs 
with local storages considering the output that listUnmanagedInstances API 
returns. Code 
(https://github.com/shapeblue/cloudstack/blob/main/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java#L485-L505)
 tries to compare datastorename with the path of storage pool and this case 
there are different.
[https://opengraph.githubassets.com/93c5f82065ba2a8daa2926dd261b1d20d28d781966a42bdd7133772f4080ca42/shapeblue/cloudstack]<https://github.com/shapeblue/cloudstack/blob/main/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java#L485-L505>
cloudstack/UnmanagedVMsManagerImpl.java at main · 
shapeblue/cloudstack<https://github.com/shapeblue/cloudstack/blob/main/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java#L485-L505>
The upstream repository is at http://github.com/apache/cloudstack. This is 
ShapeBlue&#39;s support/patch branches and Apache CloudStack™ backup - 
cloudstack/UnmanagedVMsManagerImpl.java at main · s...
github.com

You may raise a bug on GitHub for this.

Regards,
Abhishek
________________________________
From: haven <382829...@qq.com.INVALID>
Sent: 14 December 2021 12:35
To: dev@cloudstack.apache.org <dev@cloudstack.apache.org>
Subject: 回复: import existing instance from vsphere to cloudstack failed

Hi Abhishek
&nbsp; &nbsp; &nbsp;Thanks for your reply , info below:



&nbsp;listUnmanagedInstances API for the VM

{"listunmanagedinstancesresponse":{"count":2,"unmanagedinstance":[{"name":"vc01","clusterid":"8f5efc66-17a9-4f80-925b-92722a04a501","hostid":"a75916bf-eb08-45cd-9101-7a2cabf06d6e","powerstate":"PowerOn","cpunumber":4,"cpucorepersocket":1,"cpuspeed":0,"memory":8192,"osid":"windows8Server64Guest","osdisplayname":"Microsoft
 Windows Server 2012 (64 位)","disk":[{"id":"1-2000","label":"硬盘 
1","capacity":53687091200,"imagepath":"[localsr1] 
acs/acs.vmdk","controller":"lsisas1068","controllerunit":0,"position":0,"datastorename":"localsr1"}],"nic":[{"id":"网络适配器
 1","networkname":"VM 
Network","macaddress":"00:0c:29:62:31:ad","vlanid":0,"adaptertype":"E1000"}]},{"name":"localstorage","clusterid":"8f5efc66-17a9-4f80-925b-92722a04a501","hostid":"a75916bf-eb08-45cd-9101-7a2cabf06d6e","powerstate":"PowerOn","cpunumber":1,"cpucorepersocket":1,"cpuspeed":0,"memory":2048,"osid":"centos7_64Guest","osdisplayname":"CentOS
 7 (64 位)","disk":[{"id":"2-2000","label":"硬盘 
1","capacity":17179869184,"imagepath":"[localsr1] 
localstorage/localstorage.vmdk","controller":"pvscsi","controllerunit":0,"position":0,"datastorename":"localsr1"}],"nic":[{"id":"网络适配器
 1","macaddress":"00:50:56:b4:fa:53","adaptertype":"Vmxnet3"}]}]}}



listStoragePools

{"liststoragepoolsresponse":{"count":5,"storagepool":[{"id":"a8eab88e-b302-4444-92d1-04e3b83d47b7","zoneid":"db959f5f-2b65-435f-8cd7-2efb7d87c3c7","zonename":"vmware01","podid":"dd8a1ce9-f16b-4de2-9441-7baa3e26ecd8","podname":"vmwarepod","name":"datastore1","ipaddress":"VMFS
 datastore: 
datastore-10","path":"datastore-10","created":"2021-12-09T10:28:07+0800","type":"VMFS","clusterid":"8f5efc66-17a9-4f80-925b-92722a04a501","clustername":"10.226.18.132/Datacenter1/cl01","disksizetotal":118648471552,"disksizeallocated":0,"disksizeused":7552892928,"state":"Up","scope":"HOST","overprovisionfactor":"2.0","provider":"DefaultPrimary","storagecapabilities":{"VOLUME_SNAPSHOT_QUIESCEVM":"false"}},{"id":"a34f25c3-3452-3441-828c-302a2c6f7f03","zoneid":"db959f5f-2b65-435f-8cd7-2efb7d87c3c7","zonename":"vmware01","podid":"dd8a1ce9-f16b-4de2-9441-7baa3e26ecd8","podname":"vmwarepod","name":"nfs1","ipaddress":"10.226.18.132","path":"/Datacenter1/nfs1","created":"2021-12-08T15:05:34+0800","type":"NFS","clusterid":"8f5efc66-17a9-4f80-925b-92722a04a501","clustername":"10.226.18.132/Datacenter1/cl01","disksizetotal":11005929193472,"disksizeallocated":34365323222,"disksizeused":195802693632,"state":"Up","scope":"CLUSTER","overprovisionfactor":"2.0","provider":"DefaultPrimary","storagecapabilities":{"VOLUME_SNAPSHOT_QUIESCEVM":"false"}},{"id":"f42dea39-fa23-3e27-9062-45381b9cc1c7","zoneid":"db959f5f-2b65-435f-8cd7-2efb7d87c3c7","zonename":"vmware01","podid":"dd8a1ce9-f16b-4de2-9441-7baa3e26ecd8","podname":"vmwarepod","name":"nfs2","ipaddress":"10.226.18.132","path":"/Datacenter1/nfs2","created":"2021-12-08T13:55:49+0800","type":"NFS","clusterid":"8f5efc66-17a9-4f80-925b-92722a04a501","clustername":"10.226.18.132/Datacenter1/cl01","disksizetotal":11005933387776,"disksizeallocated":4194304000,"disksizeused":195802693632,"state":"Up","scope":"CLUSTER","overprovisionfactor":"2.0","provider":"DefaultPrimary","storagecapabilities":{"VOLUME_SNAPSHOT_QUIESCEVM":"false"}},{"id":"44069041-572d-32b0-abc4-745b97eae508","zoneid":"690eaa87-5228-4192-a388-ea250b58d963","zonename":"uat","podid":"f0a0d079-2944-45bd-8c77-b60b09330eff","podname":"SP01","name":"Ceph
 
RBD","ipaddress":"10.100.250.11,10.100.250.12,10.100.250.13","path":"rbd","created":"2021-11-22T12:22:40+0800","type":"RBD","clusterid":"d384ab7a-1377-4371-b444-e0d7150536d6","clustername":"defaultGroupName","disksizetotal":36332551200768,"disksizeallocated":4691748454400,"disksizeused":1808940470272,"state":"Up","scope":"CLUSTER","overprovisionfactor":"2.0","provider":"DefaultPrimary","storagecapabilities":{"VOLUME_SNAPSHOT_QUIESCEVM":"false"}},{"id":"89f42f77-6c2b-4bd6-885c-4bb24a09366c","zoneid":"db959f5f-2b65-435f-8cd7-2efb7d87c3c7","zonename":"vmware01","podid":"dd8a1ce9-f16b-4de2-9441-7baa3e26ecd8","podname":"vmwarepod","name":"localsr1","ipaddress":"VMFS
 datastore: 
datastore-11","path":"datastore-11","created":"2021-12-09T10:28:07+0800","type":"VMFS","clusterid":"8f5efc66-17a9-4f80-925b-92722a04a501","clustername":"10.226.18.132/Datacenter1/cl01","disksizetotal":4000762036224,"disksizeallocated":0,"disksizeused":83411075072,"state":"Up","scope":"HOST","overprovisionfactor":"2.0","provider":"DefaultPrimary","storagecapabilities":{"VOLUME_SNAPSHOT_QUIESCEVM":"false"}}]}}


------------------&nbsp;原始邮件&nbsp;------------------
发件人:                                                                            
                                            "dev"                               
                                                     
<abhishek.ku...@shapeblue.com&gt;;
发送时间:&nbsp;2021年12月13日(星期一) 晚上6:11
收件人:&nbsp;"dev@cloudstack.apache.org"<dev@cloudstack.apache.org&gt;;

主题:&nbsp;Re: import existing instance from vsphere to cloudstack failed



Hi Haven,

From the error, API is failing to find the local storage pool for the volume 
for disk ID: 2-2000. I'm not sure if importing VM with local storage is widely 
tested so there can be an issue there. There could be some difference in pool's 
path as returned by listUnmanagedInstances vs listStoragePools APIs.
Can you please share output of:

&nbsp; *&nbsp;&nbsp; listUnmanagedInstances API for the VM
&nbsp; *&nbsp;&nbsp; listStoragePools API for the storage pool that corresponds 
to datastore named - localsr1

Regards,
Abhishek
________________________________
From: haven <382829...@qq.com.INVALID&gt;
Sent: 10 December 2021 22:02
To: dev <dev@cloudstack.apache.org&gt;
Subject: import existing instance from vsphere to cloudstack failed

Hi devs
&amp;nbsp; &amp;nbsp; I tried to&amp;nbsp; &amp;nbsp;import existing instance 
from vsphere to cloudstack failed, this instance use vsphere local storage 
datastore .already enabled localstorage vmware zone and found that localstorage 
in cloudstack,&amp;nbsp; get same error again。Is there any way to import it 
normally?


ENV:
Version: cloudstack 4.15.2&amp;nbsp;
vsphere:6.5


API:
http://x.x.x.x:8090/client/api/?clusterid=8f5efc66-17a9-4f80-925b-92722a04a501&amp;amp;name=localstorage&amp;amp;serviceofferingid=a9544da9-cc83-4ed0-9cf5-52e46f9e9361&amp;amp;command=importUnmanagedInstance&amp;amp;nicnetworklist[0].network=7b0b27c0-7827-4505-9c53-a7969406562b&amp;amp;nicnetworklist[0].nic=%E7%BD%91%E7%BB%9C%E9%80%82%E9%85%8D%E5%99%A8%201&amp;amp;response=json


Error:
{"queryasyncjobresultresponse":{"accountid":"623017de-4b49-11ec-b1af-52540044e80f","userid":"6232957f-4b49-11ec-b1af-52540044e80f","cmd":"org.apache.cloudstack.api.command.admin.vm.ImportUnmanagedInstanceCmd","jobstatus":2,"jobprocstatus":0,"jobresultcode":530,"jobresulttype":"object","jobresult":{"errorcode":530,"errortext":"Storage
 pool for disk 硬盘 1(2-2000) with datastore: localsr1 not found in zone ID: 
db959f5f-2b65-435f-8cd7-2efb7d87c3c7"},"created":"2021-12-10T13:10:29+0800","completed":"2021-12-10T13:10:30+0800","jobid":"2ce8de02-8abc-41ef-acd5-2c205b206598"}}

&nbsp;

 

Reply via email to