こんにちは。
私は、テンプレートから仮想マシンのクローンを作ろうとしています。
テンプレートは、[vm_iscsi_1]という名前のDatastoreにあります。
このテンプレートを元に、[vm_iscsi_2]という名前のDatastoreに仮想マシンの
クローンを作りたいです。
しかし、「VMware SDK for java」のVMClone.javaというサンプルソースでは
Datastoreの変更はできません。
そこで、下記のようにVMClone.javaを修正しました。
//**********************************************************************
// TODO Set of clone method
VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();
VirtualMachineRelocateSpec relocSpec = new VirtualMachineRelocateSpec();
// **********************************************************************
// TODO Setting of datastorePath
if (datastorePath != null && !"".equals(datastorePath.trim())) {
ManagedObjectReference datastoreRef = S1.getService()
.findByInventoryPath(content.getSearchIndex(),
datastorePath);
relocSpec.setDatastore(datastoreRef);
} else {
// The clone is done in the same datastore.
}
// **********************************************************************
cloneSpec.setLocation(relocSpec);
// TODO Setting of operation status
cloneSpec.setPowerOn(false);
// TODO Setting whether to use template file
cloneSpec.setTemplate(false);
//***********************************************************************
また、datastorePathに以下のパターンを代入して試験しました。
datastorePath datastoreRef
vm_iscsi_1 NULL
esx1:storage1 NULL
/vm_iscsi_1/110/110.vmdk NULL
/vm_iscsi_1/110 NULL
/[esx1:storage1]/Clone003/Clone003.vmdk NULL
/esx1:storage1/Clone003/Clone003.vmdk NULL
/esx1:storage1/Clone003 NULL
/[vm_iscsi_1]/110/110.vmdk NULL
/[vm_iscsi_1]/110 NULL
/vmfs/volumes/47ff3a37-59398f00-c5df-001e0bea2efa NULL
いつも、datastoreRefには"NULL"が代入されます。
なででしょうか?
findByInventoryPath()でMoRefを取得しようとすることは間違いでしょうか?
また、datastorePathには何を代入するべきですか?
宜しくお願いします。
Thank you!!
It was possible to do.
//***********************************************************
ManagedObjectReference [] datastoreRef
= (ManagedObjectReference [])cb.getServiceUtil().getDynamicProperty(
datacenterRef,"datastore");
//************************************************************