cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject [07/10] git commit: updated refs/heads/master to b155129
Date Wed, 27 May 2015 14:20:54 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpdateHostPasswordCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpdateHostPasswordCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpdateHostPasswordCommandWrapper.java
deleted file mode 100644
index 6c11a18..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpdateHostPasswordCommandWrapper.java
+++ /dev/null
@@ -1,36 +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.hypervisor.xenserver.resource.wrapper.citrix;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.UpdateHostPasswordCommand;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.resource.CommandWrapper;
-import com.cloud.resource.ResourceWrapper;
-
-@ResourceWrapper(handles =  UpdateHostPasswordCommand.class)
-public final class CitrixUpdateHostPasswordCommandWrapper extends CommandWrapper<UpdateHostPasswordCommand, Answer, CitrixResourceBase> {
-
-    @Override
-    public Answer execute(final UpdateHostPasswordCommand command, final CitrixResourceBase citrixResourceBase) {
-        citrixResourceBase.addToPwdQueue(command.getNewPassword());
-        return new Answer(command, true, null);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpgradeSnapshotCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpgradeSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpgradeSnapshotCommandWrapper.java
deleted file mode 100644
index a158938..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpgradeSnapshotCommandWrapper.java
+++ /dev/null
@@ -1,66 +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.hypervisor.xenserver.resource.wrapper.citrix;
-
-import java.net.URI;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.UpgradeSnapshotCommand;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.resource.CommandWrapper;
-import com.cloud.resource.ResourceWrapper;
-import com.xensource.xenapi.Connection;
-
-@ResourceWrapper(handles =  UpgradeSnapshotCommand.class)
-public final class CitrixUpgradeSnapshotCommandWrapper extends CommandWrapper<UpgradeSnapshotCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixUpgradeSnapshotCommandWrapper.class);
-
-    @Override
-    public Answer execute(final UpgradeSnapshotCommand command, final CitrixResourceBase citrixResourceBase) {
-        final String secondaryStorageUrl = command.getSecondaryStorageUrl();
-        final String backedUpSnapshotUuid = command.getSnapshotUuid();
-        final Long volumeId = command.getVolumeId();
-        final Long accountId = command.getAccountId();
-        final Long templateId = command.getTemplateId();
-        final Long tmpltAcountId = command.getTmpltAccountId();
-        final String version = command.getVersion();
-
-        if (!version.equals("2.1")) {
-            return new Answer(command, true, "success");
-        }
-        try {
-            final Connection conn = citrixResourceBase.getConnection();
-            final URI uri = new URI(secondaryStorageUrl);
-            final String secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath();
-            final String snapshotPath = secondaryStorageMountPath + "/snapshots/" + accountId + "/" + volumeId + "/" + backedUpSnapshotUuid + ".vhd";
-            final String templatePath = secondaryStorageMountPath + "/template/tmpl/" + tmpltAcountId + "/" + templateId;
-            citrixResourceBase.upgradeSnapshot(conn, templatePath, snapshotPath);
-            return new Answer(command, true, "success");
-        } catch (final Exception e) {
-            final String details = "upgrading snapshot " + backedUpSnapshotUuid + " failed due to " + e.toString();
-            s_logger.error(details, e);
-
-        }
-        return new Answer(command, false, "failure");
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixWatchConsoleProxyLoadCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixWatchConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixWatchConsoleProxyLoadCommandWrapper.java
deleted file mode 100644
index eb2790d..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixWatchConsoleProxyLoadCommandWrapper.java
+++ /dev/null
@@ -1,43 +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.hypervisor.xenserver.resource.wrapper.citrix;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.resource.ResourceWrapper;
-import com.cloud.resource.ServerResource;
-
-@ResourceWrapper(handles =  WatchConsoleProxyLoadCommand.class)
-public final class CitrixWatchConsoleProxyLoadCommandWrapper extends CitrixConsoleProxyLoadCommandWrapper<WatchConsoleProxyLoadCommand, Answer, CitrixResourceBase> {
-
-    @Override
-    public Answer execute(final Command command, final ServerResource serverResource) {
-        final WatchConsoleProxyLoadCommand cmd = (WatchConsoleProxyLoadCommand) command;
-
-        final long proxyVmId = cmd.getProxyVmId();
-        final String proxyVmName = cmd.getProxyVmName();
-        final String proxyManagementIp = cmd.getProxyManagementIp();
-        final int cmdPort = cmd.getProxyCmdPort();
-
-        return executeProxyLoadScan(command, proxyVmId, proxyVmName, proxyManagementIp, cmdPort);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixAttachIsoCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixAttachIsoCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixAttachIsoCommandWrapper.java
new file mode 100644
index 0000000..287096f
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixAttachIsoCommandWrapper.java
@@ -0,0 +1,136 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.AttachIsoCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.SR;
+import com.xensource.xenapi.Types;
+import com.xensource.xenapi.Types.XenAPIException;
+import com.xensource.xenapi.VBD;
+import com.xensource.xenapi.VDI;
+import com.xensource.xenapi.VM;
+
+@ResourceWrapper(handles =  AttachIsoCommand.class)
+public final class CitrixAttachIsoCommandWrapper extends CommandWrapper<AttachIsoCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixAttachIsoCommandWrapper.class);
+
+    @Override
+    public Answer execute(final AttachIsoCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        final boolean attach = command.isAttach();
+        final String vmName = command.getVmName();
+        final String isoURL = command.getIsoPath();
+
+        String errorMsg;
+        if (attach) {
+            errorMsg = "Failed to attach ISO";
+        } else {
+            errorMsg = "Failed to detach ISO";
+        }
+        try {
+            if (attach) {
+                VBD isoVBD = null;
+
+                // Find the VM
+                final VM vm = citrixResourceBase.getVM(conn, vmName);
+
+                // Find the ISO VDI
+                final VDI isoVDI = citrixResourceBase.getIsoVDIByURL(conn, vmName, isoURL);
+
+                // Find the VM's CD-ROM VBD
+                final Set<VBD> vbds = vm.getVBDs(conn);
+                for (final VBD vbd : vbds) {
+                    final String userDevice = vbd.getUserdevice(conn);
+                    final Types.VbdType type = vbd.getType(conn);
+
+                    if (userDevice.equals("3") && type == Types.VbdType.CD) {
+                        isoVBD = vbd;
+                        break;
+                    }
+                }
+
+                if (isoVBD == null) {
+                    throw new CloudRuntimeException("Unable to find CD-ROM VBD for VM: " + vmName);
+                } else {
+                    // If an ISO is already inserted, eject it
+                    if (isoVBD.getEmpty(conn) == false) {
+                        isoVBD.eject(conn);
+                    }
+
+                    // Insert the new ISO
+                    isoVBD.insert(conn, isoVDI);
+                }
+
+                return new Answer(command);
+            } else {
+                // Find the VM
+                final VM vm = citrixResourceBase.getVM(conn, vmName);
+                final String vmUUID = vm.getUuid(conn);
+
+                // Find the ISO VDI
+                final VDI isoVDI = citrixResourceBase.getIsoVDIByURL(conn, vmName, isoURL);
+
+                final SR sr = isoVDI.getSR(conn);
+
+                // Look up all VBDs for this VDI
+                final Set<VBD> vbds = isoVDI.getVBDs(conn);
+
+                // Iterate through VBDs, and if the VBD belongs the VM, eject
+                // the ISO from it
+                for (final VBD vbd : vbds) {
+                    final VM vbdVM = vbd.getVM(conn);
+                    final String vbdVmUUID = vbdVM.getUuid(conn);
+
+                    if (vbdVmUUID.equals(vmUUID)) {
+                        // If an ISO is already inserted, eject it
+                        if (!vbd.getEmpty(conn)) {
+                            vbd.eject(conn);
+                        }
+
+                        break;
+                    }
+                }
+
+                if (!sr.getNameLabel(conn).startsWith("XenServer Tools")) {
+                    citrixResourceBase.removeSR(conn, sr);
+                }
+
+                return new Answer(command);
+            }
+        } catch (final XenAPIException e) {
+            s_logger.warn(errorMsg + ": " + e.toString(), e);
+            return new Answer(command, false, e.toString());
+        } catch (final Exception e) {
+            s_logger.warn(errorMsg + ": " + e.toString(), e);
+            return new Answer(command, false, e.getMessage());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixAttachVolumeCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixAttachVolumeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixAttachVolumeCommandWrapper.java
new file mode 100644
index 0000000..436419e
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixAttachVolumeCommandWrapper.java
@@ -0,0 +1,146 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.AttachVolumeAnswer;
+import com.cloud.agent.api.AttachVolumeCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.SR;
+import com.xensource.xenapi.Types;
+import com.xensource.xenapi.Types.XenAPIException;
+import com.xensource.xenapi.VBD;
+import com.xensource.xenapi.VDI;
+import com.xensource.xenapi.VM;
+
+@ResourceWrapper(handles =  AttachVolumeCommand.class)
+public final class CitrixAttachVolumeCommandWrapper extends CommandWrapper<AttachVolumeCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixAttachVolumeCommandWrapper.class);
+
+    @Override
+    public Answer execute(final AttachVolumeCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        final boolean attach = command.getAttach();
+        final String vmName = command.getVmName();
+        final String vdiNameLabel = vmName + "-DATA";
+        final Long deviceId = command.getDeviceId();
+
+        String errorMsg;
+        if (attach) {
+            errorMsg = "Failed to attach volume";
+        } else {
+            errorMsg = "Failed to detach volume";
+        }
+
+        try {
+            VDI vdi = null;
+
+            if (command.getAttach() && command.isManaged()) {
+                final SR sr = citrixResourceBase.getIscsiSR(conn, command.get_iScsiName(), command.getStorageHost(), command.get_iScsiName(), command.getChapInitiatorUsername(),
+                        command.getChapInitiatorPassword(), true);
+
+                vdi = citrixResourceBase.getVDIbyUuid(conn, command.getVolumePath(), false);
+
+                if (vdi == null) {
+                    vdi = citrixResourceBase.createVdi(sr, vdiNameLabel, command.getVolumeSize());
+                }
+            } else {
+                vdi = citrixResourceBase.getVDIbyUuid(conn, command.getVolumePath());
+            }
+
+            // Look up the VM
+            final VM vm = citrixResourceBase.getVM(conn, vmName);
+            if (attach) {
+                // Figure out the disk number to attach the VM to
+                String diskNumber = null;
+                if (deviceId != null) {
+                    if (deviceId.longValue() == 3) {
+                        final String msg = "Device 3 is reserved for CD-ROM, choose other device";
+                        return new AttachVolumeAnswer(command, msg);
+                    }
+                    if (citrixResourceBase.isDeviceUsed(conn, vm, deviceId)) {
+                        final String msg = "Device " + deviceId + " is used in VM " + vmName;
+                        return new AttachVolumeAnswer(command, msg);
+                    }
+                    diskNumber = deviceId.toString();
+                } else {
+                    diskNumber = citrixResourceBase.getUnusedDeviceNum(conn, vm);
+                }
+                // Create a new VBD
+                final VBD.Record vbdr = new VBD.Record();
+                vbdr.VM = vm;
+                vbdr.VDI = vdi;
+                vbdr.bootable = false;
+                vbdr.userdevice = diskNumber;
+                vbdr.mode = Types.VbdMode.RW;
+                vbdr.type = Types.VbdType.DISK;
+                vbdr.unpluggable = true;
+                final VBD vbd = VBD.create(conn, vbdr);
+
+                // Attach the VBD to the VM
+                vbd.plug(conn);
+
+                // Update the VDI's label to include the VM name
+                vdi.setNameLabel(conn, vdiNameLabel);
+
+                return new AttachVolumeAnswer(command, Long.parseLong(diskNumber), vdi.getUuid(conn));
+            } else {
+                // Look up all VBDs for this VDI
+                final Set<VBD> vbds = vdi.getVBDs(conn);
+
+                // Detach each VBD from its VM, and then destroy it
+                for (final VBD vbd : vbds) {
+                    final VBD.Record vbdr = vbd.getRecord(conn);
+
+                    if (vbdr.currentlyAttached) {
+                        vbd.unplug(conn);
+                    }
+
+                    vbd.destroy(conn);
+                }
+
+                // Update the VDI's label to be "detached"
+                vdi.setNameLabel(conn, "detached");
+
+                if (command.isManaged()) {
+                    citrixResourceBase.handleSrAndVdiDetach(command.get_iScsiName(), conn);
+                }
+
+                return new AttachVolumeAnswer(command);
+            }
+        } catch (final XenAPIException e) {
+            final String msg = errorMsg + " for uuid: " + command.getVolumePath() + "  due to " + e.toString();
+            s_logger.warn(msg, e);
+            return new AttachVolumeAnswer(command, msg);
+        } catch (final Exception e) {
+            final String msg = errorMsg + " for uuid: " + command.getVolumePath() + "  due to " + e.getMessage();
+            s_logger.warn(msg, e);
+            return new AttachVolumeAnswer(command, msg);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckConsoleProxyLoadCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckConsoleProxyLoadCommandWrapper.java
new file mode 100644
index 0000000..f70cbc5
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckConsoleProxyLoadCommandWrapper.java
@@ -0,0 +1,43 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.ResourceWrapper;
+import com.cloud.resource.ServerResource;
+
+@ResourceWrapper(handles =  CheckConsoleProxyLoadCommand.class)
+public final class CitrixCheckConsoleProxyLoadCommandWrapper extends CitrixConsoleProxyLoadCommandWrapper<CheckConsoleProxyLoadCommand, Answer, CitrixResourceBase> {
+
+    @Override
+    public Answer execute(final Command command, final ServerResource serverResource) {
+        final CheckConsoleProxyLoadCommand cmd = (CheckConsoleProxyLoadCommand) command;
+
+        final long proxyVmId = cmd.getProxyVmId();
+        final String proxyVmName = cmd.getProxyVmName();
+        final String proxyManagementIp = cmd.getProxyManagementIp();
+        final int cmdPort = cmd.getProxyCmdPort();
+
+        return executeProxyLoadScan(command, proxyVmId, proxyVmName, proxyManagementIp, cmdPort);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckHealthCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckHealthCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckHealthCommandWrapper.java
new file mode 100644
index 0000000..214d345
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckHealthCommandWrapper.java
@@ -0,0 +1,37 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckHealthAnswer;
+import com.cloud.agent.api.CheckHealthCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+
+@ResourceWrapper(handles =  CheckHealthCommand.class)
+public final class CitrixCheckHealthCommandWrapper extends CommandWrapper<CheckHealthCommand, Answer, CitrixResourceBase> {
+
+    @Override
+    public Answer execute(final CheckHealthCommand command, final CitrixResourceBase citrixResourceBase) {
+        final boolean result = citrixResourceBase.pingXAPI();
+        return new CheckHealthAnswer(command, result);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckNetworkCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckNetworkCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckNetworkCommandWrapper.java
new file mode 100644
index 0000000..2fce2fe
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckNetworkCommandWrapper.java
@@ -0,0 +1,96 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckNetworkAnswer;
+import com.cloud.agent.api.CheckNetworkCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.network.PhysicalNetworkSetupInfo;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.xensource.xenapi.Types.XenAPIException;
+
+@ResourceWrapper(handles =  CheckNetworkCommand.class)
+public final class CitrixCheckNetworkCommandWrapper extends CommandWrapper<CheckNetworkCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixCheckNetworkCommandWrapper.class);
+
+    @Override
+    public Answer execute(final CheckNetworkCommand command, final CitrixResourceBase citrixResourceBase) {
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Checking if network name setup is done on the resource");
+        }
+
+        final List<PhysicalNetworkSetupInfo> infoList = command.getPhysicalNetworkInfoList();
+
+        try {
+            boolean errorout = false;
+            String msg = "";
+            for (final PhysicalNetworkSetupInfo info : infoList) {
+                if (!citrixResourceBase.isNetworkSetupByName(info.getGuestNetworkName())) {
+                    msg =
+                            "For Physical Network id:" + info.getPhysicalNetworkId() + ", Guest Network is not configured on the backend by name " +
+                                    info.getGuestNetworkName();
+                    errorout = true;
+                    break;
+                }
+                if (!citrixResourceBase.isNetworkSetupByName(info.getPrivateNetworkName())) {
+                    msg =
+                            "For Physical Network id:" + info.getPhysicalNetworkId() + ", Private Network is not configured on the backend by name " +
+                                    info.getPrivateNetworkName();
+                    errorout = true;
+                    break;
+                }
+                if (!citrixResourceBase.isNetworkSetupByName(info.getPublicNetworkName())) {
+                    msg =
+                            "For Physical Network id:" + info.getPhysicalNetworkId() + ", Public Network is not configured on the backend by name " +
+                                    info.getPublicNetworkName();
+                    errorout = true;
+                    break;
+                }
+                /*if(!isNetworkSetupByName(info.getStorageNetworkName())){
+                    msg = "For Physical Network id:"+ info.getPhysicalNetworkId() + ", Storage Network is not configured on the backend by name " + info.getStorageNetworkName();
+                    errorout = true;
+                    break;
+                }*/
+            }
+            if (errorout) {
+                s_logger.error(msg);
+                return new CheckNetworkAnswer(command, false, msg);
+            } else {
+                return new CheckNetworkAnswer(command, true, "Network Setup check by names is done");
+            }
+
+        } catch (final XenAPIException e) {
+            final String msg = "CheckNetworkCommand failed with XenAPIException:" + e.toString() + " host:" + citrixResourceBase.getHost().getUuid();
+            s_logger.warn(msg, e);
+            return new CheckNetworkAnswer(command, false, msg);
+        } catch (final Exception e) {
+            final String msg = "CheckNetworkCommand failed with Exception:" + e.getMessage() + " host:" + citrixResourceBase.getHost().getUuid();
+            s_logger.warn(msg, e);
+            return new CheckNetworkAnswer(command, false, msg);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckOnHostCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckOnHostCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckOnHostCommandWrapper.java
new file mode 100644
index 0000000..d9372bb
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckOnHostCommandWrapper.java
@@ -0,0 +1,36 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckOnHostAnswer;
+import com.cloud.agent.api.CheckOnHostCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+
+@ResourceWrapper(handles =  CheckOnHostCommand.class)
+public final class CitrixCheckOnHostCommandWrapper extends CommandWrapper<CheckOnHostCommand, Answer, CitrixResourceBase> {
+
+    @Override
+    public Answer execute(final CheckOnHostCommand command, final CitrixResourceBase citrixResourceBase) {
+        return new CheckOnHostAnswer(command, "Not Implmeneted");
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckSshCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckSshCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckSshCommandWrapper.java
new file mode 100644
index 0000000..cf34a8f
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckSshCommandWrapper.java
@@ -0,0 +1,65 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.check.CheckSshAnswer;
+import com.cloud.agent.api.check.CheckSshCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.xensource.xenapi.Connection;
+
+@ResourceWrapper(handles =  CheckSshCommand.class)
+public final class CitrixCheckSshCommandWrapper extends CommandWrapper<CheckSshCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixCheckSshCommandWrapper.class);
+
+    @Override
+    public Answer execute(final CheckSshCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        final String vmName = command.getName();
+        final String privateIp = command.getIp();
+        final int cmdPort = command.getPort();
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Ping command port, " + privateIp + ":" + cmdPort);
+        }
+
+        try {
+            final String result = citrixResourceBase.connect(conn, command.getName(), privateIp, cmdPort);
+            if (result != null) {
+                return new CheckSshAnswer(command, "Can not ping System vm " + vmName + "due to:" + result);
+            }
+            //Do not destroy the disk here! It will stio the patching process. Please, don't!
+            //destroyPatchVbd(conn, vmName);
+        } catch (final Exception e) {
+            return new CheckSshAnswer(command, e);
+        }
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Ping command port succeeded for vm " + vmName);
+        }
+
+        return new CheckSshAnswer(command);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckVirtualMachineCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckVirtualMachineCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckVirtualMachineCommandWrapper.java
new file mode 100644
index 0000000..04a5606
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckVirtualMachineCommandWrapper.java
@@ -0,0 +1,50 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckVirtualMachineAnswer;
+import com.cloud.agent.api.CheckVirtualMachineCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.cloud.vm.VirtualMachine.PowerState;
+import com.xensource.xenapi.Connection;
+
+@ResourceWrapper(handles =  CheckVirtualMachineCommand.class)
+public final class CitrixCheckVirtualMachineCommandWrapper extends CommandWrapper<CheckVirtualMachineCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixCheckVirtualMachineCommandWrapper.class);
+
+    @Override
+    public Answer execute(final CheckVirtualMachineCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        final String vmName = command.getVmName();
+        final PowerState powerState = citrixResourceBase.getVmState(conn, vmName);
+        final Integer vncPort = null;
+        if (powerState == PowerState.PowerOn) {
+            s_logger.debug("3. The VM " + vmName + " is in Running state");
+        }
+
+        return new CheckVirtualMachineAnswer(command, powerState, vncPort);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCleanupNetworkRulesCmdWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCleanupNetworkRulesCmdWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCleanupNetworkRulesCmdWrapper.java
new file mode 100644
index 0000000..32f8cf1
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCleanupNetworkRulesCmdWrapper.java
@@ -0,0 +1,56 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CleanupNetworkRulesCmd;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.xensource.xenapi.Connection;
+
+@ResourceWrapper(handles =  CleanupNetworkRulesCmd.class)
+public final class CitrixCleanupNetworkRulesCmdWrapper extends CommandWrapper<CleanupNetworkRulesCmd, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixCleanupNetworkRulesCmdWrapper.class);
+
+    @Override
+    public Answer execute(final CleanupNetworkRulesCmd command, final CitrixResourceBase citrixResourceBase) {
+        if (!citrixResourceBase.canBridgeFirewall()) {
+            return new Answer(command, true, null);
+        }
+        final Connection conn = citrixResourceBase.getConnection();
+
+        final String result = citrixResourceBase.callHostPlugin(conn, "vmops", "cleanup_rules", "instance", citrixResourceBase.getVMInstanceName());
+        final int numCleaned = Integer.parseInt(result);
+
+        if (result == null || result.isEmpty() || numCleaned < 0) {
+            s_logger.warn("Failed to cleanup rules for host " + citrixResourceBase.getHost().getIp());
+            return new Answer(command, false, result);
+        }
+
+        if (numCleaned > 0) {
+            s_logger.info("Cleaned up rules for " + result + " vms on host " + citrixResourceBase.getHost().getIp());
+        }
+        return new Answer(command, true, result);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixClusterVMMetaDataSyncCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixClusterVMMetaDataSyncCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixClusterVMMetaDataSyncCommandWrapper.java
new file mode 100644
index 0000000..05f6eb6
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixClusterVMMetaDataSyncCommandWrapper.java
@@ -0,0 +1,59 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.ClusterVMMetaDataSyncAnswer;
+import com.cloud.agent.api.ClusterVMMetaDataSyncCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.Host;
+import com.xensource.xenapi.Pool;
+
+@ResourceWrapper(handles =  ClusterVMMetaDataSyncCommand.class)
+public final class CitrixClusterVMMetaDataSyncCommandWrapper extends CommandWrapper<ClusterVMMetaDataSyncCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixClusterVMMetaDataSyncCommandWrapper.class);
+
+    @Override
+    public Answer execute(final ClusterVMMetaDataSyncCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        //check if this is master
+        try {
+            final Pool pool = Pool.getByUuid(conn, citrixResourceBase.getHost().getPool());
+            final Pool.Record poolr = pool.getRecord(conn);
+            final Host.Record hostr = poolr.master.getRecord(conn);
+            if (!citrixResourceBase.getHost().getUuid().equals(hostr.uuid)) {
+                return new ClusterVMMetaDataSyncAnswer(command.getClusterId(), null);
+            }
+        } catch (final Throwable e) {
+            s_logger.warn("Check for master failed, failing the Cluster sync VMMetaData command");
+            return new ClusterVMMetaDataSyncAnswer(command.getClusterId(), null);
+        }
+        final HashMap<String, String> vmMetadatum = citrixResourceBase.clusterVMMetaDataSync(conn);
+        return new ClusterVMMetaDataSyncAnswer(command.getClusterId(), vmMetadatum);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixConsoleProxyLoadCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixConsoleProxyLoadCommandWrapper.java
new file mode 100644
index 0000000..4b863a2
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixConsoleProxyLoadCommandWrapper.java
@@ -0,0 +1,83 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.charset.Charset;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ServerResource;
+
+public abstract class CitrixConsoleProxyLoadCommandWrapper<T extends Command, A extends Answer, R extends ServerResource> extends CommandWrapper<Command, Answer, ServerResource> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixConsoleProxyLoadCommandWrapper.class);
+
+    protected Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, final String proxyVmName, final String proxyManagementIp, final int cmdPort) {
+        String result = null;
+
+        final StringBuffer sb = new StringBuffer();
+        sb.append("http://").append(proxyManagementIp).append(":" + cmdPort).append("/cmd/getstatus");
+
+        boolean success = true;
+        try {
+            final URL url = new URL(sb.toString());
+            final URLConnection conn = url.openConnection();
+
+            // setting TIMEOUTs to avoid possible waiting until death situations
+            conn.setConnectTimeout(5000);
+            conn.setReadTimeout(5000);
+
+            final InputStream is = conn.getInputStream();
+            final BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.defaultCharset()));
+            final StringBuilder sb2 = new StringBuilder();
+            String line = null;
+            try {
+                while ((line = reader.readLine()) != null) {
+                    sb2.append(line + "\n");
+                }
+                result = sb2.toString();
+            } catch (final IOException e) {
+                success = false;
+            } finally {
+                try {
+                    is.close();
+                } catch (final IOException e) {
+                    s_logger.warn("Exception when closing , console proxy address : " + proxyManagementIp);
+                    success = false;
+                }
+            }
+        } catch (final IOException e) {
+            s_logger.warn("Unable to open console proxy command port url, console proxy address : " + proxyManagementIp);
+            success = false;
+        }
+
+        return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateCommandWrapper.java
new file mode 100644
index 0000000..38150ce
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateCommandWrapper.java
@@ -0,0 +1,84 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.storage.CreateAnswer;
+import com.cloud.agent.api.storage.CreateCommand;
+import com.cloud.agent.api.to.StorageFilerTO;
+import com.cloud.agent.api.to.VolumeTO;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.cloud.vm.DiskProfile;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.SR;
+import com.xensource.xenapi.Types;
+import com.xensource.xenapi.VDI;
+
+@ResourceWrapper(handles =  CreateCommand.class)
+public final class CitrixCreateCommandWrapper extends CommandWrapper<CreateCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixCreateCommandWrapper.class);
+
+    @Override
+    public Answer execute(final CreateCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        final StorageFilerTO pool = command.getPool();
+        final DiskProfile dskch = command.getDiskCharacteristics();
+
+        VDI vdi = null;
+        try {
+            final SR poolSr = citrixResourceBase.getStorageRepository(conn, pool.getUuid());
+            if (command.getTemplateUrl() != null) {
+                VDI tmpltvdi = null;
+
+                tmpltvdi = citrixResourceBase.getVDIbyUuid(conn, command.getTemplateUrl());
+                vdi = tmpltvdi.createClone(conn, new HashMap<String, String>());
+                vdi.setNameLabel(conn, dskch.getName());
+            } else {
+                final VDI.Record vdir = new VDI.Record();
+                vdir.nameLabel = dskch.getName();
+                vdir.SR = poolSr;
+                vdir.type = Types.VdiType.USER;
+
+                vdir.virtualSize = dskch.getSize();
+                vdi = VDI.create(conn, vdir);
+            }
+
+            VDI.Record vdir;
+            vdir = vdi.getRecord(conn);
+
+            s_logger.debug("Succesfully created VDI for " + command + ".  Uuid = " + vdir.uuid);
+
+            final VolumeTO vol =
+                    new VolumeTO(command.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(), vdir.nameLabel, pool.getPath(), vdir.uuid, vdir.virtualSize, null);
+
+            return new CreateAnswer(command, vol);
+        } catch (final Exception e) {
+            s_logger.warn("Unable to create volume; Pool=" + pool + "; Disk: " + dskch, e);
+            return new CreateAnswer(command, e);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateStoragePoolCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateStoragePoolCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateStoragePoolCommandWrapper.java
new file mode 100644
index 0000000..bed417f
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateStoragePoolCommandWrapper.java
@@ -0,0 +1,59 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CreateStoragePoolCommand;
+import com.cloud.agent.api.to.StorageFilerTO;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.xensource.xenapi.Connection;
+
+@ResourceWrapper(handles =  CreateStoragePoolCommand.class)
+public final class CitrixCreateStoragePoolCommandWrapper extends CommandWrapper<CreateStoragePoolCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixCreateStoragePoolCommandWrapper.class);
+
+    @Override
+    public Answer execute(final CreateStoragePoolCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        final StorageFilerTO pool = command.getPool();
+        try {
+            if (pool.getType() == StoragePoolType.NetworkFilesystem) {
+                citrixResourceBase.getNfsSR(conn, Long.toString(pool.getId()), pool.getUuid(), pool.getHost(), pool.getPath(), pool.toString());
+            } else if (pool.getType() == StoragePoolType.IscsiLUN) {
+                citrixResourceBase.getIscsiSR(conn, pool.getUuid(), pool.getHost(), pool.getPath(), null, null, false);
+            } else if (pool.getType() == StoragePoolType.PreSetup) {
+            } else {
+                return new Answer(command, false, "The pool type: " + pool.getType().name() + " is not supported.");
+            }
+            return new Answer(command, true, "success");
+        } catch (final Exception e) {
+            final String msg = "Catch Exception " + e.getClass().getName() + ", create StoragePool failed due to " + e.toString() + " on host:"
+                    + citrixResourceBase.getHost().getUuid() + " pool: " + pool.getHost() + pool.getPath();
+            s_logger.warn(msg, e);
+            return new Answer(command, false, msg);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateVMSnapshotCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateVMSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateVMSnapshotCommandWrapper.java
new file mode 100644
index 0000000..4550cf8
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateVMSnapshotCommandWrapper.java
@@ -0,0 +1,190 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.cloudstack.storage.to.VolumeObjectTO;
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CreateVMSnapshotAnswer;
+import com.cloud.agent.api.CreateVMSnapshotCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.cloud.vm.snapshot.VMSnapshot;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.Pool;
+import com.xensource.xenapi.SR;
+import com.xensource.xenapi.Task;
+import com.xensource.xenapi.Types;
+import com.xensource.xenapi.Types.VmPowerState;
+import com.xensource.xenapi.VBD;
+import com.xensource.xenapi.VDI;
+import com.xensource.xenapi.VM;
+
+@ResourceWrapper(handles =  CreateVMSnapshotCommand.class)
+public final class CitrixCreateVMSnapshotCommandWrapper extends CommandWrapper<CreateVMSnapshotCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixCreateVMSnapshotCommandWrapper.class);
+
+    @Override
+    public Answer execute(final CreateVMSnapshotCommand command, final CitrixResourceBase citrixResourceBase) {
+        final String vmName = command.getVmName();
+        final String vmSnapshotName = command.getTarget().getSnapshotName();
+        final List<VolumeObjectTO> listVolumeTo = command.getVolumeTOs();
+
+        VmPowerState vmState = VmPowerState.HALTED;
+
+        final String guestOSType = command.getGuestOSType();
+        final String platformEmulator = command.getPlatformEmulator();
+
+        final boolean snapshotMemory = command.getTarget().getType() == VMSnapshot.Type.DiskAndMemory;
+        final long timeout = command.getWait();
+
+        final Connection conn = citrixResourceBase.getConnection();
+        VM vm = null;
+        VM vmSnapshot = null;
+        boolean success = false;
+
+        try {
+            // check if VM snapshot already exists
+            final Set<VM> vmSnapshots = VM.getByNameLabel(conn, command.getTarget().getSnapshotName());
+            if (vmSnapshots == null || vmSnapshots.size() > 0) {
+                return new CreateVMSnapshotAnswer(command, command.getTarget(), command.getVolumeTOs());
+            }
+
+            // check if there is already a task for this VM snapshot
+            Task task = null;
+            Set<Task> tasks = Task.getByNameLabel(conn, "Async.VM.snapshot");
+            if(tasks == null) {
+                tasks = new LinkedHashSet<>();
+            }
+            final Set<Task> tasksByName = Task.getByNameLabel(conn, "Async.VM.checkpoint");
+            if(tasksByName != null) {
+                tasks.addAll(tasksByName);
+            }
+            for (final Task taskItem : tasks) {
+                if (taskItem.getOtherConfig(conn).containsKey("CS_VM_SNAPSHOT_KEY")) {
+                    final String vmSnapshotTaskName = taskItem.getOtherConfig(conn).get("CS_VM_SNAPSHOT_KEY");
+                    if (vmSnapshotTaskName != null && vmSnapshotTaskName.equals(command.getTarget().getSnapshotName())) {
+                        task = taskItem;
+                    }
+                }
+            }
+
+            // create a new task if there is no existing task for this VM snapshot
+            if (task == null) {
+                try {
+                    vm = citrixResourceBase.getVM(conn, vmName);
+                    vmState = vm.getPowerState(conn);
+                } catch (final Exception e) {
+                    if (!snapshotMemory) {
+                        vm = citrixResourceBase.createWorkingVM(conn, vmName, guestOSType, platformEmulator, listVolumeTo);
+                    }
+                }
+
+                if (vm == null) {
+                    return new CreateVMSnapshotAnswer(command, false, "Creating VM Snapshot Failed due to can not find vm: " + vmName);
+                }
+
+                // call Xenserver API
+                if (!snapshotMemory) {
+                    task = vm.snapshotAsync(conn, vmSnapshotName);
+                } else {
+                    final Set<VBD> vbds = vm.getVBDs(conn);
+                    final Pool pool = Pool.getByUuid(conn, citrixResourceBase.getHost().getPool());
+                    for (final VBD vbd : vbds) {
+                        final VBD.Record vbdr = vbd.getRecord(conn);
+                        if (vbdr.userdevice.equals("0")) {
+                            final VDI vdi = vbdr.VDI;
+                            final SR sr = vdi.getSR(conn);
+                            // store memory image on the same SR with ROOT volume
+                            pool.setSuspendImageSR(conn, sr);
+                        }
+                    }
+                    task = vm.checkpointAsync(conn, vmSnapshotName);
+                }
+                task.addToOtherConfig(conn, "CS_VM_SNAPSHOT_KEY", vmSnapshotName);
+            }
+
+            citrixResourceBase.waitForTask(conn, task, 1000, timeout * 1000);
+            citrixResourceBase.checkForSuccess(conn, task);
+            final String result = task.getResult(conn);
+
+            // extract VM snapshot ref from result
+            final String ref = result.substring("<value>".length(), result.length() - "</value>".length());
+            vmSnapshot = Types.toVM(ref);
+            try {
+                Thread.sleep(5000);
+            } catch (final InterruptedException ex) {
+
+            }
+            // calculate used capacity for this VM snapshot
+            for (final VolumeObjectTO volumeTo : command.getVolumeTOs()) {
+                final long size = citrixResourceBase.getVMSnapshotChainSize(conn, volumeTo, command.getVmName());
+                volumeTo.setSize(size);
+            }
+
+            success = true;
+            return new CreateVMSnapshotAnswer(command, command.getTarget(), command.getVolumeTOs());
+        } catch (final Exception e) {
+            String msg = "";
+            if (e instanceof Types.BadAsyncResult) {
+                final String licenseKeyWord = "LICENCE_RESTRICTION";
+                final Types.BadAsyncResult errorResult = (Types.BadAsyncResult)e;
+                if (errorResult.shortDescription != null && errorResult.shortDescription.contains(licenseKeyWord)) {
+                    msg = licenseKeyWord;
+                }
+            } else {
+                msg = e.toString();
+            }
+            s_logger.warn("Creating VM Snapshot " + command.getTarget().getSnapshotName() + " failed due to: " + msg, e);
+            return new CreateVMSnapshotAnswer(command, false, msg);
+        } finally {
+            try {
+                if (!success) {
+                    if (vmSnapshot != null) {
+                        s_logger.debug("Delete exsisting VM Snapshot " + vmSnapshotName + " after making VolumeTO failed");
+                        final Set<VBD> vbds = vmSnapshot.getVBDs(conn);
+                        for (final VBD vbd : vbds) {
+                            final VBD.Record vbdr = vbd.getRecord(conn);
+                            if (vbdr.type == Types.VbdType.DISK) {
+                                final VDI vdi = vbdr.VDI;
+                                vdi.destroy(conn);
+                            }
+                        }
+                        vmSnapshot.destroy(conn);
+                    }
+                }
+                if (vmState == VmPowerState.HALTED) {
+                    if (vm != null) {
+                        vm.destroy(conn);
+                    }
+                }
+            } catch (final Exception e2) {
+                s_logger.error("delete snapshot error due to " + e2.getMessage());
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDeleteStoragePoolCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDeleteStoragePoolCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDeleteStoragePoolCommandWrapper.java
new file mode 100644
index 0000000..a9ae680
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDeleteStoragePoolCommandWrapper.java
@@ -0,0 +1,54 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.DeleteStoragePoolCommand;
+import com.cloud.agent.api.to.StorageFilerTO;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.SR;
+
+@ResourceWrapper(handles =  DeleteStoragePoolCommand.class)
+public final class CitrixDeleteStoragePoolCommandWrapper extends CommandWrapper<DeleteStoragePoolCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixDeleteStoragePoolCommandWrapper.class);
+
+    @Override
+    public Answer execute(final DeleteStoragePoolCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        final StorageFilerTO poolTO = command.getPool();
+        try {
+            final SR sr = citrixResourceBase.getStorageRepository(conn, poolTO.getUuid());
+            citrixResourceBase.removeSR(conn, sr);
+            final Answer answer = new Answer(command, true, "success");
+            return answer;
+        } catch (final Exception e) {
+            final String msg = "DeleteStoragePoolCommand XenAPIException:" + e.getMessage() + " host:" + citrixResourceBase.getHost().getUuid() + " pool: " + poolTO.getHost()
+                    + poolTO.getPath();
+            s_logger.warn(msg, e);
+            return new Answer(command, false, msg);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDeleteVMSnapshotCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDeleteVMSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDeleteVMSnapshotCommandWrapper.java
new file mode 100644
index 0000000..a341c76
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDeleteVMSnapshotCommandWrapper.java
@@ -0,0 +1,92 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.cloudstack.storage.to.VolumeObjectTO;
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.DeleteVMSnapshotAnswer;
+import com.cloud.agent.api.DeleteVMSnapshotCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.cloud.vm.snapshot.VMSnapshot;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.Types;
+import com.xensource.xenapi.VBD;
+import com.xensource.xenapi.VDI;
+import com.xensource.xenapi.VM;
+
+@ResourceWrapper(handles =  DeleteVMSnapshotCommand.class)
+public final class CitrixDeleteVMSnapshotCommandWrapper extends CommandWrapper<DeleteVMSnapshotCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixDeleteVMSnapshotCommandWrapper.class);
+
+    @Override
+    public Answer execute(final DeleteVMSnapshotCommand command, final CitrixResourceBase citrixResourceBase) {
+        final String snapshotName = command.getTarget().getSnapshotName();
+        final Connection conn = citrixResourceBase.getConnection();
+
+        try {
+            final List<VDI> vdiList = new ArrayList<VDI>();
+            final Set<VM> snapshots = VM.getByNameLabel(conn, snapshotName);
+            if (snapshots == null || snapshots.size() == 0) {
+                s_logger.warn("VM snapshot with name " + snapshotName + " does not exist, assume it is already deleted");
+                return new DeleteVMSnapshotAnswer(command, command.getVolumeTOs());
+            }
+            final VM snapshot = snapshots.iterator().next();
+            final Set<VBD> vbds = snapshot.getVBDs(conn);
+            for (final VBD vbd : vbds) {
+                if (vbd.getType(conn) == Types.VbdType.DISK) {
+                    final VDI vdi = vbd.getVDI(conn);
+                    vdiList.add(vdi);
+                }
+            }
+            if (command.getTarget().getType() == VMSnapshot.Type.DiskAndMemory) {
+                vdiList.add(snapshot.getSuspendVDI(conn));
+            }
+            snapshot.destroy(conn);
+            for (final VDI vdi : vdiList) {
+                vdi.destroy(conn);
+            }
+
+            try {
+                Thread.sleep(5000);
+            } catch (final InterruptedException ex) {
+
+            }
+            // re-calculate used capacify for this VM snapshot
+            for (final VolumeObjectTO volumeTo : command.getVolumeTOs()) {
+                final long size = citrixResourceBase.getVMSnapshotChainSize(conn, volumeTo, command.getVmName());
+                volumeTo.setSize(size);
+            }
+
+            return new DeleteVMSnapshotAnswer(command, command.getVolumeTOs());
+        } catch (final Exception e) {
+            s_logger.warn("Catch Exception: " + e.getClass().toString() + " due to " + e.toString(), e);
+            return new DeleteVMSnapshotAnswer(command, false, e.getMessage());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDestroyCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDestroyCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDestroyCommandWrapper.java
new file mode 100644
index 0000000..c542744
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDestroyCommandWrapper.java
@@ -0,0 +1,85 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.storage.DestroyCommand;
+import com.cloud.agent.api.to.VolumeTO;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.VBD;
+import com.xensource.xenapi.VDI;
+
+@ResourceWrapper(handles =  DestroyCommand.class)
+public final class CitrixDestroyCommandWrapper extends CommandWrapper<DestroyCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixDestroyCommandWrapper.class);
+
+    @Override
+    public Answer execute(final DestroyCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        final VolumeTO vol = command.getVolume();
+        // Look up the VDI
+        final String volumeUUID = vol.getPath();
+        VDI vdi = null;
+        try {
+            vdi = citrixResourceBase.getVDIbyUuid(conn, volumeUUID);
+        } catch (final Exception e) {
+            return new Answer(command, true, "Success");
+        }
+        Set<VBD> vbds = null;
+        try {
+            vbds = vdi.getVBDs(conn);
+        } catch (final Exception e) {
+            final String msg = "VDI getVBDS for " + volumeUUID + " failed due to " + e.toString();
+            s_logger.warn(msg, e);
+            return new Answer(command, false, msg);
+        }
+        for (final VBD vbd : vbds) {
+            try {
+                vbd.unplug(conn);
+                vbd.destroy(conn);
+            } catch (final Exception e) {
+                final String msg = "VM destroy for " + volumeUUID + "  failed due to " + e.toString();
+                s_logger.warn(msg, e);
+                return new Answer(command, false, msg);
+            }
+        }
+        try {
+            final Set<VDI> snapshots = vdi.getSnapshots(conn);
+            for (final VDI snapshot : snapshots) {
+                snapshot.destroy(conn);
+            }
+            vdi.destroy(conn);
+        } catch (final Exception e) {
+            final String msg = "VDI destroy for " + volumeUUID + " failed due to " + e.toString();
+            s_logger.warn(msg, e);
+            return new Answer(command, false, msg);
+        }
+
+        return new Answer(command, true, "Success");
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixGetHostStatsCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixGetHostStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixGetHostStatsCommandWrapper.java
new file mode 100644
index 0000000..78a06a0
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixGetHostStatsCommandWrapper.java
@@ -0,0 +1,50 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.GetHostStatsAnswer;
+import com.cloud.agent.api.GetHostStatsCommand;
+import com.cloud.agent.api.HostStatsEntry;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.xensource.xenapi.Connection;
+
+@ResourceWrapper(handles =  GetHostStatsCommand.class)
+public final class CitrixGetHostStatsCommandWrapper extends CommandWrapper<GetHostStatsCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixGetHostStatsCommandWrapper.class);
+
+    @Override
+    public Answer execute(final GetHostStatsCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        try {
+            final HostStatsEntry hostStats = citrixResourceBase.getHostStats(conn, command, command.getHostGuid(), command.getHostId());
+            return new GetHostStatsAnswer(command, hostStats);
+        } catch (final Exception e) {
+            final String msg = "Unable to get Host stats" + e.toString();
+            s_logger.warn(msg, e);
+            return new GetHostStatsAnswer(command, null);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b155129a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixGetStorageStatsCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixGetStorageStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixGetStorageStatsCommandWrapper.java
new file mode 100644
index 0000000..016cce4
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixGetStorageStatsCommandWrapper.java
@@ -0,0 +1,71 @@
+//
+// 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.xenserver.resource.wrapper.xenbase;
+
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.apache.xmlrpc.XmlRpcException;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.GetStorageStatsAnswer;
+import com.cloud.agent.api.GetStorageStatsCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.SR;
+import com.xensource.xenapi.Types.XenAPIException;
+
+@ResourceWrapper(handles =  GetStorageStatsCommand.class)
+public final class CitrixGetStorageStatsCommandWrapper extends CommandWrapper<GetStorageStatsCommand, Answer, CitrixResourceBase> {
+
+    private static final Logger s_logger = Logger.getLogger(CitrixGetStorageStatsCommandWrapper.class);
+
+    @Override
+    public Answer execute(final GetStorageStatsCommand command, final CitrixResourceBase citrixResourceBase) {
+        final Connection conn = citrixResourceBase.getConnection();
+        try {
+            final Set<SR> srs = SR.getByNameLabel(conn, command.getStorageId());
+            if (srs.size() != 1) {
+                final String msg = "There are " + srs.size() + " storageid: " + command.getStorageId();
+                s_logger.warn(msg);
+                return new GetStorageStatsAnswer(command, msg);
+            }
+            final SR sr = srs.iterator().next();
+            sr.scan(conn);
+            final long capacity = sr.getPhysicalSize(conn);
+            final long used = sr.getPhysicalUtilisation(conn);
+            return new GetStorageStatsAnswer(command, capacity, used);
+        } catch (final XenAPIException e) {
+            final String msg = "GetStorageStats Exception:" + e.toString() + "host:" + citrixResourceBase.getHost().getUuid() + "storageid: " + command.getStorageId();
+            s_logger.warn(msg);
+            return new GetStorageStatsAnswer(command, msg);
+        } catch (final XmlRpcException e) {
+            final String msg = "GetStorageStats Exception:" + e.getMessage() + "host:" + citrixResourceBase.getHost().getUuid() + "storageid: " + command.getStorageId();
+            s_logger.warn(msg);
+            return new GetStorageStatsAnswer(command, msg);
+        }  catch (final Exception e) {
+            final String msg = "GetStorageStats Exception:" + e.getMessage() + "host:" + citrixResourceBase.getHost().getUuid() + "storageid: " + command.getStorageId();
+            s_logger.warn(msg);
+            return new GetStorageStatsAnswer(command, msg);
+        }
+    }
+}
\ No newline at end of file


Mime
View raw message