http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java deleted file mode 100644 index 8726141..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java +++ /dev/null @@ -1,71 +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.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
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.java deleted file mode 100644 index 18e05c4..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.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; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.GetVmDiskStatsAnswer; -import com.cloud.agent.api.GetVmDiskStatsCommand; -import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = GetVmDiskStatsCommand.class) -public final class CitrixGetVmDiskStatsCommandWrapper extends CommandWrapper<GetVmDiskStatsCommand, Answer, CitrixResourceBase> { - - @Override - public Answer execute(final GetVmDiskStatsCommand command, final CitrixResourceBase citrixResourceBase) { - return new GetVmDiskStatsAnswer(command, null, null, null); - } -} \ 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/CitrixGetVmStatsCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmStatsCommandWrapper.java deleted file mode 100644 index 5dce256..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmStatsCommandWrapper.java +++ /dev/null @@ -1,84 +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.List; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.apache.xmlrpc.XmlRpcException; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.GetVmStatsAnswer; -import com.cloud.agent.api.GetVmStatsCommand; -import com.cloud.agent.api.VmStatsEntry; -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 = GetVmStatsCommand.class) -public final class CitrixGetVmStatsCommandWrapper extends CommandWrapper<GetVmStatsCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixGetVmStatsCommandWrapper.class); - - @Override - public Answer execute(final GetVmStatsCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - final List<String> vmNames = command.getVmNames(); - final HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>(); - if (vmNames.size() == 0) { - return new GetVmStatsAnswer(command, vmStatsNameMap); - } - try { - - // Determine the UUIDs of the requested VMs - final List<String> vmUUIDs = new ArrayList<String>(); - - for (final String vmName : vmNames) { - final VM vm = citrixResourceBase.getVM(conn, vmName); - vmUUIDs.add(vm.getUuid(conn)); - } - - final HashMap<String, VmStatsEntry> vmStatsUUIDMap = citrixResourceBase.getVmStats(conn, command, vmUUIDs, command.getHostGuid()); - if (vmStatsUUIDMap == null) { - return new GetVmStatsAnswer(command, vmStatsNameMap); - } - - for (final Map.Entry<String,VmStatsEntry>entry : vmStatsUUIDMap.entrySet()) { - vmStatsNameMap.put(vmNames.get(vmUUIDs.indexOf(entry.getKey())), entry.getValue()); - } - - return new GetVmStatsAnswer(command, vmStatsNameMap); - } catch (final XenAPIException e) { - final String msg = "Unable to get VM stats" + e.toString(); - s_logger.warn(msg, e); - return new GetVmStatsAnswer(command, vmStatsNameMap); - } catch (final XmlRpcException e) { - final String msg = "Unable to get VM stats" + e.getMessage(); - s_logger.warn(msg, e); - return new GetVmStatsAnswer(command, vmStatsNameMap); - } - } -} \ 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/CitrixGetVncPortCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVncPortCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVncPortCommandWrapper.java deleted file mode 100644 index d57ab57..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVncPortCommandWrapper.java +++ /dev/null @@ -1,58 +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.GetVncPortAnswer; -import com.cloud.agent.api.GetVncPortCommand; -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.VM; - -@ResourceWrapper(handles = GetVncPortCommand.class) -public final class CitrixGetVncPortCommandWrapper extends CommandWrapper<GetVncPortCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixGetVncPortCommandWrapper.class); - - @Override - public Answer execute(final GetVncPortCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - try { - final Set<VM> vms = VM.getByNameLabel(conn, command.getName()); - if (vms.size() == 1) { - String consoleurl; - consoleurl = "consoleurl=" + citrixResourceBase.getVncUrl(conn, vms.iterator().next()) + "&" + "sessionref=" + conn.getSessionReference(); - return new GetVncPortAnswer(command, consoleurl, -1); - } else { - return new GetVncPortAnswer(command, "There are " + vms.size() + " VMs named " + command.getName()); - } - } catch (final Exception e) { - final String msg = "Unable to get vnc port due to " + e.toString(); - s_logger.warn(msg, e); - return new GetVncPortAnswer(command, 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/CitrixMaintainCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMaintainCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMaintainCommandWrapper.java deleted file mode 100644 index 8b56e9b..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMaintainCommandWrapper.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.Iterator; - -import org.apache.log4j.Logger; -import org.apache.xmlrpc.XmlRpcException; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.MaintainAnswer; -import com.cloud.agent.api.MaintainCommand; -import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.hypervisor.xenserver.resource.XsHost; -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; - -@ResourceWrapper(handles = MaintainCommand.class) -public final class CitrixMaintainCommandWrapper extends CommandWrapper<MaintainCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixMaintainCommandWrapper.class); - - @Override - public Answer execute(final MaintainCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - try { - - final XsHost xsHost = citrixResourceBase.getHost(); - final String uuid = xsHost.getUuid(); - final Host host = Host.getByUuid(conn, uuid); - // remove all tags cloud stack - final Host.Record hr = host.getRecord(conn); - - // Adding this check because could not get the mock to work. Will push the code and fix it afterwards. - if (hr == null) { - s_logger.warn("Host.Record is null."); - return new MaintainAnswer(command, false, "Host.Record is null"); - } - - final Iterator<String> it = hr.tags.iterator(); - while (it.hasNext()) { - final String tag = it.next(); - if (tag.contains("cloud")) { - it.remove(); - } - } - host.setTags(conn, hr.tags); - return new MaintainAnswer(command); - } catch (final XenAPIException e) { - s_logger.warn("Unable to put server in maintainence mode", e); - return new MaintainAnswer(command, false, e.getMessage()); - } catch (final XmlRpcException e) { - s_logger.warn("Unable to put server in maintainence mode", e); - return new MaintainAnswer(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/CitrixMigrateCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMigrateCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMigrateCommandWrapper.java deleted file mode 100644 index a4265dd..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMigrateCommandWrapper.java +++ /dev/null @@ -1,86 +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.MigrateAnswer; -import com.cloud.agent.api.MigrateCommand; -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; -import com.xensource.xenapi.VBD; -import com.xensource.xenapi.VM; - -@ResourceWrapper(handles = MigrateCommand.class) -public final class CitrixMigrateCommandWrapper extends CommandWrapper<MigrateCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixMigrateCommandWrapper.class); - - @Override - public Answer execute(final MigrateCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - final String vmName = command.getVmName(); - - try { - final Set<VM> vms = VM.getByNameLabel(conn, vmName); - - final String ipaddr = command.getDestinationIp(); - - final Set<Host> hosts = Host.getAll(conn); - Host dsthost = null; - if(hosts != null) { - for (final Host host : hosts) { - if (host.getAddress(conn).equals(ipaddr)) { - dsthost = host; - break; - } - } - } - if (dsthost == null) { - final String msg = "Migration failed due to unable to find host " + ipaddr + " in XenServer pool " + citrixResourceBase.getHost().getPool(); - s_logger.warn(msg); - return new MigrateAnswer(command, false, msg, null); - } - for (final VM vm : vms) { - final Set<VBD> vbds = vm.getVBDs(conn); - for (final VBD vbd : vbds) { - final VBD.Record vbdRec = vbd.getRecord(conn); - if (vbdRec.type.equals(Types.VbdType.CD) && !vbdRec.empty) { - vbd.eject(conn); - break; - } - } - citrixResourceBase.migrateVM(conn, dsthost, vm, vmName); - vm.setAffinity(conn, dsthost); - } - return new MigrateAnswer(command, true, "migration succeeded", null); - } catch (final Exception e) { - s_logger.warn(e.getMessage(), e); - return new MigrateAnswer(command, false, e.getMessage(), null); - } - } -} \ 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/CitrixModifySshKeysCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifySshKeysCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifySshKeysCommandWrapper.java deleted file mode 100644 index f443074..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifySshKeysCommandWrapper.java +++ /dev/null @@ -1,35 +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.ModifySshKeysCommand; -import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = ModifySshKeysCommand.class) -public final class CitrixModifySshKeysCommandWrapper extends CommandWrapper<ModifySshKeysCommand, Answer, CitrixResourceBase> { - - @Override - public Answer execute(final ModifySshKeysCommand command, final CitrixResourceBase citrixResourceBase) { - return new Answer(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/CitrixModifyStoragePoolCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifyStoragePoolCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifyStoragePoolCommandWrapper.java deleted file mode 100644 index 64848a4..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifyStoragePoolCommandWrapper.java +++ /dev/null @@ -1,98 +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.Map; - -import org.apache.log4j.Logger; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.ModifyStoragePoolAnswer; -import com.cloud.agent.api.ModifyStoragePoolCommand; -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.template.TemplateProp; -import com.cloud.utils.exception.CloudRuntimeException; -import com.xensource.xenapi.Connection; -import com.xensource.xenapi.SR; -import com.xensource.xenapi.Types.XenAPIException; - -@ResourceWrapper(handles = ModifyStoragePoolCommand.class) -public final class CitrixModifyStoragePoolCommandWrapper extends CommandWrapper<ModifyStoragePoolCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixModifyStoragePoolCommandWrapper.class); - - @Override - public Answer execute(final ModifyStoragePoolCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - final StorageFilerTO pool = command.getPool(); - final boolean add = command.getAdd(); - if (add) { - try { - final SR sr = citrixResourceBase.getStorageRepository(conn, pool.getUuid()); - citrixResourceBase.setupHeartbeatSr(conn, sr, false); - final long capacity = sr.getPhysicalSize(conn); - final long available = capacity - sr.getPhysicalUtilisation(conn); - if (capacity == -1) { - final String msg = "Pool capacity is -1! pool: " + pool.getHost() + pool.getPath(); - s_logger.warn(msg); - return new Answer(command, false, msg); - } - final Map<String, TemplateProp> tInfo = new HashMap<String, TemplateProp>(); - final ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(command, capacity, available, tInfo); - return answer; - } catch (final XenAPIException e) { - final String msg = "ModifyStoragePoolCommand add XenAPIException:" + e.toString() + " host:" + citrixResourceBase.getHost().getUuid() + " pool: " + pool.getHost() - + pool.getPath(); - s_logger.warn(msg, e); - return new Answer(command, false, msg); - } catch (final Exception e) { - final String msg = "ModifyStoragePoolCommand add XenAPIException:" + e.getMessage() + " host:" + citrixResourceBase.getHost().getUuid() + " pool: " - + pool.getHost() + pool.getPath(); - s_logger.warn(msg, e); - return new Answer(command, false, msg); - } - } else { - try { - final SR sr = citrixResourceBase.getStorageRepository(conn, pool.getUuid()); - final String srUuid = sr.getUuid(conn); - final String result = citrixResourceBase.callHostPluginPremium(conn, "setup_heartbeat_file", "host", citrixResourceBase.getHost().getUuid(), "sr", srUuid, "add", - "false"); - if (result == null || !result.split("#")[1].equals("0")) { - throw new CloudRuntimeException("Unable to remove heartbeat file entry for SR " + srUuid + " due to " + result); - } - return new Answer(command, true, "seccuss"); - } catch (final XenAPIException e) { - final String msg = "ModifyStoragePoolCommand remove XenAPIException:" + e.toString() + " host:" + citrixResourceBase.getHost().getUuid() + " pool: " - + pool.getHost() + pool.getPath(); - s_logger.warn(msg, e); - return new Answer(command, false, msg); - } catch (final Exception e) { - final String msg = "ModifyStoragePoolCommand remove XenAPIException:" + e.getMessage() + " 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/79d24ae2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java deleted file mode 100644 index d59dca3..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java +++ /dev/null @@ -1,37 +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.routing.NetworkElementCommand; -import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; -import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = NetworkElementCommand.class) -public final class CitrixNetworkElementCommandWrapper extends CommandWrapper<NetworkElementCommand, Answer, CitrixResourceBase> { - - @Override - public Answer execute(final NetworkElementCommand command, final CitrixResourceBase citrixResourceBase) { - final VirtualRoutingResource routingResource = citrixResourceBase.getVirtualRoutingResource(); - return routingResource.executeRequest(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/CitrixNetworkRulesSystemVmCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesSystemVmCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesSystemVmCommandWrapper.java deleted file mode 100644 index 3c2f5ef..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesSystemVmCommandWrapper.java +++ /dev/null @@ -1,47 +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.NetworkRulesSystemVmCommand; -import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; -import com.cloud.vm.VirtualMachine; -import com.xensource.xenapi.Connection; - -@ResourceWrapper(handles = NetworkRulesSystemVmCommand.class) -public final class CitrixNetworkRulesSystemVmCommandWrapper extends CommandWrapper<NetworkRulesSystemVmCommand, Answer, CitrixResourceBase> { - - @Override - public Answer execute(final NetworkRulesSystemVmCommand command, final CitrixResourceBase citrixResourceBase) { - boolean success = true; - final Connection conn = citrixResourceBase.getConnection(); - if (command.getType() != VirtualMachine.Type.User) { - - final String result = citrixResourceBase.callHostPlugin(conn, "vmops", "default_network_rules_systemvm", "vmName", command.getVmName()); - if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) { - success = false; - } - } - - return new Answer(command, success, ""); - } -} \ 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/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java deleted file mode 100644 index f19771f..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java +++ /dev/null @@ -1,46 +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.NetworkRulesVmSecondaryIpCommand; -import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; -import com.xensource.xenapi.Connection; - -@ResourceWrapper(handles = NetworkRulesVmSecondaryIpCommand.class) -public final class CitrixNetworkRulesVmSecondaryIpCommandWrapper extends CommandWrapper<NetworkRulesVmSecondaryIpCommand, Answer, CitrixResourceBase> { - - @Override - public Answer execute(final NetworkRulesVmSecondaryIpCommand command, final CitrixResourceBase citrixResourceBase) { - boolean success = true; - final Connection conn = citrixResourceBase.getConnection(); - - final String result = citrixResourceBase.callHostPlugin(conn, "vmops", "network_rules_vmSecondaryIp", "vmName", command.getVmName(), "vmMac", command.getVmMac(), - "vmSecIp", command.getVmSecIp(), "action", command.getAction()); - - if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) { - success = false; - } - - return new Answer(command, success, ""); - } -} \ 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/CitrixOvsCreateGreTunnelCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateGreTunnelCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateGreTunnelCommandWrapper.java deleted file mode 100644 index 93d6208..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateGreTunnelCommandWrapper.java +++ /dev/null @@ -1,69 +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.OvsCreateGreTunnelAnswer; -import com.cloud.agent.api.OvsCreateGreTunnelCommand; -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.Types.BadServerResponse; -import com.xensource.xenapi.Types.XenAPIException; - -@ResourceWrapper(handles = OvsCreateGreTunnelCommand.class) -public final class CitrixOvsCreateGreTunnelCommandWrapper extends CommandWrapper<OvsCreateGreTunnelCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixOvsCreateGreTunnelCommandWrapper.class); - - @Override - public Answer execute(final OvsCreateGreTunnelCommand command, final CitrixResourceBase citrixResourceBase) { - citrixResourceBase.setIsOvs(true); - - final Connection conn = citrixResourceBase.getConnection(); - String bridge = "unkonwn"; - try { - final Network nw = citrixResourceBase.setupvSwitchNetwork(conn); - bridge = nw.getBridge(conn); - - final String result = citrixResourceBase.callHostPlugin(conn, "ovsgre", "ovs_create_gre", "bridge", bridge, "remoteIP", command.getRemoteIp(), "greKey", - command.getKey(), "from", Long.toString(command.getFrom()), "to", Long.toString(command.getTo())); - final String[] res = result.split(":"); - if (res.length != 2 || res.length == 2 && res[1].equalsIgnoreCase("[]")) { - return new OvsCreateGreTunnelAnswer(command, false, result, citrixResourceBase.getHost().getIp(), bridge); - } else { - return new OvsCreateGreTunnelAnswer(command, true, result, citrixResourceBase.getHost().getIp(), bridge, Integer.parseInt(res[1])); - } - } catch (final BadServerResponse e) { - s_logger.error("An error occurred while creating a GRE tunnel to " + command.getRemoteIp() + " on host " + citrixResourceBase.getHost().getIp(), e); - } catch (final XenAPIException e) { - s_logger.error("An error occurred while creating a GRE tunnel to " + command.getRemoteIp() + " on host " + citrixResourceBase.getHost().getIp(), e); - } catch (final XmlRpcException e) { - s_logger.error("An error occurred while creating a GRE tunnel to " + command.getRemoteIp() + " on host " + citrixResourceBase.getHost().getIp(), e); - } - - return new OvsCreateGreTunnelAnswer(command, false, "EXCEPTION", citrixResourceBase.getHost().getIp(), bridge); - } -} \ 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/CitrixOvsCreateTunnelCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateTunnelCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateTunnelCommandWrapper.java deleted file mode 100644 index 14d57d8..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateTunnelCommandWrapper.java +++ /dev/null @@ -1,69 +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.OvsCreateTunnelAnswer; -import com.cloud.agent.api.OvsCreateTunnelCommand; -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; - -@ResourceWrapper(handles = OvsCreateTunnelCommand.class) -public final class CitrixOvsCreateTunnelCommandWrapper extends CommandWrapper<OvsCreateTunnelCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixOvsCreateTunnelCommandWrapper.class); - - @Override - public Answer execute(final OvsCreateTunnelCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - String bridge = "unknown"; - try { - final Network nw = citrixResourceBase.findOrCreateTunnelNetwork(conn, command.getNetworkName()); - if (nw == null) { - s_logger.debug("Error during bridge setup"); - return new OvsCreateTunnelAnswer(command, false, "Cannot create network", bridge); - } - - citrixResourceBase.configureTunnelNetwork(conn, command.getNetworkId(), command.getFrom(), command.getNetworkName()); - bridge = nw.getBridge(conn); - final String result = - citrixResourceBase.callHostPlugin(conn, "ovstunnel", "create_tunnel", "bridge", bridge, "remote_ip", command.getRemoteIp(), - "key", command.getKey().toString(), "from", - command.getFrom().toString(), "to", command.getTo().toString(), "cloudstack-network-id", - command.getNetworkUuid()); - final String[] res = result.split(":"); - - if (res.length == 2 && res[0].equalsIgnoreCase("SUCCESS")) { - return new OvsCreateTunnelAnswer(command, true, result, res[1], bridge); - } else { - return new OvsCreateTunnelAnswer(command, false, result, bridge); - } - } catch (final Exception e) { - s_logger.debug("Error during tunnel setup"); - s_logger.warn("Caught execption when creating ovs tunnel", e); - return new OvsCreateTunnelAnswer(command, false, e.getMessage(), bridge); - } - } -} \ 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/CitrixOvsDeleteFlowCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDeleteFlowCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDeleteFlowCommandWrapper.java deleted file mode 100644 index 8c782ee..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDeleteFlowCommandWrapper.java +++ /dev/null @@ -1,64 +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.OvsDeleteFlowCommand; -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.Types.BadServerResponse; -import com.xensource.xenapi.Types.XenAPIException; - -@ResourceWrapper(handles = OvsDeleteFlowCommand.class) -public final class CitrixOvsDeleteFlowCommandWrapper extends CommandWrapper<OvsDeleteFlowCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixOvsDeleteFlowCommandWrapper.class); - - @Override - public Answer execute(final OvsDeleteFlowCommand command, final CitrixResourceBase citrixResourceBase) { - citrixResourceBase.setIsOvs(true); - - final Connection conn = citrixResourceBase.getConnection(); - try { - final Network nw = citrixResourceBase.setupvSwitchNetwork(conn); - final String bridge = nw.getBridge(conn); - final String result = citrixResourceBase.callHostPlugin(conn, "ovsgre", "ovs_delete_flow", "bridge", bridge, "vmName", command.getVmName()); - - if (result.equalsIgnoreCase("SUCCESS")) { - return new Answer(command, true, "success to delete flows for " + command.getVmName()); - } else { - return new Answer(command, false, result); - } - } catch (final BadServerResponse e) { - s_logger.error("Failed to delete flow", e); - } catch (final XenAPIException e) { - s_logger.error("Failed to delete flow", e); - } catch (final XmlRpcException e) { - s_logger.error("Failed to delete flow", e); - } - return new Answer(command, false, "failed to delete flow for " + command.getVmName()); - } -} \ 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/CitrixOvsDestroyBridgeCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyBridgeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyBridgeCommandWrapper.java deleted file mode 100644 index 62739fb..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyBridgeCommandWrapper.java +++ /dev/null @@ -1,55 +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.OvsDestroyBridgeCommand; -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; - -@ResourceWrapper(handles = OvsDestroyBridgeCommand.class) -public final class CitrixOvsDestroyBridgeCommandWrapper extends CommandWrapper<OvsDestroyBridgeCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixOvsDestroyBridgeCommandWrapper.class); - - @Override - public Answer execute(final OvsDestroyBridgeCommand command, final CitrixResourceBase citrixResourceBase) { - try { - final Connection conn = citrixResourceBase.getConnection(); - - final Network nw = citrixResourceBase.findOrCreateTunnelNetwork(conn, command.getBridgeName()); - citrixResourceBase.cleanUpTmpDomVif(conn, nw); - - citrixResourceBase.destroyTunnelNetwork(conn, nw, command.getHostId()); - - s_logger.debug("OVS Bridge destroyed"); - - return new Answer(command, true, null); - } catch (final Exception e) { - s_logger.warn("caught execption when destroying ovs bridge", e); - return new Answer(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/CitrixOvsDestroyTunnelCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyTunnelCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyTunnelCommandWrapper.java deleted file mode 100644 index 543c2f5..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyTunnelCommandWrapper.java +++ /dev/null @@ -1,60 +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.OvsDestroyTunnelCommand; -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; - -@ResourceWrapper(handles = OvsDestroyTunnelCommand.class) -public final class CitrixOvsDestroyTunnelCommandWrapper extends CommandWrapper<OvsDestroyTunnelCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixOvsDestroyTunnelCommandWrapper.class); - - @Override - public Answer execute(final OvsDestroyTunnelCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - try { - final Network nw = citrixResourceBase.findOrCreateTunnelNetwork(conn, command.getBridgeName()); - if (nw == null) { - s_logger.warn("Unable to find tunnel network for GRE key:" + command.getBridgeName()); - return new Answer(command, false, "No network found"); - } - - final String bridge = nw.getBridge(conn); - final String result = citrixResourceBase.callHostPlugin(conn, "ovstunnel", "destroy_tunnel", "bridge", bridge, "in_port", command.getInPortName()); - - if (result.equalsIgnoreCase("SUCCESS")) { - return new Answer(command, true, result); - } else { - return new Answer(command, false, result); - } - } catch (final Exception e) { - s_logger.warn("caught execption when destroy ovs tunnel", e); - return new Answer(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/CitrixOvsFetchInterfaceCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsFetchInterfaceCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsFetchInterfaceCommandWrapper.java deleted file mode 100644 index 8be62db..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsFetchInterfaceCommandWrapper.java +++ /dev/null @@ -1,73 +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.OvsFetchInterfaceAnswer; -import com.cloud.agent.api.OvsFetchInterfaceCommand; -import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.hypervisor.xenserver.resource.XsLocalNetwork; -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.PIF; -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.XenAPIException; - -@ResourceWrapper(handles = OvsFetchInterfaceCommand.class) -public final class CitrixOvsFetchInterfaceCommandWrapper extends CommandWrapper<OvsFetchInterfaceCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixOvsFetchInterfaceCommandWrapper.class); - - @Override - public Answer execute(final OvsFetchInterfaceCommand command, final CitrixResourceBase citrixResourceBase) { - String label = command.getLabel(); - //FIXME: this is a tricky to pass the network checking in XCP. I temporary get default label from Host. - if (citrixResourceBase.isXcp()) { - label = citrixResourceBase.getLabel(); - } - s_logger.debug("Will look for network with name-label:" + label + " on host " + citrixResourceBase.getHost().getIp()); - final Connection conn = citrixResourceBase.getConnection(); - try { - final XsLocalNetwork nw = citrixResourceBase.getNetworkByName(conn, label); - if(nw == null) { - throw new CloudRuntimeException("Unable to locate the network with name-label: " + label + " on host: " + citrixResourceBase.getHost().getIp()); - } - s_logger.debug("Network object:" + nw.getNetwork().getUuid(conn)); - final PIF pif = nw.getPif(conn); - final PIF.Record pifRec = pif.getRecord(conn); - s_logger.debug("PIF object:" + pifRec.uuid + "(" + pifRec.device + ")"); - return new OvsFetchInterfaceAnswer(command, true, "Interface " + pifRec.device + " retrieved successfully", pifRec.IP, pifRec.netmask, pifRec.MAC); - } catch (final BadServerResponse e) { - s_logger.error("An error occurred while fetching the interface for " + label + " on host " + citrixResourceBase.getHost().getIp(), e); - return new OvsFetchInterfaceAnswer(command, false, "EXCEPTION:" + e.getMessage()); - } catch (final XenAPIException e) { - s_logger.error("An error occurred while fetching the interface for " + label + " on host " + citrixResourceBase.getHost().getIp(), e); - return new OvsFetchInterfaceAnswer(command, false, "EXCEPTION:" + e.getMessage()); - } catch (final XmlRpcException e) { - s_logger.error("An error occurred while fetching the interface for " + label + " on host " + citrixResourceBase.getHost().getIp(), e); - return new OvsFetchInterfaceAnswer(command, false, "EXCEPTION:" + 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/CitrixOvsSetTagAndFlowCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetTagAndFlowCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetTagAndFlowCommandWrapper.java deleted file mode 100644 index 087453d..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetTagAndFlowCommandWrapper.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 org.apache.log4j.Logger; -import org.apache.xmlrpc.XmlRpcException; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.OvsSetTagAndFlowAnswer; -import com.cloud.agent.api.OvsSetTagAndFlowCommand; -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.Types.BadServerResponse; -import com.xensource.xenapi.Types.XenAPIException; - -@ResourceWrapper(handles = OvsSetTagAndFlowCommand.class) -public final class CitrixOvsSetTagAndFlowCommandWrapper extends CommandWrapper<OvsSetTagAndFlowCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixOvsSetTagAndFlowCommandWrapper.class); - - @Override - public Answer execute(final OvsSetTagAndFlowCommand command, final CitrixResourceBase citrixResourceBase) { - citrixResourceBase.setIsOvs(true); - - final Connection conn = citrixResourceBase.getConnection(); - try { - final Network nw = citrixResourceBase.setupvSwitchNetwork(conn); - final String bridge = nw.getBridge(conn); - - /* - * If VM is domainRouter, this will try to set flow and tag on its - * none guest network nic. don't worry, it will fail silently at - * host plugin side - */ - final String result = citrixResourceBase.callHostPlugin(conn, "ovsgre", "ovs_set_tag_and_flow", "bridge", bridge, "vmName", command.getVmName(), "tag", - command.getTag(), "vlans", command.getVlans(), "seqno", command.getSeqNo()); - s_logger.debug("set flow for " + command.getVmName() + " " + result); - - if (result != null && result.equalsIgnoreCase("SUCCESS")) { - return new OvsSetTagAndFlowAnswer(command, true, result); - } else { - return new OvsSetTagAndFlowAnswer(command, false, result); - } - } catch (final BadServerResponse e) { - s_logger.error("Failed to set tag and flow", e); - } catch (final XenAPIException e) { - s_logger.error("Failed to set tag and flow", e); - } catch (final XmlRpcException e) { - s_logger.error("Failed to set tag and flow", e); - } - - return new OvsSetTagAndFlowAnswer(command, false, "EXCEPTION"); - } -} \ 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/CitrixOvsSetupBridgeCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetupBridgeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetupBridgeCommandWrapper.java deleted file mode 100644 index 20c6abc..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetupBridgeCommandWrapper.java +++ /dev/null @@ -1,47 +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.OvsSetupBridgeCommand; -import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; -import com.xensource.xenapi.Connection; - -@ResourceWrapper(handles = OvsSetupBridgeCommand.class) -public final class CitrixOvsSetupBridgeCommandWrapper extends CommandWrapper<OvsSetupBridgeCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixOvsSetupBridgeCommandWrapper.class); - - @Override - public Answer execute(final OvsSetupBridgeCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - - citrixResourceBase.findOrCreateTunnelNetwork(conn, command.getBridgeName()); - citrixResourceBase.configureTunnelNetwork(conn, command.getNetworkId(), command.getHostId(), command.getBridgeName()); - - s_logger.debug("OVS Bridge configured"); - - return new Answer(command, true, null); - } -} \ 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/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java deleted file mode 100644 index 4b0a66d..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java +++ /dev/null @@ -1,59 +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.OvsVpcPhysicalTopologyConfigCommand; -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; - -@ResourceWrapper(handles = OvsVpcPhysicalTopologyConfigCommand.class) -public final class CitrixOvsVpcPhysicalTopologyConfigCommandWrapper extends CommandWrapper<OvsVpcPhysicalTopologyConfigCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.class); - - @Override - public Answer execute(final OvsVpcPhysicalTopologyConfigCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - try { - final Network nw = citrixResourceBase.findOrCreateTunnelNetwork(conn, command.getBridgeName()); - final String bridgeName = nw.getBridge(conn); - final long sequenceNo = command.getSequenceNumber(); - - final String result = citrixResourceBase.callHostPlugin(conn, "ovstunnel", "configure_ovs_bridge_for_network_topology", "bridge", - bridgeName, "config", command.getVpcConfigInJson(), "host-id", ((Long)command.getHostId()).toString(), - "seq-no", Long.toString(sequenceNo)); - - if (result.startsWith("SUCCESS")) { - return new Answer(command, true, result); - } else { - return new Answer(command, false, result); - } - } catch (final Exception e) { - s_logger.warn("caught exception while updating host with latest VPC topology", e); - return new Answer(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/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java deleted file mode 100644 index de29dc6..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java +++ /dev/null @@ -1,59 +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.OvsVpcRoutingPolicyConfigCommand; -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; - -@ResourceWrapper(handles = OvsVpcRoutingPolicyConfigCommand.class) -public final class CitrixOvsVpcRoutingPolicyConfigCommandWrapper extends CommandWrapper<OvsVpcRoutingPolicyConfigCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixOvsVpcRoutingPolicyConfigCommandWrapper.class); - - @Override - public Answer execute(final OvsVpcRoutingPolicyConfigCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - try { - final Network nw = citrixResourceBase.findOrCreateTunnelNetwork(conn, command.getBridgeName()); - final String bridgeName = nw.getBridge(conn); - final long sequenceNo = command.getSequenceNumber(); - - final String result = citrixResourceBase.callHostPlugin(conn, "ovstunnel", "configure_ovs_bridge_for_routing_policies", "bridge", - bridgeName, "host-id", ((Long)command.getHostId()).toString(), "config", - command.getVpcConfigInJson(), "seq-no", Long.toString(sequenceNo)); - - if (result.startsWith("SUCCESS")) { - return new Answer(command, true, result); - } else { - return new Answer(command, false, result); - } - } catch (final Exception e) { - s_logger.warn("caught exception while updating host with latest routing policies", e); - return new Answer(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/CitrixPerformanceMonitorCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPerformanceMonitorCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPerformanceMonitorCommandWrapper.java deleted file mode 100644 index e3f51ce..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPerformanceMonitorCommandWrapper.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; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.PerformanceMonitorAnswer; -import com.cloud.agent.api.PerformanceMonitorCommand; -import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; -import com.xensource.xenapi.Connection; - -@ResourceWrapper(handles = PerformanceMonitorCommand.class) -public final class CitrixPerformanceMonitorCommandWrapper extends CommandWrapper<PerformanceMonitorCommand, Answer, CitrixResourceBase> { - - @Override - public Answer execute(final PerformanceMonitorCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - final String perfMon = citrixResourceBase.getPerfMon(conn, command.getParams(), command.getWait()); - if (perfMon == null) { - return new PerformanceMonitorAnswer(command, false, perfMon); - } else { - return new PerformanceMonitorAnswer(command, true, perfMon); - } - } -} \ 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/CitrixPingTestCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java deleted file mode 100644 index caf0242..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java +++ /dev/null @@ -1,49 +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.PingTestCommand; -import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; -import com.xensource.xenapi.Connection; - -@ResourceWrapper(handles = PingTestCommand.class) -public final class CitrixPingTestCommandWrapper extends CommandWrapper<PingTestCommand, Answer, CitrixResourceBase> { - - @Override - public Answer execute(final PingTestCommand command, final CitrixResourceBase citrixResourceBase) { - final Connection conn = citrixResourceBase.getConnection(); - boolean result = false; - final String computingHostIp = command.getComputingHostIp(); - - if (computingHostIp != null) { - result = citrixResourceBase.doPingTest(conn, computingHostIp); - } else { - result = citrixResourceBase.doPingTest(conn, command.getRouterIp(), command.getPrivateIp()); - } - - if (!result) { - return new Answer(command, false, "PingTestCommand failed"); - } - return new Answer(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/CitrixPlugNicCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPlugNicCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPlugNicCommandWrapper.java deleted file mode 100644 index b233bac..0000000 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPlugNicCommandWrapper.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 java.util.Set; - -import org.apache.log4j.Logger; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.PlugNicAnswer; -import com.cloud.agent.api.PlugNicCommand; -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.VIF; -import com.xensource.xenapi.VM; - -@ResourceWrapper(handles = PlugNicCommand.class) -public final class CitrixPlugNicCommandWrapper extends CommandWrapper<PlugNicCommand, Answer, CitrixResourceBase> { - - private static final Logger s_logger = Logger.getLogger(CitrixPlugNicCommandWrapper.class); - - @Override - public Answer execute(final PlugNicCommand 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 PlugNicAnswer(command, false, "Can not find VM " + vmName); - } - final VM vm = vms.iterator().next(); - final NicTO nic = command.getNic(); - - String mac = nic.getMac(); - final Set<VIF> routerVIFs = vm.getVIFs(conn); - mac = mac.trim(); - - int counter = 0; - for (final VIF vif : routerVIFs) { - final String lmac = vif.getMAC(conn); - if (lmac.trim().equals(mac)) { - counter++; - } - } - // We allow 2 routers with the same mac. It's needed for the redundant vpc routers. - // [FIXME] Find a way to identify the type of the router or if it's - // redundant. - if (counter > 2) { - final String msg = " Plug Nic failed due to a VIF with the same mac " + nic.getMac() + " exists in more than 2 routers."; - s_logger.error(msg); - return new PlugNicAnswer(command, false, msg); - } - - // Wilder Rodrigues - replaced this code with the code above. - // VIF vif = getVifByMac(conn, vm, nic.getMac()); - // if (vif != null) { - // final String msg = " Plug Nic failed due to a VIF with the same mac " + nic.getMac() + " exists"; - // s_logger.warn(msg); - // return new PlugNicAnswer(cmd, false, msg); - // } - - final String deviceId = citrixResourceBase.getLowestAvailableVIFDeviceNum(conn, vm); - nic.setDeviceId(Integer.parseInt(deviceId)); - final VIF vif = citrixResourceBase.createVif(conn, vmName, vm, null, nic); - // vif = createVif(conn, vmName, vm, null, nic); - vif.plug(conn); - return new PlugNicAnswer(command, true, "success"); - } catch (final Exception e) { - final String msg = " Plug Nic failed due to " + e.toString(); - s_logger.error(msg, e); - return new PlugNicAnswer(command, false, msg); - } - } -} \ No newline at end of file
