Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@
package com.cloud.storage.template;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.naming.ConfigurationException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import com.cloud.agent.api.storage.OVFPropertyTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import com.cloud.agent.api.storage.OVFHelper;
import com.cloud.agent.api.to.DatadiskTO;
Expand All @@ -42,6 +45,9 @@
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.script.Script;

/**
* processes the content of an OVA for registration of a template
*/
public class OVAProcessor extends AdapterBase implements Processor {
private static final Logger s_logger = Logger.getLogger(OVAProcessor.class);
StorageLayer _storage;
Expand Down Expand Up @@ -113,7 +119,7 @@ public FormatInfo process(String templatePath, ImageFormat format, String templa
s_logger.info("Found " + ovfProperties.size() + " configurable OVF properties");
info.ovfProperties = ovfProperties;
}
} catch (Exception e) {
} catch (ParserConfigurationException | IOException | SAXException e) {
s_logger.info("The ovf file " + ovfFile + " is invalid ", e);
throw new InternalErrorException("OVA package has bad ovf file " + e.getMessage(), e);
}
Expand Down
2 changes: 2 additions & 0 deletions deps/install-non-oss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ mvn install:install-file -Dfile=vim25_65.jar -DgroupId=com.cloud.com.vmwa

# From https://my.vmware.com/group/vmware/details?downloadGroup=WEBCLIENTSDK67U2&productId=742
mvn install:install-file -Dfile=vim25_67.jar -DgroupId=com.cloud.com.vmware -DartifactId=vmware-vim25 -Dversion=6.7 -Dpackaging=jar

mvn install:install-file -Dfile=pbm_65.jar -DgroupId=com.cloud.com.vmware -DartifactId=pbm -Dversion=6.5 -Dpackaging=jar
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really not in mvn central? I understood Vmware made all their libs redist??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess not, i now see the same for the old API. still seems off, though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a link like in the one above?

6 changes: 6 additions & 0 deletions plugins/hypervisors/vmware/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,11 @@
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<dependency>
<groupId>com.cloud.com.vmware</groupId>
<artifactId>pbm</artifactId>
<version>${cs.vmware.api.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions vmware-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,11 @@
<version>${cs.jaxws.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.cloud.com.vmware</groupId>
<artifactId>pbm</artifactId>
<version>${cs.vmware.api.version}</version>
<scope>compile</scope>
</dependency>
Comment on lines +78 to +83
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is called from both the hypervisor plugin and from the base lib. That does not seem like proper isolation.

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.cloud.hypervisor.vmware.mo;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license needed



import com.cloud.hypervisor.vmware.util.VmwareContext;

import com.vmware.pbm.PbmProfile;
import com.vmware.pbm.PbmProfileId;
import com.vmware.pbm.PbmProfileResourceType;
import com.vmware.pbm.PbmProfileResourceTypeEnum;
import com.vmware.vim25.ManagedObjectReference;

import org.apache.log4j.Logger;

import java.util.List;

public class PbmProfileManagerMO extends BaseMO {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this class provide me? can we have that in javadoc?


private static final Logger s_logger = Logger.getLogger(PbmProfileManagerMO.class);

public PbmProfileManagerMO (VmwareContext context) {
super(context, context.getPbmServiceContent().getProfileManager());
}

public PbmProfileManagerMO (VmwareContext context, ManagedObjectReference morProfileMgr) {
super(context, morProfileMgr);
}

public PbmProfileManagerMO (VmwareContext context, String morType, String morValue) {
super(context, morType, morValue);
}

public List<PbmProfileId> getProfileIds() throws Exception {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Querying vCenter " + _context.getServerAddress() + " for profiles");
}
List<PbmProfileId> profileIds = _context.getPbmService().pbmQueryProfile(_mor, getStorageResourceType(), null);
return profileIds;
}

public List<PbmProfile> getProfiles(PbmProfileResourceType pbmResourceType) throws Exception {
List<PbmProfileId> profileIds = getProfileIds();
List<PbmProfile> profiles = _context.getPbmService().pbmRetrieveContent(_mor, profileIds);
return profiles;
}

private PbmProfileResourceType getStorageResourceType() {
PbmProfileResourceType resourceType = new PbmProfileResourceType();
resourceType.setResourceType(PbmProfileResourceTypeEnum.STORAGE.value());
return resourceType;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import com.vmware.vim25.VStorageObject;
import com.vmware.vim25.VStorageObjectConfigInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;

Expand Down Expand Up @@ -2455,7 +2457,13 @@ public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath) throws
String deviceNumbering = getDeviceBusName(devices, device);

s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);

if (((VirtualDisk) device).getVDiskId() == null) {
s_logger.debug("vDiskid does not exist for volume " + vmdkDatastorePath + " registering the disk now");
VirtualStorageObjectManager vStorageObjectManagerMO = new VirtualStorageObjectManager(getOwnerDatacenter().first().getContext());
VStorageObject vStorageObject = vStorageObjectManagerMO.registerVirtualDisk(dsBackingFile, null, getOwnerDatacenter().first().getName());
VStorageObjectConfigInfo diskConfigInfo = vStorageObject.getConfig();
((VirtualDisk) device).setVDiskId(diskConfigInfo.getId());
}
return new Pair<>((VirtualDisk)device, deviceNumbering);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.hypervisor.vmware.mo;

import com.vmware.vim25.ID;
import com.vmware.vim25.VStorageObject;
import org.apache.log4j.Logger;

import com.vmware.vim25.ManagedObjectReference;

import com.cloud.hypervisor.vmware.util.VmwareContext;

public class VirtualStorageObjectManager extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(VirtualStorageObjectManager.class);

public VirtualStorageObjectManager(VmwareContext context) {
super(context, context.getServiceContent().getVStorageObjectManager());
}

public VirtualStorageObjectManager(VmwareContext context, ManagedObjectReference morDiskMgr) {
super(context, morDiskMgr);
}

public VirtualStorageObjectManager(VmwareContext context, String morType, String morValue) {
super(context, morType, morValue);
}

public VStorageObject registerVirtualDisk(DatastoreFile datastoreFile, String name, String dcName) throws Exception {
StringBuilder sb = new StringBuilder();
//https://10.2.2.254/folder/i-2-4-VM/89e3756d9b7444dc92388eb36ddd026b.vmdk?dcPath=datacenter-21&dsName=c84e4af9b6ac33e887a25d9242650091
sb.append("https://").append(_context.getServerAddress()).append("/folder/");
sb.append(datastoreFile.getRelativePath());
sb.append("?dcPath=");
sb.append(dcName);
sb.append("&dsName=");
sb.append(datastoreFile.getDatastoreName());
return _context.getService().registerDisk(_mor, sb.toString(), name);
}

public VStorageObject retrieveVirtualDisk (ID id, ManagedObjectReference morDS) throws Exception {
return _context.getService().retrieveVStorageObject(_mor, id, morDS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

import org.apache.cloudstack.utils.security.SSLUtils;
import org.apache.cloudstack.utils.security.SecureSSLSocketFactory;
import com.vmware.pbm.PbmPortType;
import com.vmware.pbm.PbmServiceInstanceContent;
import org.apache.log4j.Logger;
import org.w3c.dom.Element;

Expand Down Expand Up @@ -120,8 +122,14 @@ private static void trustAllHttpsCertificates() throws Exception {
}

private final ManagedObjectReference svcInstRef = new ManagedObjectReference();
private final ManagedObjectReference pbmSvcInstRef = new ManagedObjectReference();

private static VimService vimService;
private VimPortType vimPort;
private PbmPortType pbmPort;
private static final String PBM_SERVICE_INSTANCE_TYPE = "PbmServiceInstance";
private static final String PBM_SERVICE_INSTANCE_VALUE = "ServiceInstance";

private String serviceCookie;
private final static String SVC_INST_NAME = "ServiceInstance";
private int vCenterSessionTimeout = 1200000; // Timeout in milliseconds
Expand Down Expand Up @@ -211,6 +219,24 @@ public ServiceContent getServiceContent() {
return null;
}

/**
* @return PBM service instance
*/
public PbmPortType getPbmService() {
return pbmPort;
}

/**
* @return Service instance content
*/
public PbmServiceInstanceContent getPbmServiceContent() {
try {
return pbmPort.pbmRetrieveServiceContent(pbmSvcInstRef);
} catch (com.vmware.pbm.RuntimeFaultFaultMsg e) {
}
return null;
}

/**
* @return cookie used in service connection
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.cloud.hypervisor.vmware.mo.DatastoreFile;
import com.cloud.utils.ActionDelegate;
import com.cloud.utils.StringUtils;
import com.vmware.pbm.PbmPortType;
import com.vmware.pbm.PbmServiceInstanceContent;
import com.vmware.vim25.ManagedObjectReference;
import com.vmware.vim25.ObjectContent;
import com.vmware.vim25.ObjectSpec;
Expand Down Expand Up @@ -148,6 +150,14 @@ public ServiceContent getServiceContent() {
return _vimClient.getServiceContent();
}

public PbmPortType getPbmService() {
return _vimClient.getPbmService();
}

public PbmServiceInstanceContent getPbmServiceContent() {
return _vimClient.getPbmServiceContent();
}

public ManagedObjectReference getPropertyCollector() {
return _vimClient.getPropCol();
}
Expand Down