diff --git a/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java b/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java index c2ca11b741b..e36ca28d0e3 100644 --- a/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java +++ b/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java @@ -28,6 +28,10 @@ public class SetupGuestNetworkCommand extends NetworkElementCommand{ boolean add = true; NicTO nic; + public NicTO getNic() { + return nic; + } + @Override public boolean executeInSequence() { return true; diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index ac39b61956b..ce709963af0 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -7017,8 +7017,47 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe * @return */ private SetupGuestNetworkAnswer execute(SetupGuestNetworkCommand cmd) { - // TODO Auto-generated method stub - return null; + Connection conn = getConnection(); + NicTO nic = cmd.getNic(); + String domrIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); + String domrGIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP); + String domrName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + try { + Set vms = VM.getByNameLabel(conn, domrName); + if ( vms == null || vms.isEmpty() ) { + return new SetupGuestNetworkAnswer(cmd, false, "Can not find VM " + domrName); + } + VM vm = vms.iterator().next(); + String mac = nic.getMac(); + VIF domrVif = null; + for ( VIF vif : vm.getVIFs(conn)) { + String lmac = vif.getMAC(conn); + if ( lmac.equals(mac) ) { + domrVif = vif; + break; + } + } + if ( domrVif == null ) { + return new SetupGuestNetworkAnswer(cmd, false, "Can not find vif with mac " + mac + " for VM " + domrName); + } + + String args = "guestnw.sh " + domrIP + " -C"; + String dev = "eth" + domrVif.getDevice(conn); + args += " -d " + dev; + args += " -i " + domrGIP; + args += " -g " + nic.getGateway(); + args += " -m " + Long.toString(NetUtils.getCidrSize(nic.getNetmask())); + args += " -s " + nic.getDns1(); + String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args); + if (result == null || result.isEmpty()) { + return new SetupGuestNetworkAnswer(cmd, false, "creating guest network failed due to " + ((result == null)? "null":result)); + } + return new SetupGuestNetworkAnswer(cmd, true, "success"); + } catch (Exception e) { + String msg = " UnPlug Nic failed due to " + e.toString(); + s_logger.warn(msg, e); + return new SetupGuestNetworkAnswer(cmd, false, msg); + } } diff --git a/wscript b/wscript index 2f5219c2363..55a487809a6 100644 --- a/wscript +++ b/wscript @@ -4,7 +4,7 @@ # the following two variables are used by the target "waf dist" # if you change 'em here, you need to change it also in cloud.spec, add a %changelog entry there, and add an entry in debian/changelog -VERSION = '3.0.3.2012-06-06T00:22:14Z' +VERSION = '3.0.3.2012-06-06T01:46:43Z' APPNAME = 'cloud' import shutil,os