throws Exception
{
if (conn_.isConnected() == false) { conn_.connect(); }
/* Get the HostSystem */
HostSystem host = getAvailableHost(hostName);
assert host != null;
/* Check the specified datastore exists and available with the host. */
Datastore datastore = getAvailableDatastore(datastoreName, host);
assert datastore != null;
/* create spec */
Folder vmFolder = null;
OvfCreateImportSpecParams importSpecParams
= new OvfCreateImportSpecParams();
String ovfDescriptor = "";
vmFolder = (Folder) host.getVms()[0].getParent();
importSpecParams.setLocale("US");
importSpecParams.setEntityName(newVmName);
importSpecParams.setDeploymentOption("");
OvfNetworkMapping networkMapping = new OvfNetworkMapping();
networkMapping.setName("Network 1");
networkMapping.setNetwork(host.getNetworks()[0].getMOR());
importSpecParams.setNetworkMapping(new OvfNetworkMapping[] { networkMapping });
importSpecParams.setPropertyMapping(null);
/* read ovf from the file. */
ovfDescriptor = readOvfContent(ovfPath);
/* create ovf descriptor */
ovfDescriptor = escapeSpecialChars(ovfDescriptor);
//logger_.info("ovfDesc: " + ovfDescriptor);
ResourcePool rp = ((ComputeResource) host.getParent()).getResourcePool();
logger_.fine(String.format("vmname: %s\n" +
"resourcepool: %s\n" +
"host:%s\n" +
"datastore:%s\n",
newVmName,
rp.getName(),
host.getName(),
datastore.getName()));
OvfCreateImportSpecResult ovfImportResult = null;
HttpNfcLease httpNfcLease = null;