cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject [5/9] git commit: updated refs/heads/master to d785479
Date Sat, 23 May 2015 15:27:55 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java
deleted file mode 100644
index fde2155..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java
+++ /dev/null
@@ -1,63 +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;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.PrepareForMigrationAnswer;
-import com.cloud.agent.api.PrepareForMigrationCommand;
-import com.cloud.agent.api.to.NicTO;
-import com.cloud.agent.api.to.VirtualMachineTO;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.resource.CommandWrapper;
-import com.cloud.resource.ResourceWrapper;
-import com.xensource.xenapi.Connection;
-
-@ResourceWrapper(handles =  PrepareForMigrationCommand.class)
-public final class CitrixPrepareForMigrationCommandWrapper extends CommandWrapper<PrepareForMigrationCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixPrepareForMigrationCommandWrapper.class);
-
-    @Override
-    public Answer execute(final PrepareForMigrationCommand command, final CitrixResourceBase citrixResourceBase) {
-        final Connection conn = citrixResourceBase.getConnection();
-
-        final VirtualMachineTO vm = command.getVirtualMachine();
-        if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Preparing host for migrating " + vm);
-        }
-
-        final NicTO[] nics = vm.getNics();
-        try {
-            citrixResourceBase.prepareISO(conn, vm.getName());
-
-            for (final NicTO nic : nics) {
-                citrixResourceBase.getNetwork(conn, nic);
-            }
-            s_logger.debug("4. The VM " + vm.getName() + " is in Migrating state");
-
-            return new PrepareForMigrationAnswer(command);
-        } catch (final Exception e) {
-            s_logger.warn("Catch Exception " + e.getClass().getName() + " prepare for migration failed due to " + e.toString(), e);
-            return new PrepareForMigrationAnswer(command, e);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java
deleted file mode 100644
index 22eca93..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java
+++ /dev/null
@@ -1,85 +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;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
-import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
-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.VDI;
-
-@ResourceWrapper(handles =  PrimaryStorageDownloadCommand.class)
-public final class CitrixPrimaryStorageDownloadCommandWrapper extends CommandWrapper<PrimaryStorageDownloadCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixPrimaryStorageDownloadCommandWrapper.class);
-
-    @Override
-    public Answer execute(final PrimaryStorageDownloadCommand command, final CitrixResourceBase citrixResourceBase) {
-        final String tmplturl = command.getUrl();
-        final String poolName = command.getPoolUuid();
-        final int wait = command.getWait();
-        try {
-            final URI uri = new URI(tmplturl);
-            final String tmplpath = uri.getHost() + ":" + uri.getPath();
-            final Connection conn = citrixResourceBase.getConnection();
-            SR poolsr = null;
-            final Set<SR> srs = SR.getByNameLabel(conn, poolName);
-            if (srs.size() != 1) {
-                final String msg = "There are " + srs.size() + " SRs with same name: " + poolName;
-                s_logger.warn(msg);
-                return new PrimaryStorageDownloadAnswer(msg);
-            } else {
-                poolsr = srs.iterator().next();
-            }
-            final String pUuid = poolsr.getUuid(conn);
-            final boolean isISCSI = citrixResourceBase.IsISCSI(poolsr.getType(conn));
-            final String uuid = citrixResourceBase.copyVhdFromSecondaryStorage(conn, tmplpath, pUuid, wait);
-            final VDI tmpl = citrixResourceBase.getVDIbyUuid(conn, uuid);
-            final VDI snapshotvdi = tmpl.snapshot(conn, new HashMap<String, String>());
-            final String snapshotUuid = snapshotvdi.getUuid(conn);
-            snapshotvdi.setNameLabel(conn, "Template " + command.getName());
-            final String parentuuid = citrixResourceBase.getVhdParent(conn, pUuid, snapshotUuid, isISCSI);
-            final VDI parent = citrixResourceBase.getVDIbyUuid(conn, parentuuid);
-            final Long phySize = parent.getPhysicalUtilisation(conn);
-            tmpl.destroy(conn);
-            poolsr.scan(conn);
-            try {
-                Thread.sleep(5000);
-            } catch (final Exception e) {
-            }
-            return new PrimaryStorageDownloadAnswer(snapshotvdi.getUuid(conn), phySize);
-        } catch (final Exception e) {
-            final String msg = "Catch Exception " + e.getClass().getName() + " on host:" + citrixResourceBase.getHost().getUuid() + " for template: " + tmplturl + " due to "
-                    + e.toString();
-            s_logger.warn(msg, e);
-            return new PrimaryStorageDownloadAnswer(msg);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java
deleted file mode 100644
index 8b7c174..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java
+++ /dev/null
@@ -1,94 +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;
-
-import org.apache.log4j.Logger;
-import org.apache.xmlrpc.XmlRpcException;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.PvlanSetupCommand;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.hypervisor.xenserver.resource.XsLocalNetwork;
-import com.cloud.network.Networks.TrafficType;
-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.Types.XenAPIException;
-
-@ResourceWrapper(handles =  PvlanSetupCommand.class)
-public final class CitrixPvlanSetupCommandWrapper extends CommandWrapper<PvlanSetupCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixPvlanSetupCommandWrapper.class);
-
-    @Override
-    public Answer execute(final PvlanSetupCommand command, final CitrixResourceBase citrixResourceBase) {
-        final Connection conn = citrixResourceBase.getConnection();
-
-        final String primaryPvlan = command.getPrimary();
-        final String isolatedPvlan = command.getIsolated();
-        final String op = command.getOp();
-        final String dhcpName = command.getDhcpName();
-        final String dhcpMac = command.getDhcpMac();
-        final String dhcpIp = command.getDhcpIp();
-        final String vmMac = command.getVmMac();
-        final String networkTag = command.getNetworkTag();
-
-        String nwNameLabel = null;
-        try {
-            final XsLocalNetwork nw = citrixResourceBase.getNativeNetworkForTraffic(conn, TrafficType.Guest, networkTag);
-            if (nw == null) {
-                s_logger.error("Network is not configured on the backend for pvlan " + primaryPvlan);
-                throw new CloudRuntimeException("Network for the backend is not configured correctly for pvlan primary: " + primaryPvlan);
-            }
-            nwNameLabel = nw.getNetwork().getNameLabel(conn);
-        } catch (final XenAPIException e) {
-            s_logger.warn("Fail to get network", e);
-            return new Answer(command, false, e.toString());
-        } catch (final XmlRpcException e) {
-            s_logger.warn("Fail to get network", e);
-            return new Answer(command, false, e.toString());
-        }
-
-        String result = null;
-        if (command.getType() == PvlanSetupCommand.Type.DHCP) {
-            result = citrixResourceBase.callHostPlugin(conn, "ovs-pvlan", "setup-pvlan-dhcp", "op", op, "nw-label", nwNameLabel, "primary-pvlan", primaryPvlan, "isolated-pvlan",
-                    isolatedPvlan, "dhcp-name", dhcpName, "dhcp-ip", dhcpIp, "dhcp-mac", dhcpMac);
-
-            if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) {
-                s_logger.warn("Failed to program pvlan for dhcp server with mac " + dhcpMac);
-                return new Answer(command, false, result);
-            } else {
-                s_logger.info("Programmed pvlan for dhcp server with mac " + dhcpMac);
-            }
-        } else if (command.getType() == PvlanSetupCommand.Type.VM) {
-            result = citrixResourceBase.callHostPlugin(conn, "ovs-pvlan", "setup-pvlan-vm", "op", op, "nw-label", nwNameLabel, "primary-pvlan", primaryPvlan, "isolated-pvlan",
-                    isolatedPvlan, "vm-mac", vmMac);
-
-            if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) {
-                s_logger.warn("Failed to program pvlan for vm with mac " + vmMac);
-                return new Answer(command, false, result);
-            } else {
-                s_logger.info("Programmed pvlan for vm with mac " + vmMac);
-            }
-        }
-        return new Answer(command, true, result);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java
deleted file mode 100644
index 708ea56..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java
+++ /dev/null
@@ -1,77 +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;
-
-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.ReadyAnswer;
-import com.cloud.agent.api.ReadyCommand;
-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.Types.XenAPIException;
-import com.xensource.xenapi.VM;
-
-@ResourceWrapper(handles =  ReadyCommand.class)
-public final class CitrixReadyCommandWrapper extends CommandWrapper<ReadyCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixReadyCommandWrapper.class);
-
-    @Override
-    public Answer execute(final ReadyCommand command, final CitrixResourceBase citrixResourceBase) {
-        final Connection conn = citrixResourceBase.getConnection();
-        final Long dcId = command.getDataCenterId();
-        // Ignore the result of the callHostPlugin. Even if unmounting the
-        // snapshots dir fails, let Ready command
-        // succeed.
-        citrixResourceBase.umountSnapshotDir(conn, dcId);
-
-        citrixResourceBase.setupLinkLocalNetwork(conn);
-        // try to destroy CD-ROM device for all system VMs on this host
-        try {
-            final Host host = Host.getByUuid(conn, citrixResourceBase.getHost().getUuid());
-            final Set<VM> vms = host.getResidentVMs(conn);
-            for (final VM vm : vms) {
-                citrixResourceBase.destroyPatchVbd(conn, vm.getNameLabel(conn));
-            }
-        } catch (final Exception e) {
-        }
-        try {
-            final boolean result = citrixResourceBase.cleanupHaltedVms(conn);
-            if (!result) {
-                return new ReadyAnswer(command, "Unable to cleanup halted vms");
-            }
-        } catch (final XenAPIException e) {
-            s_logger.warn("Unable to cleanup halted vms", e);
-            return new ReadyAnswer(command, "Unable to cleanup halted vms");
-        } catch (final XmlRpcException e) {
-            s_logger.warn("Unable to cleanup halted vms", e);
-            return new ReadyAnswer(command, "Unable to cleanup halted vms");
-        }
-
-        return new ReadyAnswer(command);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java
deleted file mode 100644
index cc27528..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java
+++ /dev/null
@@ -1,70 +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;
-
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.RebootAnswer;
-import com.cloud.agent.api.RebootCommand;
-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.Types.XenAPIException;
-import com.xensource.xenapi.VM;
-
-@ResourceWrapper(handles =  RebootCommand.class)
-public final class CitrixRebootCommandWrapper extends CommandWrapper<RebootCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixRebootCommandWrapper.class);
-
-    @Override
-    public Answer execute(final RebootCommand command, final CitrixResourceBase citrixResourceBase) {
-        final Connection conn = citrixResourceBase.getConnection();
-        s_logger.debug("7. The VM " + command.getVmName() + " is in Starting state");
-        try {
-            Set<VM> vms = null;
-            try {
-                vms = VM.getByNameLabel(conn, command.getVmName());
-            } catch (final XenAPIException e0) {
-                s_logger.debug("getByNameLabel failed " + e0.toString());
-                return new RebootAnswer(command, "getByNameLabel failed " + e0.toString(), false);
-            } catch (final Exception e0) {
-                s_logger.debug("getByNameLabel failed " + e0.getMessage());
-                return new RebootAnswer(command, "getByNameLabel failed", false);
-            }
-            for (final VM vm : vms) {
-                try {
-                    citrixResourceBase.rebootVM(conn, vm, vm.getNameLabel(conn));
-                } catch (final Exception e) {
-                    final String msg = e.toString();
-                    s_logger.warn(msg, e);
-                    return new RebootAnswer(command, msg, false);
-                }
-            }
-            return new RebootAnswer(command, "reboot succeeded", true);
-        } finally {
-            s_logger.debug("8. The VM " + command.getVmName() + " is in Running state");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java
deleted file mode 100644
index 182048c..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java
+++ /dev/null
@@ -1,54 +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;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.RebootCommand;
-import com.cloud.agent.api.RebootRouterCommand;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.resource.CommandWrapper;
-import com.cloud.resource.ResourceWrapper;
-import com.xensource.xenapi.Connection;
-
-@ResourceWrapper(handles =  RebootRouterCommand.class)
-public final class CitrixRebootRouterCommandWrapper extends CommandWrapper<RebootRouterCommand, Answer, CitrixResourceBase> {
-
-    @Override
-    public Answer execute(final RebootRouterCommand command, final CitrixResourceBase citrixResourceBase) {
-        final Connection conn = citrixResourceBase.getConnection();
-
-        final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
-
-        final RebootCommand rebootCommand = new RebootCommand(command.getVmName());
-        final Answer answer = wrapper.execute(rebootCommand, citrixResourceBase);
-
-        if (answer.getResult()) {
-            final String cnct = citrixResourceBase.connect(conn, command.getVmName(), command.getPrivateIpAddress());
-            citrixResourceBase.networkUsage(conn, command.getPrivateIpAddress(), "create", null);
-
-            if (cnct == null) {
-                return answer;
-            } else {
-                return new Answer(command, false, cnct);
-            }
-        }
-        return answer;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java
deleted file mode 100644
index 8dabaf2..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java
+++ /dev/null
@@ -1,124 +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;
-
-import java.util.Hashtable;
-import java.util.Set;
-
-import org.reflections.Reflections;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.hypervisor.xenserver.resource.XcpServerResource;
-import com.cloud.hypervisor.xenserver.resource.XenServer56FP1Resource;
-import com.cloud.hypervisor.xenserver.resource.XenServer56Resource;
-import com.cloud.hypervisor.xenserver.resource.XenServer610Resource;
-import com.cloud.hypervisor.xenserver.resource.XenServer620SP1Resource;
-import com.cloud.resource.CommandWrapper;
-import com.cloud.resource.RequestWrapper;
-import com.cloud.resource.ServerResource;
-
-public class CitrixRequestWrapper extends RequestWrapper {
-
-    private static CitrixRequestWrapper instance;
-
-    static {
-        instance = new CitrixRequestWrapper();
-    }
-
-    Reflections baseWrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper");
-    @SuppressWarnings("rawtypes")
-    Set<Class<? extends CommandWrapper>> baseSet = baseWrappers.getSubTypesOf(CommandWrapper.class);
-
-    Reflections xenServer56Wrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.xen56");
-    @SuppressWarnings("rawtypes")
-    Set<Class<? extends CommandWrapper>> xenServer56Set = xenServer56Wrappers.getSubTypesOf(CommandWrapper.class);
-
-    Reflections xenServer56P1Wrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.xen56p1");
-    @SuppressWarnings("rawtypes")
-    Set<Class<? extends CommandWrapper>> xenServer56P1Set = xenServer56P1Wrappers.getSubTypesOf(CommandWrapper.class);
-
-    Reflections xenServer610Wrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.xen610");
-    @SuppressWarnings("rawtypes")
-    Set<Class<? extends CommandWrapper>> xenServer610Set = xenServer610Wrappers.getSubTypesOf(CommandWrapper.class);
-
-    Reflections xenServer620SP1Wrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.xen620sp1");
-    @SuppressWarnings("rawtypes")
-    Set<Class<? extends CommandWrapper>> xenServer620SP1Set = xenServer620SP1Wrappers.getSubTypesOf(CommandWrapper.class);
-
-    Reflections xcpWrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.xcp");
-    @SuppressWarnings("rawtypes")
-    Set<Class<? extends CommandWrapper>> xcpSet = xcpWrappers.getSubTypesOf(CommandWrapper.class);
-
-    private CitrixRequestWrapper() {
-        init();
-    }
-
-    @SuppressWarnings("rawtypes")
-    private void init() {
-
-        final Hashtable<Class<? extends Command>, CommandWrapper> citrixCommands = processAnnotations(baseSet);
-        final Hashtable<Class<? extends Command>, CommandWrapper> xenServer56Commands = processAnnotations(xenServer56Set);
-        final Hashtable<Class<? extends Command>, CommandWrapper> xenServer56P1Commands = processAnnotations(xenServer56P1Set);
-        final Hashtable<Class<? extends Command>, CommandWrapper> xenServer610Commands = processAnnotations(xenServer610Set);
-        final Hashtable<Class<? extends Command>, CommandWrapper> xenServer620SP1Commands = processAnnotations(xenServer620SP1Set);
-        final Hashtable<Class<? extends Command>, CommandWrapper> xcpServerResourceCommand = processAnnotations(xcpSet);
-
-        // CitrixResourceBase commands
-        resources.put(CitrixResourceBase.class, citrixCommands);
-
-        // XenServer56Resource commands
-        resources.put(XenServer56Resource.class, xenServer56Commands);
-
-        // XenServer56FP1Resource commands
-        resources.put(XenServer56FP1Resource.class, xenServer56P1Commands);
-
-        // XenServer620SP1Resource commands
-        resources.put(XenServer620SP1Resource.class, xenServer620SP1Commands);
-
-        // XenServer610Resource commands
-        resources.put(XenServer610Resource.class, xenServer610Commands);
-
-        // XcpServerResource commands
-        resources.put(XcpServerResource.class, xcpServerResourceCommand);
-    }
-
-    public static CitrixRequestWrapper getInstance() {
-        return instance;
-    }
-
-    @SuppressWarnings({"rawtypes" })
-    @Override
-    public Answer execute(final Command command, final ServerResource serverResource) {
-        final Class<? extends ServerResource> resourceClass = serverResource.getClass();
-
-        final Hashtable<Class<? extends Command>, CommandWrapper> resourceCommands = retrieveResource(command, resourceClass);
-
-        CommandWrapper<Command, Answer, ServerResource> commandWrapper = retrieveCommands(command.getClass(), resourceCommands);
-
-        while (commandWrapper == null) {
-            //Could not find the command in the given resource, will traverse the family tree.
-            commandWrapper = retryWhenAllFails(command, resourceClass, resourceCommands);
-        }
-
-        return commandWrapper.execute(command, serverResource);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java
deleted file mode 100644
index 25f350f..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java
+++ /dev/null
@@ -1,54 +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;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.storage.ResizeVolumeAnswer;
-import com.cloud.agent.api.storage.ResizeVolumeCommand;
-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.VDI;
-
-@ResourceWrapper(handles =  ResizeVolumeCommand.class)
-public final class CitrixResizeVolumeCommandWrapper extends CommandWrapper<ResizeVolumeCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixResizeVolumeCommandWrapper.class);
-
-    @Override
-    public Answer execute(final ResizeVolumeCommand command, final CitrixResourceBase citrixResourceBase) {
-        final Connection conn = citrixResourceBase.getConnection();
-        final String volid = command.getPath();
-        final long newSize = command.getNewSize();
-
-        try {
-            final VDI vdi = citrixResourceBase.getVDIbyUuid(conn, volid);
-            vdi.resize(conn, newSize);
-            return new ResizeVolumeAnswer(command, true, "success", newSize);
-        } catch (final Exception e) {
-            s_logger.warn("Unable to resize volume", e);
-            final String error = "failed to resize volume:" + e;
-            return new ResizeVolumeAnswer(command, false, error);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.java
deleted file mode 100644
index def4df7..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.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.hypervisor.xenserver.resource.wrapper;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-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.RevertToVMSnapshotAnswer;
-import com.cloud.agent.api.RevertToVMSnapshotCommand;
-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.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 =  RevertToVMSnapshotCommand.class)
-public final class CitrixRevertToVMSnapshotCommandWrapper extends CommandWrapper<RevertToVMSnapshotCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixRevertToVMSnapshotCommandWrapper.class);
-
-    @Override
-    public Answer execute(final RevertToVMSnapshotCommand command, final CitrixResourceBase citrixResourceBase) {
-        final String vmName = command.getVmName();
-        final List<VolumeObjectTO> listVolumeTo = command.getVolumeTOs();
-        final VMSnapshot.Type vmSnapshotType = command.getTarget().getType();
-        final Boolean snapshotMemory = vmSnapshotType == VMSnapshot.Type.DiskAndMemory;
-        final Connection conn = citrixResourceBase.getConnection();
-        PowerState vmState = null;
-        VM vm = null;
-        try {
-
-            final Set<VM> vmSnapshots = VM.getByNameLabel(conn, command.getTarget().getSnapshotName());
-            if (vmSnapshots == null || vmSnapshots.size() == 0) {
-                return new RevertToVMSnapshotAnswer(command, false, "Cannot find vmSnapshot with name: " + command.getTarget().getSnapshotName());
-            }
-
-            final VM vmSnapshot = vmSnapshots.iterator().next();
-
-            // find target VM or creating a work VM
-            try {
-                vm = citrixResourceBase.getVM(conn, vmName);
-            } catch (final Exception e) {
-                vm = citrixResourceBase.createWorkingVM(conn, vmName, command.getGuestOSType(), command.getPlatformEmulator(), listVolumeTo);
-            }
-
-            if (vm == null) {
-                return new RevertToVMSnapshotAnswer(command, false, "Revert to VM Snapshot Failed due to can not find vm: " + vmName);
-            }
-
-            // call plugin to execute revert
-            citrixResourceBase.revertToSnapshot(conn, vmSnapshot, vmName, vm.getUuid(conn), snapshotMemory, citrixResourceBase.getHost().getUuid());
-            vm = citrixResourceBase.getVM(conn, vmName);
-            final Set<VBD> vbds = vm.getVBDs(conn);
-            final Map<String, VDI> vdiMap = new HashMap<String, VDI>();
-            // get vdi:vbdr to a map
-            for (final VBD vbd : vbds) {
-                final VBD.Record vbdr = vbd.getRecord(conn);
-                if (vbdr.type == Types.VbdType.DISK) {
-                    final VDI vdi = vbdr.VDI;
-                    vdiMap.put(vbdr.userdevice, vdi);
-                }
-            }
-
-            if (!snapshotMemory) {
-                vm.destroy(conn);
-                vmState = PowerState.PowerOff;
-            } else {
-                vmState = PowerState.PowerOn;
-            }
-
-            // after revert, VM's volumes path have been changed, need to report to manager
-            for (final VolumeObjectTO volumeTo : listVolumeTo) {
-                final Long deviceId = volumeTo.getDeviceId();
-                final VDI vdi = vdiMap.get(deviceId.toString());
-                volumeTo.setPath(vdi.getUuid(conn));
-            }
-
-            return new RevertToVMSnapshotAnswer(command, listVolumeTo, vmState);
-        } catch (final Exception e) {
-            s_logger.error("revert vm " + vmName + " to snapshot " + command.getTarget().getSnapshotName() + " failed due to " + e.getMessage());
-            return new RevertToVMSnapshotAnswer(command, false, e.getMessage());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java
deleted file mode 100644
index d21bcbd..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java
+++ /dev/null
@@ -1,108 +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;
-
-import java.util.Iterator;
-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.ScaleVmAnswer;
-import com.cloud.agent.api.ScaleVmCommand;
-import com.cloud.agent.api.to.VirtualMachineTO;
-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.Host;
-import com.xensource.xenapi.Types.VmPowerState;
-import com.xensource.xenapi.Types.XenAPIException;
-import com.xensource.xenapi.VM;
-
-@ResourceWrapper(handles =  ScaleVmCommand.class)
-public final class CitrixScaleVmCommandWrapper extends CommandWrapper<ScaleVmCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixScaleVmCommandWrapper.class);
-
-    @Override
-    public Answer execute(final ScaleVmCommand command, final CitrixResourceBase citrixResourceBase) {
-        final VirtualMachineTO vmSpec = command.getVirtualMachine();
-        final String vmName = vmSpec.getName();
-        try {
-            final Connection conn = citrixResourceBase.getConnection();
-            final Set<VM> vms = VM.getByNameLabel(conn, vmName);
-            final Host host = Host.getByUuid(conn, citrixResourceBase.getHost().getUuid());
-
-            // If DMC is not enable then don't execute this command.
-            if (!citrixResourceBase.isDmcEnabled(conn, host)) {
-                throw new CloudRuntimeException("Unable to scale the vm: " + vmName + " as DMC - Dynamic memory control is not enabled for the XenServer:"
-                        + citrixResourceBase.getHost().getUuid() + " ,check your license and hypervisor version.");
-            }
-
-            if (vms == null || vms.size() == 0) {
-                s_logger.info("No running VM " + vmName + " exists on XenServer" + citrixResourceBase.getHost().getUuid());
-                return new ScaleVmAnswer(command, false, "VM does not exist");
-            }
-
-            // stop vm which is running on this host or is in halted state
-            final Iterator<VM> iter = vms.iterator();
-            while (iter.hasNext()) {
-                final VM vm = iter.next();
-                final VM.Record vmr = vm.getRecord(conn);
-
-                if (vmr.powerState == VmPowerState.HALTED || vmr.powerState == VmPowerState.RUNNING && !citrixResourceBase.isRefNull(vmr.residentOn)
-                        && !vmr.residentOn.getUuid(conn).equals(citrixResourceBase.getHost().getUuid())) {
-                    iter.remove();
-                }
-            }
-
-            for (final VM vm : vms) {
-                vm.getRecord(conn);
-                try {
-                    citrixResourceBase.scaleVM(conn, vm, vmSpec, host);
-                } catch (final Exception e) {
-                    final String msg = "Catch exception " + e.getClass().getName() + " when scaling VM:" + vmName + " due to " + e.toString();
-                    s_logger.debug(msg);
-                    return new ScaleVmAnswer(command, false, msg);
-                }
-
-            }
-            final String msg = "scaling VM " + vmName + " is successful on host " + host;
-            s_logger.debug(msg);
-            return new ScaleVmAnswer(command, true, msg);
-
-        } catch (final XenAPIException e) {
-            final String msg = "Upgrade Vm " + vmName + " fail due to " + e.toString();
-            s_logger.warn(msg, e);
-            return new ScaleVmAnswer(command, false, msg);
-        } catch (final XmlRpcException e) {
-            final String msg = "Upgrade Vm " + vmName + " fail due to " + e.getMessage();
-            s_logger.warn(msg, e);
-            return new ScaleVmAnswer(command, false, msg);
-        } catch (final Exception e) {
-            final String msg = "Unable to upgrade " + vmName + " due to " + e.getMessage();
-            s_logger.warn(msg, e);
-            return new ScaleVmAnswer(command, false, msg);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java
deleted file mode 100644
index 793a564..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java
+++ /dev/null
@@ -1,63 +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;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.SecurityGroupRuleAnswer;
-import com.cloud.agent.api.SecurityGroupRulesCmd;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.resource.CommandWrapper;
-import com.cloud.resource.ResourceWrapper;
-import com.xensource.xenapi.Connection;
-
-@ResourceWrapper(handles =  SecurityGroupRulesCmd.class)
-public final class CitrixSecurityGroupRulesCommandWrapper extends CommandWrapper<SecurityGroupRulesCmd, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixSecurityGroupRulesCommandWrapper.class);
-
-    @Override
-    public Answer execute(final SecurityGroupRulesCmd command, final CitrixResourceBase citrixResourceBase) {
-        final Connection conn = citrixResourceBase.getConnection();
-        if (s_logger.isTraceEnabled()) {
-            s_logger.trace("Sending network rules command to " + citrixResourceBase.getHost().getIp());
-        }
-
-        if (!citrixResourceBase.canBridgeFirewall()) {
-            s_logger.warn("Host " + citrixResourceBase.getHost().getIp() + " cannot do bridge firewalling");
-            return new SecurityGroupRuleAnswer(command, false, "Host " + citrixResourceBase.getHost().getIp() + " cannot do bridge firewalling",
-                    SecurityGroupRuleAnswer.FailureReason.CANNOT_BRIDGE_FIREWALL);
-        }
-
-        final String result = citrixResourceBase.callHostPlugin(conn, "vmops", "network_rules", "vmName", command.getVmName(), "vmIP", command.getGuestIp(), "vmMAC",
-                command.getGuestMac(), "vmID", Long.toString(command.getVmId()), "signature", command.getSignature(), "seqno", Long.toString(command.getSeqNum()), "deflated",
-                "true", "rules", command.compressStringifiedRules(), "secIps", command.getSecIpsString());
-
-        if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) {
-            s_logger.warn("Failed to program network rules for vm " + command.getVmName());
-            return new SecurityGroupRuleAnswer(command, false, "programming network rules failed");
-        } else {
-            s_logger.info("Programmed network rules for vm " + command.getVmName() + " guestIp=" + command.getGuestIp() + ", ingress numrules="
-                    + command.getIngressRuleSet().length + ", egress numrules=" + command.getEgressRuleSet().length);
-            return new SecurityGroupRuleAnswer(command);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java
deleted file mode 100644
index 3ff0dfe..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java
+++ /dev/null
@@ -1,202 +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;
-
-import java.util.Map;
-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.SetupAnswer;
-import com.cloud.agent.api.SetupCommand;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.resource.CommandWrapper;
-import com.cloud.resource.ResourceWrapper;
-import com.cloud.utils.Pair;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.xensource.xenapi.Bond;
-import com.xensource.xenapi.Connection;
-import com.xensource.xenapi.Host;
-import com.xensource.xenapi.Network;
-import com.xensource.xenapi.PIF;
-import com.xensource.xenapi.Pool;
-import com.xensource.xenapi.Types;
-import com.xensource.xenapi.Types.XenAPIException;
-
-@ResourceWrapper(handles =  SetupCommand.class)
-public final class CitrixSetupCommandWrapper extends CommandWrapper<SetupCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixSetupCommandWrapper.class);
-
-    @Override
-    public Answer execute(final SetupCommand command, final CitrixResourceBase citrixResourceBase) {
-        final Connection conn = citrixResourceBase.getConnection();
-        try {
-            final Map<Pool, Pool.Record> poolRecs = Pool.getAllRecords(conn);
-            if (poolRecs.size() != 1) {
-                throw new CloudRuntimeException("There are " + poolRecs.size() + " pool for host :" + citrixResourceBase.getHost().getUuid());
-            }
-            final Host master = poolRecs.values().iterator().next().master;
-            citrixResourceBase.setupServer(conn, master);
-            final Host host = Host.getByUuid(conn, citrixResourceBase.getHost().getUuid());
-            citrixResourceBase.setupServer(conn, host);
-
-            if (!citrixResourceBase.setIptables(conn)) {
-                s_logger.warn("set xenserver Iptable failed");
-                return null;
-            }
-
-            if (citrixResourceBase.isSecurityGroupEnabled()) {
-                final boolean canBridgeFirewall = citrixResourceBase.canBridgeFirewall(conn);
-                citrixResourceBase.setCanBridgeFirewall(canBridgeFirewall);
-                if (!canBridgeFirewall) {
-                    final String msg = "Failed to configure brige firewall";
-                    s_logger.warn(msg);
-                    s_logger.warn("Check host " + citrixResourceBase.getHost().getIp() +" for CSP is installed or not and check network mode for bridge");
-                    return new SetupAnswer(command, msg);
-                }
-
-            }
-
-
-            final boolean r = citrixResourceBase.launchHeartBeat(conn);
-            if (!r) {
-                return null;
-            }
-            citrixResourceBase.cleanupTemplateSR(conn);
-            try {
-                if (command.useMultipath()) {
-                    // the config value is set to true
-                    host.addToOtherConfig(conn, "multipathing", "true");
-                    host.addToOtherConfig(conn, "multipathhandle", "dmp");
-                }
-
-            } catch (final Types.MapDuplicateKey e) {
-                s_logger.debug("multipath is already set");
-            }
-
-            if (command.needSetup() ) {
-                final String result = citrixResourceBase.callHostPlugin(conn, "vmops", "setup_iscsi", "uuid", citrixResourceBase.getHost().getUuid());
-
-                if (!result.contains("> DONE <")) {
-                    s_logger.warn("Unable to setup iscsi: " + result);
-                    return new SetupAnswer(command, result);
-                }
-
-                Pair<PIF, PIF.Record> mgmtPif = null;
-                final Set<PIF> hostPifs = host.getPIFs(conn);
-                for (final PIF pif : hostPifs) {
-                    final PIF.Record rec = pif.getRecord(conn);
-                    if (rec.management) {
-                        if (rec.VLAN != null && rec.VLAN != -1) {
-                            final String msg =
-                                    new StringBuilder("Unsupported configuration.  Management network is on a VLAN.  host=").append(citrixResourceBase.getHost().getUuid())
-                                    .append("; pif=")
-                                    .append(rec.uuid)
-                                    .append("; vlan=")
-                                    .append(rec.VLAN)
-                                    .toString();
-                            s_logger.warn(msg);
-                            return new SetupAnswer(command, msg);
-                        }
-                        if (s_logger.isDebugEnabled()) {
-                            s_logger.debug("Management network is on pif=" + rec.uuid);
-                        }
-                        mgmtPif = new Pair<PIF, PIF.Record>(pif, rec);
-                        break;
-                    }
-                }
-
-                if (mgmtPif == null) {
-                    final String msg = "Unable to find management network for " + citrixResourceBase.getHost().getUuid();
-                    s_logger.warn(msg);
-                    return new SetupAnswer(command, msg);
-                }
-
-                final Map<Network, Network.Record> networks = Network.getAllRecords(conn);
-                if(networks == null) {
-                    final String msg = "Unable to setup as there are no networks in the host: " +  citrixResourceBase.getHost().getUuid();
-                    s_logger.warn(msg);
-                    return new SetupAnswer(command, msg);
-                }
-                for (final Network.Record network : networks.values()) {
-                    if (network.nameLabel.equals("cloud-private")) {
-                        for (final PIF pif : network.PIFs) {
-                            final PIF.Record pr = pif.getRecord(conn);
-                            if (citrixResourceBase.getHost().getUuid().equals(pr.host.getUuid(conn))) {
-                                if (s_logger.isDebugEnabled()) {
-                                    s_logger.debug("Found a network called cloud-private. host=" + citrixResourceBase.getHost().getUuid() + ";  Network=" + network.uuid + "; pif=" + pr.uuid);
-                                }
-                                if (pr.VLAN != null && pr.VLAN != -1) {
-                                    final String msg =
-                                            new StringBuilder("Unsupported configuration.  Network cloud-private is on a VLAN.  Network=").append(network.uuid)
-                                            .append(" ; pif=")
-                                            .append(pr.uuid)
-                                            .toString();
-                                    s_logger.warn(msg);
-                                    return new SetupAnswer(command, msg);
-                                }
-                                if (!pr.management && pr.bondMasterOf != null && pr.bondMasterOf.size() > 0) {
-                                    if (pr.bondMasterOf.size() > 1) {
-                                        final String msg =
-                                                new StringBuilder("Unsupported configuration.  Network cloud-private has more than one bond.  Network=").append(network.uuid)
-                                                .append("; pif=")
-                                                .append(pr.uuid)
-                                                .toString();
-                                        s_logger.warn(msg);
-                                        return new SetupAnswer(command, msg);
-                                    }
-                                    final Bond bond = pr.bondMasterOf.iterator().next();
-                                    final Set<PIF> slaves = bond.getSlaves(conn);
-                                    for (final PIF slave : slaves) {
-                                        final PIF.Record spr = slave.getRecord(conn);
-                                        if (spr.management) {
-                                            if (!citrixResourceBase.transferManagementNetwork(conn, host, slave, spr, pif)) {
-                                                final String msg =
-                                                        new StringBuilder("Unable to transfer management network.  slave=" + spr.uuid + "; master=" + pr.uuid + "; host=" +
-                                                                citrixResourceBase.getHost().getUuid()).toString();
-                                                s_logger.warn(msg);
-                                                return new SetupAnswer(command, msg);
-                                            }
-                                            break;
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-            return new SetupAnswer(command, false);
-
-        } catch (final XmlRpcException e) {
-            s_logger.warn("Unable to setup", e);
-            return new SetupAnswer(command, e.getMessage());
-        } catch (final XenAPIException e) {
-            s_logger.warn("Unable to setup", e);
-            return new SetupAnswer(command, e.getMessage());
-        } catch (final Exception e) {
-            s_logger.warn("Unable to setup", e);
-            return new SetupAnswer(command, e.getMessage());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java
deleted file mode 100644
index 27f8474..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java
+++ /dev/null
@@ -1,212 +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;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.OvsSetTagAndFlowAnswer;
-import com.cloud.agent.api.OvsSetTagAndFlowCommand;
-import com.cloud.agent.api.StartAnswer;
-import com.cloud.agent.api.StartCommand;
-import com.cloud.agent.api.to.DiskTO;
-import com.cloud.agent.api.to.GPUDeviceTO;
-import com.cloud.agent.api.to.NicTO;
-import com.cloud.agent.api.to.VirtualMachineTO;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.network.Networks;
-import com.cloud.network.Networks.BroadcastDomainType;
-import com.cloud.network.Networks.IsolationType;
-import com.cloud.resource.CommandWrapper;
-import com.cloud.resource.ResourceWrapper;
-import com.cloud.vm.VirtualMachine;
-import com.xensource.xenapi.Connection;
-import com.xensource.xenapi.Host;
-import com.xensource.xenapi.Types.VmPowerState;
-import com.xensource.xenapi.VDI;
-import com.xensource.xenapi.VM;
-
-@ResourceWrapper(handles =  StartCommand.class)
-public final class CitrixStartCommandWrapper extends CommandWrapper<StartCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixStartCommandWrapper.class);
-
-    @Override
-    public Answer execute(final StartCommand command, final CitrixResourceBase citrixResourceBase) {
-        final Connection conn = citrixResourceBase.getConnection();
-        final VirtualMachineTO vmSpec = command.getVirtualMachine();
-        final String vmName = vmSpec.getName();
-        VmPowerState state = VmPowerState.HALTED;
-        VM vm = null;
-        // if a VDI is created, record its UUID to send back to the CS MS
-        final Map<String, String> iqnToPath = new HashMap<String, String>();
-        try {
-            final Set<VM> vms = VM.getByNameLabel(conn, vmName);
-            if (vms != null) {
-                for (final VM v : vms) {
-                    final VM.Record vRec = v.getRecord(conn);
-                    if (vRec.powerState == VmPowerState.HALTED) {
-                        v.destroy(conn);
-                    } else if (vRec.powerState == VmPowerState.RUNNING) {
-                        final String host = vRec.residentOn.getUuid(conn);
-                        final String msg = "VM " + vmName + " is runing on host " + host;
-                        s_logger.debug(msg);
-                        return new StartAnswer(command, msg, host);
-                    } else {
-                        final String msg = "There is already a VM having the same name " + vmName + " vm record " + vRec.toString();
-                        s_logger.warn(msg);
-                        return new StartAnswer(command, msg);
-                    }
-                }
-            }
-            s_logger.debug("1. The VM " + vmName + " is in Starting state.");
-
-            final Host host = Host.getByUuid(conn, citrixResourceBase.getHost().getUuid());
-            vm = citrixResourceBase.createVmFromTemplate(conn, vmSpec, host);
-
-            final GPUDeviceTO gpuDevice = vmSpec.getGpuDevice();
-            if (gpuDevice != null) {
-                s_logger.debug("Creating VGPU for of VGPU type: " + gpuDevice.getVgpuType() + " in GPU group " + gpuDevice.getGpuGroup() + " for VM " + vmName);
-                citrixResourceBase.createVGPU(conn, command, vm, gpuDevice);
-            }
-
-            for (final DiskTO disk : vmSpec.getDisks()) {
-                final VDI newVdi = citrixResourceBase.prepareManagedDisk(conn, disk, vmName);
-
-                if (newVdi != null) {
-                    final String path = newVdi.getUuid(conn);
-
-                    iqnToPath.put(disk.getDetails().get(DiskTO.IQN), path);
-                }
-
-                citrixResourceBase.createVbd(conn, disk, vmName, vm, vmSpec.getBootloader(), newVdi);
-            }
-
-            if (vmSpec.getType() != VirtualMachine.Type.User) {
-                citrixResourceBase.createPatchVbd(conn, vmName, vm);
-            }
-
-            for (final NicTO nic : vmSpec.getNics()) {
-                citrixResourceBase.createVif(conn, vmName, vm, vmSpec, nic);
-            }
-
-            citrixResourceBase.startVM(conn, host, vm, vmName);
-
-            if (citrixResourceBase.isOvs()) {
-                // TODO(Salvatore-orlando): This code should go
-                for (final NicTO nic : vmSpec.getNics()) {
-                    if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vswitch) {
-                        final HashMap<String, String> args = citrixResourceBase.parseDefaultOvsRuleComamnd(BroadcastDomainType.getValue(nic.getBroadcastUri()));
-                        final OvsSetTagAndFlowCommand flowCmd = new OvsSetTagAndFlowCommand(args.get("vmName"), args.get("tag"), args.get("vlans"), args.get("seqno"),
-                                Long.parseLong(args.get("vmId")));
-
-                        final CitrixRequestWrapper citrixRequestWrapper = CitrixRequestWrapper.getInstance();
-
-                        final OvsSetTagAndFlowAnswer r = (OvsSetTagAndFlowAnswer) citrixRequestWrapper.execute(flowCmd, citrixResourceBase);
-
-                        if (!r.getResult()) {
-                            s_logger.warn("Failed to set flow for VM " + r.getVmId());
-                        } else {
-                            s_logger.info("Success to set flow for VM " + r.getVmId());
-                        }
-                    }
-                }
-            }
-
-            if (citrixResourceBase.canBridgeFirewall()) {
-                String result = null;
-                if (vmSpec.getType() != VirtualMachine.Type.User) {
-                    final NicTO[] nics = vmSpec.getNics();
-                    boolean secGrpEnabled = false;
-                    for (final NicTO nic : nics) {
-                        if (nic.isSecurityGroupEnabled() || nic.getIsolationUri() != null && nic.getIsolationUri().getScheme().equalsIgnoreCase(IsolationType.Ec2.toString())) {
-                            secGrpEnabled = true;
-                            break;
-                        }
-                    }
-                    if (secGrpEnabled) {
-                        result = citrixResourceBase.callHostPlugin(conn, "vmops", "default_network_rules_systemvm", "vmName", vmName);
-                        if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) {
-                            s_logger.warn("Failed to program default network rules for " + vmName);
-                        } else {
-                            s_logger.info("Programmed default network rules for " + vmName);
-                        }
-                    }
-
-                } else {
-                    // For user vm, program the rules for each nic if the
-                    // isolation uri scheme is ec2
-                    final NicTO[] nics = vmSpec.getNics();
-                    for (final NicTO nic : nics) {
-                        if (nic.isSecurityGroupEnabled() || nic.getIsolationUri() != null && nic.getIsolationUri().getScheme().equalsIgnoreCase(IsolationType.Ec2.toString())) {
-                            final List<String> nicSecIps = nic.getNicSecIps();
-                            String secIpsStr;
-                            final StringBuilder sb = new StringBuilder();
-                            if (nicSecIps != null) {
-                                for (final String ip : nicSecIps) {
-                                    sb.append(ip).append(":");
-                                }
-                                secIpsStr = sb.toString();
-                            } else {
-                                secIpsStr = "0:";
-                            }
-                            result = citrixResourceBase.callHostPlugin(conn, "vmops", "default_network_rules", "vmName", vmName, "vmIP", nic.getIp(), "vmMAC", nic.getMac(),
-                                    "vmID", Long.toString(vmSpec.getId()), "secIps", secIpsStr);
-
-                            if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) {
-                                s_logger.warn("Failed to program default network rules for " + vmName + " on nic with ip:" + nic.getIp() + " mac:" + nic.getMac());
-                            } else {
-                                s_logger.info("Programmed default network rules for " + vmName + " on nic with ip:" + nic.getIp() + " mac:" + nic.getMac());
-                            }
-                        }
-                    }
-                }
-            }
-
-            state = VmPowerState.RUNNING;
-
-            final StartAnswer startAnswer = new StartAnswer(command);
-
-            startAnswer.setIqnToPath(iqnToPath);
-
-            return startAnswer;
-        } catch (final Exception e) {
-            s_logger.warn("Catch Exception: " + e.getClass().toString() + " due to " + e.toString(), e);
-            final String msg = citrixResourceBase.handleVmStartFailure(conn, vmName, vm, "", e);
-
-            final StartAnswer startAnswer = new StartAnswer(command, msg);
-
-            startAnswer.setIqnToPath(iqnToPath);
-
-            return startAnswer;
-        } finally {
-            if (state != VmPowerState.HALTED) {
-                s_logger.debug("2. The VM " + vmName + " is in " + state + " state.");
-            } else {
-                s_logger.debug("The VM is in stopped state, detected problem during startup : " + vmName);
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java
deleted file mode 100644
index 8310cd8..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java
+++ /dev/null
@@ -1,175 +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;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.StopAnswer;
-import com.cloud.agent.api.StopCommand;
-import com.cloud.agent.api.VgpuTypesInfo;
-import com.cloud.agent.api.to.GPUDeviceTO;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.resource.CommandWrapper;
-import com.cloud.resource.ResourceWrapper;
-import com.cloud.utils.StringUtils;
-import com.xensource.xenapi.Connection;
-import com.xensource.xenapi.Network;
-import com.xensource.xenapi.SR;
-import com.xensource.xenapi.Types.VmPowerState;
-import com.xensource.xenapi.Types.XenAPIException;
-import com.xensource.xenapi.VGPU;
-import com.xensource.xenapi.VIF;
-import com.xensource.xenapi.VM;
-
-@ResourceWrapper(handles =  StopCommand.class)
-public final class CitrixStopCommandWrapper extends CommandWrapper<StopCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixStopCommandWrapper.class);
-
-    @Override
-    public Answer execute(final StopCommand command, final CitrixResourceBase citrixResourceBase) {
-        final String vmName = command.getVmName();
-        String platformstring = null;
-        try {
-            final Connection conn = citrixResourceBase.getConnection();
-            final Set<VM> vms = VM.getByNameLabel(conn, vmName);
-            // stop vm which is running on this host or is in halted state
-            final Iterator<VM> iter = vms.iterator();
-            while (iter.hasNext()) {
-                final VM vm = iter.next();
-                final VM.Record vmr = vm.getRecord(conn);
-                if (vmr.powerState != VmPowerState.RUNNING) {
-                    continue;
-                }
-                if (citrixResourceBase.isRefNull(vmr.residentOn)) {
-                    continue;
-                }
-                if (vmr.residentOn.getUuid(conn).equals(citrixResourceBase.getHost().getUuid())) {
-                    continue;
-                }
-                iter.remove();
-            }
-
-            if (vms.size() == 0) {
-                return new StopAnswer(command, "VM does not exist", true);
-            }
-            for (final VM vm : vms) {
-                final VM.Record vmr = vm.getRecord(conn);
-                platformstring = StringUtils.mapToString(vmr.platform);
-                if (vmr.isControlDomain) {
-                    final String msg = "Tring to Shutdown control domain";
-                    s_logger.warn(msg);
-                    return new StopAnswer(command, msg, false);
-                }
-
-                if (vmr.powerState == VmPowerState.RUNNING && !citrixResourceBase.isRefNull(vmr.residentOn) && !vmr.residentOn.getUuid(conn).equals(citrixResourceBase.getHost().getUuid())) {
-                    final String msg = "Stop Vm " + vmName + " failed due to this vm is not running on this host: " + citrixResourceBase.getHost().getUuid() + " but host:" + vmr.residentOn.getUuid(conn);
-                    s_logger.warn(msg);
-                    return new StopAnswer(command, msg, platformstring, false);
-                }
-
-                if (command.checkBeforeCleanup() && vmr.powerState == VmPowerState.RUNNING) {
-                    final String msg = "Vm " + vmName + " is running on host and checkBeforeCleanup flag is set, so bailing out";
-                    s_logger.debug(msg);
-                    return new StopAnswer(command, msg, false);
-                }
-
-                s_logger.debug("9. The VM " + vmName + " is in Stopping state");
-
-                try {
-                    if (vmr.powerState == VmPowerState.RUNNING) {
-                        /* when stop a vm, set affinity to current xenserver */
-                        vm.setAffinity(conn, vm.getResidentOn(conn));
-
-                        if (citrixResourceBase.canBridgeFirewall()) {
-                            final String result = citrixResourceBase.callHostPlugin(conn, "vmops", "destroy_network_rules_for_vm", "vmName", command.getVmName());
-                            if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) {
-                                s_logger.warn("Failed to remove  network rules for vm " + command.getVmName());
-                            } else {
-                                s_logger.info("Removed  network rules for vm " + command.getVmName());
-                            }
-                        }
-                        citrixResourceBase.shutdownVM(conn, vm, vmName);
-                    }
-                } catch (final Exception e) {
-                    final String msg = "Catch exception " + e.getClass().getName() + " when stop VM:" + command.getVmName() + " due to " + e.toString();
-                    s_logger.debug(msg);
-                    return new StopAnswer(command, msg, platformstring, false);
-                } finally {
-
-                    try {
-                        if (vm.getPowerState(conn) == VmPowerState.HALTED) {
-                            Set<VGPU> vGPUs = null;
-                            // Get updated GPU details
-                            try {
-                                vGPUs = vm.getVGPUs(conn);
-                            } catch (final XenAPIException e2) {
-                                s_logger.debug("VM " + vmName + " does not have GPU support.");
-                            }
-                            if (vGPUs != null && !vGPUs.isEmpty()) {
-                                final HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = citrixResourceBase.getGPUGroupDetails(conn);
-                                command.setGpuDevice(new GPUDeviceTO(null, null, groupDetails));
-                            }
-
-                            final Set<VIF> vifs = vm.getVIFs(conn);
-                            final List<Network> networks = new ArrayList<Network>();
-                            for (final VIF vif : vifs) {
-                                networks.add(vif.getNetwork(conn));
-                            }
-                            vm.destroy(conn);
-                            final SR sr = citrixResourceBase.getISOSRbyVmName(conn, command.getVmName());
-                            citrixResourceBase.removeSR(conn, sr);
-                            // Disable any VLAN networks that aren't used
-                            // anymore
-                            for (final Network network : networks) {
-                                try {
-                                    if (network.getNameLabel(conn).startsWith("VLAN")) {
-                                        citrixResourceBase.disableVlanNetwork(conn, network);
-                                    }
-                                } catch (final Exception e) {
-                                    // network might be destroyed by other host
-                                }
-                            }
-                            return new StopAnswer(command, "Stop VM " + vmName + " Succeed", platformstring, true);
-                        }
-                    } catch (final Exception e) {
-                        final String msg = "VM destroy failed in Stop " + vmName + " Command due to " + e.getMessage();
-                        s_logger.warn(msg, e);
-                    } finally {
-                        s_logger.debug("10. The VM " + vmName + " is in Stopped state");
-                    }
-                }
-            }
-
-        } catch (final Exception e) {
-            final String msg = "Stop Vm " + vmName + " fail due to " + e.toString();
-            s_logger.warn(msg, e);
-            return new StopAnswer(command, msg, platformstring, false);
-        }
-        return new StopAnswer(command, "Stop VM failed", platformstring, false);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java
deleted file mode 100644
index c14818e..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java
+++ /dev/null
@@ -1,38 +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;
-
-import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
-import com.cloud.resource.CommandWrapper;
-import com.cloud.resource.ResourceWrapper;
-import com.cloud.storage.resource.StorageSubsystemCommandHandler;
-
-@ResourceWrapper(handles =  StorageSubSystemCommand.class)
-public final class CitrixStorageSubSystemCommandWrapper extends CommandWrapper<StorageSubSystemCommand, Answer, CitrixResourceBase> {
-
-    @Override
-    public Answer execute(final StorageSubSystemCommand command, final CitrixResourceBase citrixResourceBase) {
-        final StorageSubsystemCommandHandler handler = citrixResourceBase.getStorageHandler();
-        return handler.handleStorageCommands(command);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java
deleted file mode 100644
index 639cfb0..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java
+++ /dev/null
@@ -1,74 +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;
-
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.UnPlugNicAnswer;
-import com.cloud.agent.api.UnPlugNicCommand;
-import com.cloud.agent.api.to.NicTO;
-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.Network;
-import com.xensource.xenapi.VIF;
-import com.xensource.xenapi.VM;
-
-@ResourceWrapper(handles =  UnPlugNicCommand.class)
-public final class CitrixUnPlugNicCommandWrapper extends CommandWrapper<UnPlugNicCommand, Answer, CitrixResourceBase> {
-
-    private static final Logger s_logger = Logger.getLogger(CitrixUnPlugNicCommandWrapper.class);
-
-    @Override
-    public Answer execute(final UnPlugNicCommand command, final CitrixResourceBase citrixResourceBase) {
-        final Connection conn = citrixResourceBase.getConnection();
-        final String vmName = command.getVmName();
-        try {
-            final Set<VM> vms = VM.getByNameLabel(conn, vmName);
-            if (vms == null || vms.isEmpty()) {
-                return new UnPlugNicAnswer(command, false, "Can not find VM " + vmName);
-            }
-            final VM vm = vms.iterator().next();
-            final NicTO nic = command.getNic();
-            final String mac = nic.getMac();
-            final VIF vif = citrixResourceBase.getVifByMac(conn, vm, mac);
-            if (vif != null) {
-                vif.unplug(conn);
-                final Network network = vif.getNetwork(conn);
-                vif.destroy(conn);
-                try {
-                    if (network.getNameLabel(conn).startsWith("VLAN")) {
-                        citrixResourceBase.disableVlanNetwork(conn, network);
-                    }
-                } catch (final Exception e) {
-                }
-            }
-            return new UnPlugNicAnswer(command, true, "success");
-        } catch (final Exception e) {
-            final String msg = " UnPlug Nic failed due to " + e.toString();
-            s_logger.warn(msg, e);
-            return new UnPlugNicAnswer(command, false, msg);
-        }
-    }
-}
\ No newline at end of file


Mime
View raw message