You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mu...@apache.org on 2012/06/27 04:45:54 UTC
[1/9] git commit: moving out VMWAre and Nexus VSM support code into
plugins/hypervisors/vmware
Updated Branches:
refs/heads/master 550b22576 -> 8197f1f07
moving out VMWAre and Nexus VSM support code into plugins/hypervisors/vmware
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/8197f1f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/8197f1f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/8197f1f0
Branch: refs/heads/master
Commit: 8197f1f07c1dc6762ea60a06e7b9bbe65ba68857
Parents: 550b225
Author: Murali reddy <Mu...@citrix.com>
Authored: Tue Jun 26 19:48:55 2012 -0700
Committer: Murali reddy <Mu...@citrix.com>
Committed: Tue Jun 26 19:48:55 2012 -0700
----------------------------------------------------------------------
.../cloud/api/response/CiscoNexusVSMResponse.java | 112 -
api/src/com/cloud/network/CiscoNexusVSMDevice.java | 72 -
build/build-cloud-plugins.xml | 9 +-
client/tomcatconf/components.xml.in | 3 +
.../hypervisor/hyperv/resource/HypervResource.java | 2 +-
.../vmware/manager/VmwareHostService.java | 25 -
.../hypervisor/vmware/manager/VmwareManager.java | 73 -
.../vmware/manager/VmwareStorageManager.java | 30 -
.../vmware/manager/VmwareStorageManagerImpl.java | 880 ---
.../vmware/manager/VmwareStorageMount.java | 17 -
.../hypervisor/vmware/resource/SshHelper.java | 201 -
.../vmware/resource/VmwareContextFactory.java | 60 -
.../hypervisor/vmware/resource/VmwareResource.java | 4201 --------------
.../resource/PremiumSecondaryStorageResource.java | 101 -
.../VmwareSecondaryStorageContextFactory.java | 68 -
.../VmwareSecondaryStorageResourceHandler.java | 301 -
plugins/hypervisors/vmware/.classpath | 12 +
plugins/hypervisors/vmware/.project | 23 +
plugins/hypervisors/vmware/build.xml | 135 +
.../cloud/api/commands/DeleteCiscoNexusVSMCmd.java | 98 +
.../api/commands/DisableCiscoNexusVSMCmd.java | 98 +
.../cloud/api/commands/EnableCiscoNexusVSMCmd.java | 98 +
.../cloud/api/commands/ListCiscoNexusVSMsCmd.java | 117 +
.../cloud/api/response/CiscoNexusVSMResponse.java | 112 +
.../vmware/src/com/cloud/ha/VmwareFencer.java | 56 +
.../src/com/cloud/ha/VmwareInvestigator.java | 44 +
.../src/com/cloud/hypervisor/guru/VMwareGuru.java | 311 ++
.../cloud/hypervisor/vmware/VmwareCleanupMaid.java | 143 +
.../hypervisor/vmware/VmwareServerDiscoverer.java | 364 ++
.../vmware/manager/VmwareHostService.java | 25 +
.../hypervisor/vmware/manager/VmwareManager.java | 73 +
.../vmware/manager/VmwareManagerImpl.java | 992 ++++
.../vmware/manager/VmwareStorageManager.java | 30 +
.../vmware/manager/VmwareStorageManagerImpl.java | 880 +++
.../vmware/manager/VmwareStorageMount.java | 17 +
.../vmware/resource/VmwareContextFactory.java | 60 +
.../hypervisor/vmware/resource/VmwareResource.java | 4202 +++++++++++++++
.../src/com/cloud/network/CiscoNexusVSMDevice.java | 72 +
.../network/CiscoNexusVSMDeviceManagerImpl.java | 408 ++
.../com/cloud/network/CiscoNexusVSMDeviceVO.java | 222 +
.../cloud/network/dao/CiscoNexusVSMDeviceDao.java | 107 +
.../network/dao/CiscoNexusVSMDeviceDaoImpl.java | 108 +
.../network/element/CiscoNexusVSMElement.java | 238 +
.../element/CiscoNexusVSMElementService.java | 72 +
.../resource/PremiumSecondaryStorageResource.java | 101 +
.../VmwareSecondaryStorageContextFactory.java | 68 +
.../VmwareSecondaryStorageResourceHandler.java | 301 +
.../cloud/api/commands/DeleteCiscoNexusVSMCmd.java | 98 -
.../api/commands/DisableCiscoNexusVSMCmd.java | 98 -
.../cloud/api/commands/EnableCiscoNexusVSMCmd.java | 98 -
.../cloud/api/commands/ListCiscoNexusVSMsCmd.java | 117 -
.../configuration/DefaultComponentLibrary.java | 5 -
.../configuration/PremiumComponentLibrary.java | 2 -
server/src/com/cloud/ha/VmwareFencer.java | 56 -
server/src/com/cloud/ha/VmwareInvestigator.java | 44 -
.../src/com/cloud/hypervisor/guru/VMwareGuru.java | 311 --
.../cloud/hypervisor/vmware/VmwareCleanupMaid.java | 143 -
.../cloud/hypervisor/vmware/VmwareManagerImpl.java | 991 ----
.../hypervisor/vmware/VmwareServerDiscoverer.java | 364 --
.../network/CiscoNexusVSMDeviceManagerImpl.java | 315 --
.../com/cloud/network/CiscoNexusVSMDeviceVO.java | 222 -
.../cloud/network/dao/CiscoNexusVSMDeviceDao.java | 107 -
.../network/dao/CiscoNexusVSMDeviceDaoImpl.java | 108 -
.../network/element/CiscoNexusVSMElement.java | 238 -
.../element/CiscoNexusVSMElementService.java | 72 -
.../com/cloud/resource/ResourceManagerImpl.java | 95 -
utils/src/com/cloud/utils/ssh/SshHelper.java | 201 +
67 files changed, 9799 insertions(+), 9628 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java b/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java
deleted file mode 100644
index e0169d3..0000000
--- a/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java
+++ /dev/null
@@ -1,112 +0,0 @@
-// 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.api.response;
-
-import javax.persistence.Column;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.utils.IdentityProxy;
-import com.cloud.serializer.Param;
-import com.google.gson.annotations.SerializedName;
-
-public class CiscoNexusVSMResponse extends BaseResponse {
-
- @SerializedName(ApiConstants.EXTERNAL_SWITCH_MGMT_DEVICE_ID) @Param(description="device id of the Cisco N1KV VSM device")
- private IdentityProxy id = new IdentityProxy("virtual_supervisor_module");
-
- @SerializedName(ApiConstants.EXTERNAL_SWITCH_MGMT_DEVICE_NAME) @Param(description="device name")
- private String deviceName;
-
- @SerializedName(ApiConstants.IP_ADDRESS) @Param(description="the management IP address of the external Cisco Nexus 1000v Virtual Supervisor Module")
- private String vsmmgmtIpAddress;
-
- @SerializedName(ApiConstants.EXTERNAL_SWITCH_MGMT_DEVICE_STATE) @Param(description="device state")
- private String deviceState;
-
- @SerializedName(ApiConstants.VSM_MGMT_VLAN_ID) @Param(description="management vlan id of the VSM")
- private String vsmmgmtvlanid;
-
- @SerializedName(ApiConstants.VSM_CTRL_VLAN_ID) @Param(description="control vlan id of the VSM")
- private int vsmctrlvlanid;
-
- @SerializedName(ApiConstants.VSM_PKT_VLAN_ID) @Param(description="packet vlan id of the VSM")
- private int vsmpktvlanid;
-
- @SerializedName(ApiConstants.VSM_STORAGE_VLAN_ID) @Param(description="storage vlan id of the VSM")
- private int vsmstoragevlanid;
-
- @SerializedName(ApiConstants.VSM_DOMAIN_ID) @Param(description="The VSM is a switch supervisor. This is the VSM's switch domain id")
- private String vsmdomainid;
-
- @SerializedName(ApiConstants.VSM_CONFIG_MODE) @Param(description="The mode of the VSM (standalone/HA)")
- private String vsmconfigmode;
-
- @SerializedName(ApiConstants.VSM_CONFIG_STATE) @Param(description="The Config State (Primary/Standby) of the VSM")
- private String vsmconfigstate;
-
- @SerializedName(ApiConstants.VSM_DEVICE_STATE) @Param(description="The Device State (Enabled/Disabled) of the VSM")
- private String vsmdevicestate;
-
- // Setter methods.
- public void setId(long vsmDeviceId) {
- this.id.setValue(vsmDeviceId);
- }
-
- public void setDeviceName(String deviceName) {
- this.deviceName = deviceName;
- }
-
- public void setMgmtIpAddress(String ipAddress) {
- this.vsmmgmtIpAddress = ipAddress;
- }
-
- public void setDeviceState(String deviceState) {
- this.deviceState = deviceState;
- }
-
- public void setVSMMgmtVlanId(String vlanId) {
- this.vsmmgmtvlanid = vlanId;
- }
-
- public void setVSMCtrlVlanId(int vlanId) {
- this.vsmctrlvlanid = vlanId;
- }
-
- public void setVSMPktVlanId(int vlanId) {
- this.vsmpktvlanid = vlanId;
- }
-
- public void setVSMStorageVlanId(int vlanId) {
- this.vsmstoragevlanid = vlanId;
- }
-
- public void setVSMDomainId(String domId) {
- this.vsmdomainid = domId;
- }
-
- public void setVSMConfigMode(String configMode) {
- this.vsmconfigmode = configMode;
- }
-
- public void setVSMConfigState(String configState) {
- this.vsmconfigstate = configState;
- }
-
- public void setVSMDeviceState(String devState) {
- this.vsmdevicestate = devState;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/api/src/com/cloud/network/CiscoNexusVSMDevice.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/CiscoNexusVSMDevice.java b/api/src/com/cloud/network/CiscoNexusVSMDevice.java
deleted file mode 100644
index db0db55..0000000
--- a/api/src/com/cloud/network/CiscoNexusVSMDevice.java
+++ /dev/null
@@ -1,72 +0,0 @@
-// 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.network;
-
-public interface CiscoNexusVSMDevice {
-
- // This tells us whether the VSM is currently enabled or disabled. We may
- // need this if we would like to carry out any sort of maintenance on the
- // VSM or CS.
- public enum VSMDeviceState {
- Enabled,
- Disabled
- }
-
- // This tells us whether the VSM is currently configured with a standby (HA)
- // or does not have any standby (Standalone).
- public enum VSMConfigMode {
- Standalone,
- HA
- }
-
- // This tells us whether the VSM is currently a primary or a standby VSM.
- public enum VSMConfigState {
- Primary,
- Standby
- }
-
- long getId();
-
- public String getvsmName();
-
- public long getHostId();
-
- public String getUserName();
-
- public String getPassword();
-
- public String getipaddr();
-
- public int getManagementVlan();
-
- public int getControlVlan();
-
- public int getPacketVlan();
-
- public int getStorageVlan();
-
- public long getvsmDomainId();
-
- public VSMConfigMode getvsmConfigMode();
-
- public VSMConfigState getvsmConfigState();
-
- public VSMDeviceState getvsmDeviceState();
-
- public String getUuid();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/build/build-cloud-plugins.xml
----------------------------------------------------------------------
diff --git a/build/build-cloud-plugins.xml b/build/build-cloud-plugins.xml
index 0ca3396..53dc1d3 100755
--- a/build/build-cloud-plugins.xml
+++ b/build/build-cloud-plugins.xml
@@ -198,8 +198,8 @@
<!-- ===================== Hypervisors ========================= -->
- <target name="compile-hypervisors" depends="compile-ovm, compile-xen" description="Compile all hypervisors"/>
- <target name="build-hypervisors" depends="build-ovm, build-xen" description="Builds all hypervisors"/>
+ <target name="compile-hypervisors" depends="compile-ovm, compile-xen, compile-vmware" description="Compile all hypervisors"/>
+ <target name="build-hypervisors" depends="build-ovm, build-xen, build-vmware" description="Builds all hypervisors"/>
<target name="compile-ovm" depends="-init, compile-server" description="Compile OVM">
<ant antfile="${base.dir}/plugins/hypervisors/ovm/build.xml" target="build"/>
@@ -212,6 +212,11 @@
</target>
<target name="build-xen" depends="compile-xen" />
+ <target name="compile-vmware" depends="-init, compile-server" description="Compiles Vmware">
+ <ant antfile="${base.dir}/plugins/hypervisors/vmware/build.xml" target="build"/>
+ </target>
+ <target name="build-vmware" depends="compile-vmware" />
+
<!-- ===================== Deployment Planners ================= -->
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/client/tomcatconf/components.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in
index 58541a5..5add24c 100755
--- a/client/tomcatconf/components.xml.in
+++ b/client/tomcatconf/components.xml.in
@@ -157,11 +157,14 @@
<adapters key="com.cloud.agent.StartupCommandProcessor">
<adapter name="BasicAgentAuthorizer" class="com.cloud.agent.manager.authn.impl.BasicAgentAuthManager"/>
</adapters>
+ <manager name="VmwareManager" key="com.cloud.hypervisor.vmware.manager.VmwareManager" class="com.cloud.hypervisor.vmware.manager.VmwareManagerImpl"/>
<pluggableservice name="VirtualRouterElementService" key="com.cloud.network.element.VirtualRouterElementService" class="com.cloud.network.element.VirtualRouterElement"/>
<pluggableservice name="NetscalerExternalLoadBalancerElementService" key="com.cloud.network.element.NetscalerLoadBalancerElementService" class="com.cloud.network.element.NetscalerElement"/>
<pluggableservice name="F5ExternalLoadBalancerElementService" key="com.cloud.network.element.F5ExternalLoadBalancerElementService" class="com.cloud.network.element.F5ExternalLoadBalancerElement"/>
<pluggableservice name="JuniperSRXFirewallElementService" key="com.cloud.network.element.JuniperSRXFirewallElementService" class="com.cloud.network.element.JuniperSRXExternalFirewallElement"/>
+ <pluggableservice name="CiscoNexusVSMElementService" key="com.coud.network.element.CiscoNexusVSMElementService" class="com.cloud.network.element.CiscoNexusVSMElement"/>
<dao name="NetScalerPodDao" class="com.cloud.network.dao.NetScalerPodDaoImpl" singleton="false"/>
+ <dao name="CiscoNexusVSMDeviceDao" class="com.cloud.network.dao.CiscoNexusVSMDeviceDaoImpl" singleton="false"/>
</management-server>
<configuration-server class="com.cloud.server.ConfigurationServerImpl">
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/core/src/com/cloud/hypervisor/hyperv/resource/HypervResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/hyperv/resource/HypervResource.java b/core/src/com/cloud/hypervisor/hyperv/resource/HypervResource.java
index 6f47b54..868a81e 100755
--- a/core/src/com/cloud/hypervisor/hyperv/resource/HypervResource.java
+++ b/core/src/com/cloud/hypervisor/hyperv/resource/HypervResource.java
@@ -96,7 +96,7 @@ import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.agent.api.to.VolumeTO;
import com.cloud.host.Host.Type;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.hypervisor.vmware.resource.SshHelper;
+import com.cloud.utils.ssh.SshHelper;
import com.cloud.resource.ServerResource;
import com.cloud.resource.ServerResourceBase;
import com.cloud.serializer.GsonHelper;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/core/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java b/core/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
deleted file mode 100644
index 5822af8..0000000
--- a/core/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.hypervisor.vmware.manager;
-
-import com.cloud.agent.api.Command;
-import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
-import com.cloud.hypervisor.vmware.util.VmwareContext;
-
-public interface VmwareHostService {
- VmwareContext getServiceContext(Command cmd);
- void invalidateServiceContext(VmwareContext context);
- VmwareHypervisorHost getHyperHost(VmwareContext context, Command cmd);
-
- String getWorkerName(VmwareContext context, Command cmd, int workerSequence);
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java b/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
deleted file mode 100755
index 7d85a96..0000000
--- a/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.hypervisor.vmware.manager;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.hypervisor.vmware.mo.HostMO;
-import com.cloud.hypervisor.vmware.util.VmwareContext;
-import com.cloud.utils.Pair;
-import com.vmware.vim25.ManagedObjectReference;
-
-public interface VmwareManager {
- public final String CONTEXT_STOCK_NAME = "vmwareMgr";
-
- // this limitation comes from the fact that we are using linked clone on shared VMFS storage,
- // we need to limit the size of vCenter cluster, http://en.wikipedia.org/wiki/VMware_VMFS
- public final int MAX_HOSTS_PER_CLUSTER = 8;
-
- String composeWorkerName();
-
- String getSystemVMIsoFileNameOnDatastore();
- String getSystemVMDefaultNicAdapterType();
-
- void prepareSecondaryStorageStore(String strStorageUrl);
-
- void setupResourceStartupParams(Map<String, Object> params);
- List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId,
- String hostInventoryPath) throws Exception;
-
- String getManagementPortGroupByHost(HostMO hostMo) throws Exception;
- String getServiceConsolePortGroupName();
- String getManagementPortGroupName();
-
- String getSecondaryStorageStoreUrl(long dcId);
-
- File getSystemVMKeyFile();
-
- VmwareStorageManager getStorageManager();
- long pushCleanupCheckpoint(String hostGuid, String vmName);
- void popCleanupCheckpoint(long checkpiont);
- void gcLeftOverVMs(VmwareContext context);
-
- Pair<Integer, Integer> getAddiionalVncPortRange();
-
- int getMaxHostsPerCluster();
- int getRouterExtraPublicNics();
-
- boolean beginExclusiveOperation(int timeOutSeconds);
- void endExclusiveOperation();
-
- boolean getNexusVSwitchGlobalParameter();
-
- Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId);
-
- String getPrivateVSwitchName(long dcId, HypervisorType hypervisorType);
-
- String getPublicVSwitchName(long dcId, HypervisorType hypervisorType);
-
- String getGuestVSwitchName(long dcId, HypervisorType hypervisorType);
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java b/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java
deleted file mode 100644
index b237291..0000000
--- a/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.hypervisor.vmware.manager;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.BackupSnapshotCommand;
-import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
-import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
-import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
-import com.cloud.agent.api.storage.CopyVolumeCommand;
-import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
-
-public interface VmwareStorageManager {
- Answer execute(VmwareHostService hostService, PrimaryStorageDownloadCommand cmd);
- Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd);
- Answer execute(VmwareHostService hostService, CreatePrivateTemplateFromVolumeCommand cmd);
- Answer execute(VmwareHostService hostService, CreatePrivateTemplateFromSnapshotCommand cmd);
- Answer execute(VmwareHostService hostService, CopyVolumeCommand cmd);
- Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd);
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
deleted file mode 100644
index afd13d1..0000000
--- a/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
+++ /dev/null
@@ -1,880 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.hypervisor.vmware.manager;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.rmi.RemoteException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.BackupSnapshotAnswer;
-import com.cloud.agent.api.BackupSnapshotCommand;
-import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
-import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
-import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
-import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
-import com.cloud.agent.api.storage.CopyVolumeAnswer;
-import com.cloud.agent.api.storage.CopyVolumeCommand;
-import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
-import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
-import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
-import com.cloud.agent.api.to.StorageFilerTO;
-import com.cloud.hypervisor.vmware.mo.CustomFieldConstants;
-import com.cloud.hypervisor.vmware.mo.DatacenterMO;
-import com.cloud.hypervisor.vmware.mo.DatastoreMO;
-import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
-import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
-import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
-import com.cloud.hypervisor.vmware.util.VmwareContext;
-import com.cloud.hypervisor.vmware.util.VmwareHelper;
-import com.cloud.storage.JavaStorageLayer;
-import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.StorageLayer;
-import com.cloud.storage.template.VmdkProcessor;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.Pair;
-import com.cloud.utils.StringUtils;
-import com.cloud.utils.Ternary;
-import com.cloud.utils.script.Script;
-import com.vmware.vim25.ManagedObjectReference;
-import com.vmware.vim25.VirtualDeviceConfigSpec;
-import com.vmware.vim25.VirtualDeviceConfigSpecOperation;
-import com.vmware.vim25.VirtualDisk;
-import com.vmware.vim25.VirtualLsiLogicController;
-import com.vmware.vim25.VirtualMachineConfigSpec;
-import com.vmware.vim25.VirtualMachineFileInfo;
-import com.vmware.vim25.VirtualMachineGuestOsIdentifier;
-import com.vmware.vim25.VirtualSCSISharing;
-
-public class VmwareStorageManagerImpl implements VmwareStorageManager {
- private static final Logger s_logger = Logger.getLogger(VmwareStorageManagerImpl.class);
-
- private final VmwareStorageMount _mountService;
- private final StorageLayer _storage = new JavaStorageLayer();
-
- private int _timeout;
-
- public VmwareStorageManagerImpl(VmwareStorageMount mountService) {
- assert(mountService != null);
- _mountService = mountService;
- }
-
- public void configure(Map<String, Object> params) {
- s_logger.info("Configure VmwareStorageManagerImpl");
-
- String value = (String)params.get("scripts.timeout");
- _timeout = NumbersUtil.parseInt(value, 1440) * 1000;
- }
-
- @Override
- public Answer execute(VmwareHostService hostService, PrimaryStorageDownloadCommand cmd) {
- String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
- assert (secondaryStorageUrl != null);
-
- String templateUrl = cmd.getUrl();
-
- String templateName = null;
- String mountPoint = null;
- if (templateUrl.endsWith(".ova")) {
- int index = templateUrl.lastIndexOf("/");
- mountPoint = templateUrl.substring(0, index);
- mountPoint = mountPoint.substring(secondaryStorageUrl.length() + 1);
- if (!mountPoint.endsWith("/")) {
- mountPoint = mountPoint + "/";
- }
-
- templateName = templateUrl.substring(index + 1).replace("." + ImageFormat.OVA.getFileExtension(), "");
-
- if (templateName == null || templateName.isEmpty()) {
- templateName = cmd.getName();
- }
- } else {
- mountPoint = templateUrl.substring(secondaryStorageUrl.length() + 1);
- if (!mountPoint.endsWith("/")) {
- mountPoint = mountPoint + "/";
- }
- templateName = cmd.getName();
- }
-
- VmwareContext context = hostService.getServiceContext(cmd);
- try {
- VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
-
- String templateUuidName = UUID.nameUUIDFromBytes((templateName + "@" + cmd.getPoolUuid() + "-" + hyperHost.getMor().get_value()).getBytes()).toString();
- // truncate template name to 32 chars to ensure they work well with vSphere API's.
- templateUuidName = templateUuidName.replace("-", "");
-
- DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
- VirtualMachineMO templateMo = VmwareHelper.pickOneVmOnRunningHost(dcMo.findVmByNameAndLabel(templateUuidName), true);
-
- if (templateMo == null) {
- if(s_logger.isInfoEnabled())
- s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName);
- ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
- assert (morDs != null);
- DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs);
-
- copyTemplateFromSecondaryToPrimary(hyperHost,
- primaryStorageDatastoreMo, secondaryStorageUrl,
- mountPoint, templateName, templateUuidName);
- } else {
- s_logger.info("Template " + templateName + " has already been setup, skip the template setup process in primary storage");
- }
-
- return new PrimaryStorageDownloadAnswer(templateUuidName, 0);
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- hostService.invalidateServiceContext(context);
- }
-
- String msg = "Unable to execute PrimaryStorageDownloadCommand due to exception";
- s_logger.error(msg, e);
- return new PrimaryStorageDownloadAnswer(msg);
- }
- }
-
- @Override
- public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd) {
- Long accountId = cmd.getAccountId();
- Long volumeId = cmd.getVolumeId();
- String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
- String snapshotUuid = cmd.getSnapshotUuid(); // not null: Precondition.
- String prevSnapshotUuid = cmd.getPrevSnapshotUuid();
- String prevBackupUuid = cmd.getPrevBackupUuid();
- VirtualMachineMO workerVm=null;
- String workerVMName = null;
- String volumePath = cmd.getVolumePath();
- ManagedObjectReference morDs = null;
- DatastoreMO dsMo=null;
-
- // By default assume failure
- String details = null;
- boolean success = false;
- String snapshotBackupUuid = null;
-
- VmwareContext context = hostService.getServiceContext(cmd);
- VirtualMachineMO vmMo = null;
- try {
- VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
- morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPool().getUuid());
-
- try {
- vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
- if (vmMo == null) {
- if(s_logger.isDebugEnabled())
- s_logger.debug("Unable to find owner VM for BackupSnapshotCommand on host " + hyperHost.getHyperHostName() + ", will try within datacenter");
-
- vmMo = hyperHost.findVmOnPeerHyperHost(cmd.getVmName());
- if(vmMo == null) {
- dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
-
- workerVMName = hostService.getWorkerName(context, cmd, 0);
-
- // attach a volume to dummay wrapper VM for taking snapshot and exporting the VM for backup
- if (!hyperHost.createBlankVm(workerVMName, 1, 512, 0, false, 4, 0, VirtualMachineGuestOsIdentifier._otherGuest.toString(), morDs, false)) {
- String msg = "Unable to create worker VM to execute BackupSnapshotCommand";
- s_logger.error(msg);
- throw new Exception(msg);
- }
- vmMo = hyperHost.findVmOnHyperHost(workerVMName);
- if (vmMo == null) {
- throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName);
- }
- workerVm = vmMo;
-
- // attach volume to worker VM
- String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
- vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
- }
- }
-
- if (!vmMo.createSnapshot(snapshotUuid, "Snapshot taken for " + cmd.getSnapshotName(), false, false)) {
- throw new Exception("Failed to take snapshot " + cmd.getSnapshotName() + " on vm: " + cmd.getVmName());
- }
-
- snapshotBackupUuid = backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, prevBackupUuid,
- hostService.getWorkerName(context, cmd, 1));
-
- success = (snapshotBackupUuid != null);
- if (success) {
- details = "Successfully backedUp the snapshotUuid: " + snapshotUuid + " to secondary storage.";
- }
-
- } finally {
- if(vmMo != null)
- vmMo.removeAllSnapshots();
-
- try {
- if (workerVm != null) {
- // detach volume and destroy worker vm
- workerVm.detachAllDisks();
- workerVm.destroy();
- }
- } catch (Throwable e) {
- s_logger.warn("Failed to destroy worker VM: " + workerVMName);
- }
- }
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- hostService.invalidateServiceContext(context);
- }
-
- s_logger.error("Unexpecpted exception ", e);
-
- details = "BackupSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
- return new BackupSnapshotAnswer(cmd, false, details, snapshotBackupUuid, true);
- }
-
- return new BackupSnapshotAnswer(cmd, success, details, snapshotBackupUuid, true);
- }
-
- @Override
- public Answer execute(VmwareHostService hostService, CreatePrivateTemplateFromVolumeCommand cmd) {
- String secondaryStoragePoolURL = cmd.getSecondaryStorageUrl();
- String volumePath = cmd.getVolumePath();
- Long accountId = cmd.getAccountId();
- Long templateId = cmd.getTemplateId();
- String details = null;
-
- VmwareContext context = hostService.getServiceContext(cmd);
- try {
- VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
-
- VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
- if (vmMo == null) {
- if(s_logger.isDebugEnabled())
- s_logger.debug("Unable to find the owner VM for CreatePrivateTemplateFromVolumeCommand on host " + hyperHost.getHyperHostName() + ", try within datacenter");
- vmMo = hyperHost.findVmOnPeerHyperHost(cmd.getVmName());
-
- if(vmMo == null) {
- String msg = "Unable to find the owner VM for volume operation. vm: " + cmd.getVmName();
- s_logger.error(msg);
- throw new Exception(msg);
- }
- }
-
- Ternary<String, Long, Long> result = createTemplateFromVolume(vmMo,
- accountId, templateId, cmd.getUniqueName(),
- secondaryStoragePoolURL, volumePath,
- hostService.getWorkerName(context, cmd, 0));
-
- return new CreatePrivateTemplateAnswer(cmd, true, null,
- result.first(), result.third(), result.second(),
- cmd.getUniqueName(), ImageFormat.OVA);
-
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- hostService.invalidateServiceContext(context);
- }
-
- s_logger.error("Unexpecpted exception ", e);
-
- details = "CreatePrivateTemplateFromVolumeCommand exception: " + StringUtils.getExceptionStackInfo(e);
- return new CreatePrivateTemplateAnswer(cmd, false, details);
- }
- }
-
- @Override
- public Answer execute(VmwareHostService hostService, CreatePrivateTemplateFromSnapshotCommand cmd) {
- Long accountId = cmd.getAccountId();
- Long volumeId = cmd.getVolumeId();
- String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
- String backedUpSnapshotUuid = cmd.getSnapshotUuid();
- Long newTemplateId = cmd.getNewTemplateId();
- String details;
- String uniqeName = UUID.randomUUID().toString();
-
- VmwareContext context = hostService.getServiceContext(cmd);
- try {
- Ternary<String, Long, Long> result = createTemplateFromSnapshot(accountId,
- newTemplateId, uniqeName,
- secondaryStorageUrl, volumeId,
- backedUpSnapshotUuid);
-
- return new CreatePrivateTemplateAnswer(cmd, true, null,
- result.first(), result.third(), result.second(),
- uniqeName, ImageFormat.OVA);
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- hostService.invalidateServiceContext(context);
- }
-
- s_logger.error("Unexpecpted exception ", e);
-
- details = "CreatePrivateTemplateFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
- return new CreatePrivateTemplateAnswer(cmd, false, details);
- }
- }
-
- @Override
- public Answer execute(VmwareHostService hostService, CopyVolumeCommand cmd) {
- Long volumeId = cmd.getVolumeId();
- String volumePath = cmd.getVolumePath();
- String secondaryStorageURL = cmd.getSecondaryStorageURL();
- String vmName = cmd.getVmName();
-
- VmwareContext context = hostService.getServiceContext(cmd);
- try {
- VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
-
- Pair<String, String> result;
- if (cmd.toSecondaryStorage()) {
- result = copyVolumeToSecStorage(hostService,
- hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath,
- secondaryStorageURL,
- hostService.getWorkerName(context, cmd, 0));
- } else {
- StorageFilerTO poolTO = cmd.getPool();
-
- ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolTO.getUuid());
- if (morDatastore == null) {
- morDatastore = hyperHost.mountDatastore(
- false,
- poolTO.getHost(), 0, poolTO.getPath(),
- poolTO.getUuid().replace("-", ""));
-
- if (morDatastore == null) {
- throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath());
- }
- }
-
- result = copyVolumeFromSecStorage(
- hyperHost, volumeId,
- new DatastoreMO(context, morDatastore),
- secondaryStorageURL, volumePath);
- }
- return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second());
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- hostService.invalidateServiceContext(context);
- }
-
- String msg = "Unable to execute CopyVolumeCommand due to exception";
- s_logger.error(msg, e);
- return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
- }
- }
-
- @Override
- public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd) {
-
- String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel();
- Long accountId = cmd.getAccountId();
- Long volumeId = cmd.getVolumeId();
- String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
- String backedUpSnapshotUuid = cmd.getSnapshotUuid();
-
- String details = null;
- boolean success = false;
- String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
-
- VmwareContext context = hostService.getServiceContext(cmd);
- try {
- VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
-
- ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStorageNameLabel);
- if (morPrimaryDs == null) {
- String msg = "Unable to find datastore: " + primaryStorageNameLabel;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
- details = createVolumeFromSnapshot(hyperHost, primaryDsMo,
- newVolumeName, accountId, volumeId, secondaryStorageUrl, backedUpSnapshotUuid);
- if (details == null) {
- success = true;
- }
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- hostService.invalidateServiceContext(context);
- }
-
- s_logger.error("Unexpecpted exception ", e);
- details = "CreateVolumeFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
- }
-
- return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
- }
-
- // templateName: name in secondary storage
- // templateUuid: will be used at hypervisor layer
- private void copyTemplateFromSecondaryToPrimary(VmwareHypervisorHost hyperHost, DatastoreMO datastoreMo, String secondaryStorageUrl,
- String templatePathAtSecondaryStorage, String templateName, String templateUuid) throws Exception {
-
- s_logger.info("Executing copyTemplateFromSecondaryToPrimary. secondaryStorage: "
- + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " + templatePathAtSecondaryStorage
- + ", templateName: " + templateName);
-
- String secondaryMountPoint = _mountService.getMountPoint(secondaryStorageUrl);
- s_logger.info("Secondary storage mount point: " + secondaryMountPoint);
-
- String srcOVAFileName = secondaryMountPoint + "/" + templatePathAtSecondaryStorage +
- templateName + "." + ImageFormat.OVA.getFileExtension();
-
- String srcFileName = getOVFFilePath(srcOVAFileName);
- if(srcFileName == null) {
- Script command = new Script("tar", 0, s_logger);
- command.add("--no-same-owner");
- command.add("-xf", srcOVAFileName);
- command.setWorkDir(secondaryMountPoint + "/" + templatePathAtSecondaryStorage);
- s_logger.info("Executing command: " + command.toString());
- String result = command.execute();
- if(result != null) {
- String msg = "Unable to unpack snapshot OVA file at: " + srcOVAFileName;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- }
-
- srcFileName = getOVFFilePath(srcOVAFileName);
- if(srcFileName == null) {
- String msg = "Unable to locate OVF file in template package directory: " + srcOVAFileName;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- String vmName = templateUuid;
- hyperHost.importVmFromOVF(srcFileName, vmName, datastoreMo, "thin");
-
- VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
- if(vmMo == null) {
- String msg = "Failed to import OVA template. secondaryStorage: "
- + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " + templatePathAtSecondaryStorage
- + ", templateName: " + templateName + ", templateUuid: " + templateUuid;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- if(vmMo.createSnapshot("cloud.template.base", "Base snapshot", false, false)) {
- vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_UUID, templateUuid);
- vmMo.markAsTemplate();
- } else {
- vmMo.destroy();
- String msg = "Unable to create base snapshot for template, templateName: " + templateName + ", templateUuid: " + templateUuid;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- }
-
- private Ternary<String, Long, Long> createTemplateFromVolume(VirtualMachineMO vmMo, long accountId, long templateId, String templateUniqueName,
- String secStorageUrl, String volumePath, String workerVmName) throws Exception {
-
- String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
- String installPath = getTemplateRelativeDirInSecStorage(accountId, templateId);
- String installFullPath = secondaryMountPoint + "/" + installPath;
- synchronized(installPath.intern()) {
- Script command = new Script(false, "mkdir", _timeout, s_logger);
- command.add("-p");
- command.add(installFullPath);
-
- String result = command.execute();
- if(result != null) {
- String msg = "unable to prepare template directory: "
- + installPath + ", storage: " + secStorageUrl + ", error msg: " + result;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- }
-
- VirtualMachineMO clonedVm = null;
- try {
- Pair<VirtualDisk, String> volumeDeviceInfo = vmMo.getDiskDevice(volumePath, false);
- if(volumeDeviceInfo == null) {
- String msg = "Unable to find related disk device for volume. volume path: " + volumePath;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- if(!vmMo.createSnapshot(templateUniqueName, "Temporary snapshot for template creation", false, false)) {
- String msg = "Unable to take snapshot for creating template from volume. volume path: " + volumePath;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- // 4 MB is the minimum requirement for VM memory in VMware
- vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(),
- VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
- clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
- if(clonedVm == null) {
- String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- clonedVm.exportVm(secondaryMountPoint + "/" + installPath, templateUniqueName, true, false);
-
- long physicalSize = new File(installFullPath + "/" + templateUniqueName + ".ova").length();
- VmdkProcessor processor = new VmdkProcessor();
- Map<String, Object> params = new HashMap<String, Object>();
- params.put(StorageLayer.InstanceConfigKey, _storage);
- processor.configure("VMDK Processor", params);
- long virtualSize = processor.getTemplateVirtualSize(installFullPath, templateUniqueName);
-
- postCreatePrivateTemplate(installFullPath, templateId, templateUniqueName, physicalSize, virtualSize);
- return new Ternary<String, Long, Long>(installPath + "/" + templateUniqueName + ".ova", physicalSize, virtualSize);
-
- } finally {
- if(clonedVm != null) {
- clonedVm.detachAllDisks();
- clonedVm.destroy();
- }
-
- vmMo.removeSnapshot(templateUniqueName, false);
- }
- }
-
- private Ternary<String, Long, Long> createTemplateFromSnapshot(long accountId, long templateId, String templateUniqueName,
- String secStorageUrl, long volumeId, String backedUpSnapshotUuid) throws Exception {
-
- String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
- String installPath = getTemplateRelativeDirInSecStorage(accountId, templateId);
- String installFullPath = secondaryMountPoint + "/" + installPath;
- String installFullName = installFullPath + "/" + templateUniqueName + ".ova";
- String snapshotFullName = secondaryMountPoint + "/" + getSnapshotRelativeDirInSecStorage(accountId, volumeId)
- + "/" + backedUpSnapshotUuid + ".ova";
- String result;
- Script command;
-
- synchronized(installPath.intern()) {
- command = new Script(false, "mkdir", _timeout, s_logger);
- command.add("-p");
- command.add(installFullPath);
-
- result = command.execute();
- if(result != null) {
- String msg = "unable to prepare template directory: "
- + installPath + ", storage: " + secStorageUrl + ", error msg: " + result;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- }
-
- try {
- command = new Script(false, "cp", _timeout, s_logger);
- command.add(snapshotFullName);
- command.add(installFullName);
- result = command.execute();
- if(result != null) {
- String msg = "unable to copy snapshot " + snapshotFullName + " to " + installFullPath;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- // untar OVA file at template directory
- command = new Script("tar", 0, s_logger);
- command.add("--no-same-owner");
- command.add("-xf", installFullName);
- command.setWorkDir(installFullPath);
- s_logger.info("Executing command: " + command.toString());
- result = command.execute();
- if(result != null) {
- String msg = "unable to untar snapshot " + snapshotFullName + " to "
- + installFullPath;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- long physicalSize = new File(installFullPath + "/" + templateUniqueName + ".ova").length();
- VmdkProcessor processor = new VmdkProcessor();
- Map<String, Object> params = new HashMap<String, Object>();
- params.put(StorageLayer.InstanceConfigKey, _storage);
- processor.configure("VMDK Processor", params);
- long virtualSize = processor.getTemplateVirtualSize(installFullPath, templateUniqueName);
-
- postCreatePrivateTemplate(installFullPath, templateId, templateUniqueName, physicalSize, virtualSize);
- return new Ternary<String, Long, Long>(installPath + "/" + templateUniqueName + ".ova", physicalSize, virtualSize);
-
- } catch(Exception e) {
- // TODO, clean up left over files
- throw e;
- }
- }
-
- private void postCreatePrivateTemplate(String installFullPath, long templateId,
- String templateName, long size, long virtualSize) throws Exception {
-
- // TODO a bit ugly here
- BufferedWriter out = null;
- try {
- out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(installFullPath + "/template.properties")));
- out.write("filename=" + templateName + ".ova");
- out.newLine();
- out.write("description=");
- out.newLine();
- out.write("checksum=");
- out.newLine();
- out.write("hvm=false");
- out.newLine();
- out.write("size=" + size);
- out.newLine();
- out.write("ova=true");
- out.newLine();
- out.write("id=" + templateId);
- out.newLine();
- out.write("public=false");
- out.newLine();
- out.write("ova.filename=" + templateName + ".ova");
- out.newLine();
- out.write("uniquename=" + templateName);
- out.newLine();
- out.write("ova.virtualsize=" + virtualSize);
- out.newLine();
- out.write("virtualsize=" + virtualSize);
- out.newLine();
- out.write("ova.size=" + size);
- out.newLine();
- } finally {
- if(out != null)
- out.close();
- }
- }
-
- private String createVolumeFromSnapshot(VmwareHypervisorHost hyperHost, DatastoreMO primaryDsMo, String newVolumeName,
- long accountId, long volumeId, String secStorageUrl, String snapshotBackupUuid) throws Exception {
-
- restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName,
- secStorageUrl, getSnapshotRelativeDirInSecStorage(accountId, volumeId), snapshotBackupUuid);
- return null;
- }
-
- private void restoreVolumeFromSecStorage(VmwareHypervisorHost hyperHost, DatastoreMO primaryDsMo, String newVolumeName,
- String secStorageUrl, String secStorageDir, String backupName) throws Exception {
-
- String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
- String srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/"
- + backupName + "." + ImageFormat.OVA.getFileExtension();
-
- String srcFileName = getOVFFilePath(srcOVAFileName);
- if(srcFileName == null) {
- Script command = new Script("tar", 0, s_logger);
- command.add("--no-same-owner");
- command.add("-xf", srcOVAFileName);
- command.setWorkDir(secondaryMountPoint + "/" + secStorageDir);
- s_logger.info("Executing command: " + command.toString());
- String result = command.execute();
- if(result != null) {
- String msg = "Unable to unpack snapshot OVA file at: " + srcOVAFileName;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- }
-
- srcFileName = getOVFFilePath(srcOVAFileName);
- if(srcFileName == null) {
- String msg = "Unable to locate OVF file in template package directory: " + srcOVAFileName;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- VirtualMachineMO clonedVm = null;
- try {
- hyperHost.importVmFromOVF(srcFileName, newVolumeName, primaryDsMo, "thin");
- clonedVm = hyperHost.findVmOnHyperHost(newVolumeName);
- if(clonedVm == null)
- throw new Exception("Unable to create container VM for volume creation");
-
- clonedVm.moveAllVmDiskFiles(primaryDsMo, "", false);
- clonedVm.detachAllDisks();
- } finally {
- if(clonedVm != null) {
- clonedVm.detachAllDisks();
- clonedVm.destroy();
- }
- }
- }
-
- private String backupSnapshotToSecondaryStorage(VirtualMachineMO vmMo, long accountId, long volumeId,
- String volumePath, String snapshotUuid, String secStorageUrl,
- String prevSnapshotUuid, String prevBackupUuid, String workerVmName) throws Exception {
-
- String backupUuid = UUID.randomUUID().toString();
- exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl,
- getSnapshotRelativeDirInSecStorage(accountId, volumeId), backupUuid, workerVmName);
- return backupUuid;
- }
-
- private void exportVolumeToSecondaryStroage(VirtualMachineMO vmMo, String volumePath,
- String secStorageUrl, String secStorageDir, String exportName,
- String workerVmName) throws Exception {
-
- String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
- String exportPath = secondaryMountPoint + "/" + secStorageDir;
-
- synchronized(exportPath.intern()) {
- if(!new File(exportPath).exists()) {
- Script command = new Script(false, "mkdir", _timeout, s_logger);
- command.add("-p");
- command.add(exportPath);
- if(command.execute() != null)
- throw new Exception("unable to prepare snapshot backup directory");
- }
- }
-
- VirtualMachineMO clonedVm = null;
- try {
-
- Pair<VirtualDisk, String> volumeDeviceInfo = vmMo.getDiskDevice(volumePath, false);
- if(volumeDeviceInfo == null) {
- String msg = "Unable to find related disk device for volume. volume path: " + volumePath;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- // 4 MB is the minimum requirement for VM memory in VMware
- vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(),
- VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
- clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
- if(clonedVm == null) {
- String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- clonedVm.exportVm(exportPath, exportName, true, true);
- } finally {
- if(clonedVm != null) {
- clonedVm.detachAllDisks();
- clonedVm.destroy();
- }
- }
- }
-
- private String deleteSnapshotOnSecondaryStorge(long accountId, long volumeId, String secStorageUrl, String backupUuid) throws Exception {
-
- String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
- String snapshotMountRoot = secondaryMountPoint + "/" + getSnapshotRelativeDirInSecStorage(accountId, volumeId);
- File file = new File(snapshotMountRoot + "/" + backupUuid + ".ova");
- if(file.exists()) {
- if(file.delete())
- return null;
-
- } else {
- return "Backup file does not exist. backupUuid: " + backupUuid;
- }
-
- return "Failed to delete snapshot backup file, backupUuid: " + backupUuid;
- }
-
- private Pair<String, String> copyVolumeToSecStorage(VmwareHostService hostService, VmwareHypervisorHost hyperHost, CopyVolumeCommand cmd,
- String vmName, long volumeId, String poolId, String volumePath,
- String secStorageUrl, String workerVmName) throws Exception {
-
- String volumeFolder = String.valueOf(volumeId) + "/";
- VirtualMachineMO workerVm=null;
- VirtualMachineMO vmMo=null;
- String exportName = UUID.randomUUID().toString();
-
- try {
- ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolId);
-
- if (morDs == null) {
- String msg = "Unable to find volumes's storage pool for copy volume operation";
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- vmMo = hyperHost.findVmOnHyperHost(vmName);
- if (vmMo == null) {
- // create a dummy worker vm for attaching the volume
- DatastoreMO dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
- //restrict VM name to 32 chars, (else snapshot descriptor file name will be truncated to 32 chars of vm name)
- VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
- vmConfig.setName(workerVmName);
- vmConfig.setMemoryMB((long) 4);
- vmConfig.setNumCPUs(1);
- vmConfig.setGuestId(VirtualMachineGuestOsIdentifier._otherGuest.toString());
- VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
- fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
- vmConfig.setFiles(fileInfo);
-
- // Scsi controller
- VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
- scsiController.setSharedBus(VirtualSCSISharing.noSharing);
- scsiController.setBusNumber(0);
- scsiController.setKey(1);
- VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
- scsiControllerSpec.setDevice(scsiController);
- scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
- vmConfig.setDeviceChange(new VirtualDeviceConfigSpec[] { scsiControllerSpec });
-
- hyperHost.createVm(vmConfig);
- workerVm = hyperHost.findVmOnHyperHost(workerVmName);
- if (workerVm == null) {
- String msg = "Unable to create worker VM to execute CopyVolumeCommand";
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- //attach volume to worker VM
- String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
- workerVm.attachDisk(new String[] { datastoreVolumePath }, morDs);
- vmMo = workerVm;
- }
-
- vmMo.createSnapshot(exportName, "Temporary snapshot for copy-volume command", false, false);
-
- exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, "volumes/" + volumeFolder, exportName,
- hostService.getWorkerName(hyperHost.getContext(), cmd, 1));
- return new Pair<String, String>(volumeFolder, exportName);
-
- } finally {
- vmMo.removeSnapshot(exportName, false);
- if (workerVm != null) {
- //detach volume and destroy worker vm
- workerVm.detachAllDisks();
- workerVm.destroy();
- }
- }
- }
-
- private Pair<String, String> copyVolumeFromSecStorage(VmwareHypervisorHost hyperHost, long volumeId,
- DatastoreMO dsMo, String secStorageUrl, String exportName) throws Exception {
-
- String volumeFolder = String.valueOf(volumeId) + "/";
- String newVolume = UUID.randomUUID().toString().replaceAll("-", "");
- restoreVolumeFromSecStorage(hyperHost, dsMo, newVolume, secStorageUrl, "volumes/" + volumeFolder, exportName);
-
- return new Pair<String, String>(volumeFolder, newVolume);
- }
-
- private String getOVFFilePath(String srcOVAFileName) {
- File file = new File(srcOVAFileName);
- assert(_storage != null);
- String[] files = _storage.listFiles(file.getParent());
- if(files != null) {
- for(String fileName : files) {
- if(fileName.toLowerCase().endsWith(".ovf")) {
- File ovfFile = new File(fileName);
- return file.getParent() + File.separator + ovfFile.getName();
- }
- }
- }
- return null;
- }
-
- private static String getTemplateRelativeDirInSecStorage(long accountId, long templateId) {
- return "template/tmpl/" + accountId + "/" + templateId;
- }
-
- private static String getSnapshotRelativeDirInSecStorage(long accountId, long volumeId) {
- return "snapshots/" + accountId + "/" + volumeId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageMount.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageMount.java b/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageMount.java
deleted file mode 100644
index 9f4de50..0000000
--- a/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageMount.java
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.hypervisor.vmware.manager;
-
-public interface VmwareStorageMount {
- String getMountPoint(String storageUrl);
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/core/src/com/cloud/hypervisor/vmware/resource/SshHelper.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/vmware/resource/SshHelper.java b/core/src/com/cloud/hypervisor/vmware/resource/SshHelper.java
deleted file mode 100755
index e85e9ca..0000000
--- a/core/src/com/cloud/hypervisor/vmware/resource/SshHelper.java
+++ /dev/null
@@ -1,201 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.hypervisor.vmware.resource;
-
-import java.io.File;
-import java.io.InputStream;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.utils.Pair;
-import com.trilead.ssh2.ChannelCondition;
-
-public class SshHelper {
- private static int DEFAULT_CONNECT_TIMEOUT = 60000;
- private static int DEFAULT_KEX_TIMEOUT = 60000;
-
- private static final Logger s_logger = Logger.getLogger(SshHelper.class);
-
- public static Pair<Boolean, String> sshExecute(String host, int port, String user, File pemKeyFile, String password, String command)
- throws Exception {
-
- return sshExecute(host, port, user, pemKeyFile, password, command, 60000, 60000, 120000);
- }
-
- public static void scpTo(String host, int port, String user, File pemKeyFile, String password, String remoteTargetDirectory,
- String localFile, String fileMode) throws Exception {
-
- scpTo(host, port, user, pemKeyFile, password, remoteTargetDirectory, localFile, fileMode,
- DEFAULT_CONNECT_TIMEOUT, DEFAULT_KEX_TIMEOUT);
- }
-
- public static void scpTo(String host, int port, String user, File pemKeyFile, String password, String remoteTargetDirectory,
- byte[] data, String remoteFileName, String fileMode) throws Exception {
-
- scpTo(host, port, user, pemKeyFile, password, remoteTargetDirectory, data, remoteFileName, fileMode,
- DEFAULT_CONNECT_TIMEOUT, DEFAULT_KEX_TIMEOUT);
- }
-
- public static void scpTo(String host, int port, String user, File pemKeyFile, String password, String remoteTargetDirectory,
- String localFile, String fileMode, int connectTimeoutInMs, int kexTimeoutInMs) throws Exception {
-
- com.trilead.ssh2.Connection conn = null;
- com.trilead.ssh2.SCPClient scpClient = null;
-
- try {
- conn = new com.trilead.ssh2.Connection(host, port);
- conn.connect(null, connectTimeoutInMs, kexTimeoutInMs);
-
- if(pemKeyFile == null) {
- if(!conn.authenticateWithPassword(user, password)) {
- String msg = "Failed to authentication SSH user " + user + " on host " + host;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- } else {
- if(!conn.authenticateWithPublicKey(user, pemKeyFile, password)) {
- String msg = "Failed to authentication SSH user " + user + " on host " + host;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- }
-
- scpClient = conn.createSCPClient();
-
- if(fileMode != null)
- scpClient.put(localFile, remoteTargetDirectory, fileMode);
- else
- scpClient.put(localFile, remoteTargetDirectory);
- } finally {
- if(conn != null)
- conn.close();
- }
- }
-
- public static void scpTo(String host, int port, String user, File pemKeyFile, String password, String remoteTargetDirectory,
- byte[] data, String remoteFileName, String fileMode, int connectTimeoutInMs, int kexTimeoutInMs) throws Exception {
-
- com.trilead.ssh2.Connection conn = null;
- com.trilead.ssh2.SCPClient scpClient = null;
-
- try {
- conn = new com.trilead.ssh2.Connection(host, port);
- conn.connect(null, connectTimeoutInMs, kexTimeoutInMs);
-
- if(pemKeyFile == null) {
- if(!conn.authenticateWithPassword(user, password)) {
- String msg = "Failed to authentication SSH user " + user + " on host " + host;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- } else {
- if(!conn.authenticateWithPublicKey(user, pemKeyFile, password)) {
- String msg = "Failed to authentication SSH user " + user + " on host " + host;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- }
-
- scpClient = conn.createSCPClient();
- if(fileMode != null)
- scpClient.put(data, remoteFileName, remoteTargetDirectory, fileMode);
- else
- scpClient.put(data, remoteFileName, remoteTargetDirectory);
- } finally {
- if(conn != null)
- conn.close();
- }
- }
-
- public static Pair<Boolean, String> sshExecute(String host, int port, String user, File pemKeyFile, String password, String command,
- int connectTimeoutInMs, int kexTimeoutInMs, int waitResultTimeoutInMs) throws Exception {
-
- com.trilead.ssh2.Connection conn = null;
- com.trilead.ssh2.Session sess = null;
- try {
- conn = new com.trilead.ssh2.Connection(host, port);
- conn.connect(null, connectTimeoutInMs, kexTimeoutInMs);
-
- if(pemKeyFile == null) {
- if(!conn.authenticateWithPassword(user, password)) {
- String msg = "Failed to authentication SSH user " + user + " on host " + host;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- } else {
- if(!conn.authenticateWithPublicKey(user, pemKeyFile, password)) {
- String msg = "Failed to authentication SSH user " + user + " on host " + host;
- s_logger.error(msg);
- throw new Exception(msg);
- }
- }
- sess = conn.openSession();
-
- // There is a bug in Trilead library, wait a second before
- // starting a shell and executing commands, from http://spci.st.ewi.tudelft.nl/chiron/xref/nl/tudelft/swerl/util/SSHConnection.html
- Thread.sleep(1000);
-
- sess.execCommand(command);
-
- InputStream stdout = sess.getStdout();
- InputStream stderr = sess.getStderr();
-
- byte[] buffer = new byte[8192];
- StringBuffer sbResult = new StringBuffer();
-
- int currentReadBytes = 0;
- while (true) {
- if ((stdout.available() == 0) && (stderr.available() == 0)) {
- int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA | ChannelCondition.EOF,
- waitResultTimeoutInMs);
-
- if ((conditions & ChannelCondition.TIMEOUT) != 0) {
- String msg = "Timed out in waiting SSH execution result";
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- if ((conditions & ChannelCondition.EOF) != 0) {
- if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
- break;
- }
- }
- }
-
- while (stdout.available() > 0) {
- currentReadBytes = stdout.read(buffer);
- sbResult.append(new String(buffer, 0, currentReadBytes));
- }
-
- while (stderr.available() > 0) {
- currentReadBytes = stderr.read(buffer);
- sbResult.append(new String(buffer, 0, currentReadBytes));
- }
- }
-
- String result = sbResult.toString();
- if (sess.getExitStatus() != null && sess.getExitStatus().intValue() != 0) {
- s_logger.error("SSH execution of command " + command + " has an error status code in return. result output: " + result);
- return new Pair<Boolean, String>(false, result);
- }
-
- return new Pair<Boolean, String>(true, result);
- } finally {
- if(sess != null)
- sess.close();
-
- if(conn != null)
- conn.close();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8197f1f0/core/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java b/core/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
deleted file mode 100755
index f82afb8..0000000
--- a/core/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.hypervisor.vmware.resource;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.hypervisor.vmware.manager.VmwareManager;
-import com.cloud.hypervisor.vmware.util.VmwareContext;
-import com.cloud.utils.StringUtils;
-import com.cloud.utils.component.ComponentLocator;
-import com.vmware.apputils.version.ExtendedAppUtil;
-
-public class VmwareContextFactory {
-
- private static final Logger s_logger = Logger.getLogger(VmwareContextFactory.class);
-
- private static volatile int s_seq = 1;
- private static VmwareManager s_vmwareMgr;
-
- static {
- // skip certificate check
- System.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
-
- ComponentLocator locator = ComponentLocator.getLocator("management-server");
- s_vmwareMgr = locator.getManager(VmwareManager.class);
- }
-
- public static VmwareContext create(String vCenterAddress, String vCenterUserName, String vCenterPassword) throws Exception {
- assert(vCenterAddress != null);
- assert(vCenterUserName != null);
- assert(vCenterPassword != null);
-
- String serviceUrl = "https://" + vCenterAddress + "/sdk/vimService";
- String[] params = new String[] {"--url", serviceUrl, "--username", vCenterUserName, "--password", vCenterPassword };
-
- if(s_logger.isDebugEnabled())
- s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));
-
- ExtendedAppUtil appUtil = ExtendedAppUtil.initialize(vCenterAddress + "-" + s_seq++, params);
-
- appUtil.connect();
- VmwareContext context = new VmwareContext(appUtil, vCenterAddress);
- context.registerStockObject(VmwareManager.CONTEXT_STOCK_NAME, s_vmwareMgr);
-
- context.registerStockObject("serviceconsole", s_vmwareMgr.getServiceConsolePortGroupName());
- context.registerStockObject("manageportgroup", s_vmwareMgr.getManagementPortGroupName());
-
- return context;
- }
-}