mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
VPC, implement plug/unplug nic
This commit is contained in:
parent
72974831a0
commit
daf1aa4b92
@ -6973,8 +6973,31 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private UnPlugNicAnswer execute(UnPlugNicCommand cmd) {
|
private UnPlugNicAnswer execute(UnPlugNicCommand cmd) {
|
||||||
// TODO Auto-generated method stub
|
Connection conn = getConnection();
|
||||||
return null;
|
VirtualMachineTO vmto = cmd.getVirtualMachine();
|
||||||
|
String vmName = vmto.getName();
|
||||||
|
try {
|
||||||
|
Set<VM> vms = VM.getByNameLabel(conn, vmName);
|
||||||
|
if ( vms == null || vms.isEmpty() ) {
|
||||||
|
return new UnPlugNicAnswer(cmd, false, "Can not find VM " + vmName);
|
||||||
|
}
|
||||||
|
VM vm = vms.iterator().next();
|
||||||
|
NicTO nic = cmd.getNic();
|
||||||
|
String mac = nic.getMac();
|
||||||
|
for ( VIF vif : vm.getVIFs(conn)) {
|
||||||
|
String lmac = vif.getMAC(conn);
|
||||||
|
if ( lmac.equals(mac) ) {
|
||||||
|
vif.unplug(conn);
|
||||||
|
vif.destroy(conn);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new UnPlugNicAnswer(cmd, true, "success");
|
||||||
|
} catch (Exception e) {
|
||||||
|
String msg = " UnPlug Nic failed due to " + e.toString();
|
||||||
|
s_logger.warn(msg, e);
|
||||||
|
return new UnPlugNicAnswer(cmd, false, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6982,8 +7005,24 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private PlugNicAnswer execute(PlugNicCommand cmd) {
|
private PlugNicAnswer execute(PlugNicCommand cmd) {
|
||||||
// TODO Auto-generated method stub
|
Connection conn = getConnection();
|
||||||
return null;
|
VirtualMachineTO vmto = cmd.getVirtualMachine();
|
||||||
|
String vmName = vmto.getName();
|
||||||
|
try {
|
||||||
|
Set<VM> vms = VM.getByNameLabel(conn, vmName);
|
||||||
|
if ( vms == null || vms.isEmpty() ) {
|
||||||
|
return new PlugNicAnswer(cmd, false, "Can not find VM " + vmName);
|
||||||
|
}
|
||||||
|
VM vm = vms.iterator().next();
|
||||||
|
NicTO nic = cmd.getNic();
|
||||||
|
VIF vif = createVif(conn, vmName, vm, nic);
|
||||||
|
vif.plug(conn);
|
||||||
|
return new PlugNicAnswer(cmd, true, "success");
|
||||||
|
} catch (Exception e) {
|
||||||
|
String msg = " Plug Nic failed due to " + e.toString();
|
||||||
|
s_logger.warn(msg, e);
|
||||||
|
return new PlugNicAnswer(cmd, false, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -10,8 +10,6 @@ COMMIT
|
|||||||
-A INPUT -d 224.0.0.18/32 -j ACCEPT
|
-A INPUT -d 224.0.0.18/32 -j ACCEPT
|
||||||
-A INPUT -d 225.0.0.50/32 -j ACCEPT
|
-A INPUT -d 225.0.0.50/32 -j ACCEPT
|
||||||
-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||||
-A INPUT -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
|
||||||
-A INPUT -i eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
|
||||||
-A INPUT -p icmp -j ACCEPT
|
-A INPUT -p icmp -j ACCEPT
|
||||||
-A INPUT -i lo -j ACCEPT
|
-A INPUT -i lo -j ACCEPT
|
||||||
-A INPUT -i eth0 -p tcp -m state --state NEW --dport 3922 -j ACCEPT
|
-A INPUT -i eth0 -p tcp -m state --state NEW --dport 3922 -j ACCEPT
|
||||||
|
|||||||
2
wscript
2
wscript
@ -4,7 +4,7 @@
|
|||||||
# the following two variables are used by the target "waf dist"
|
# 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
|
# 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-05T18:30:03Z'
|
VERSION = '3.0.3.2012-06-05T22:35:08Z'
|
||||||
APPNAME = 'cloud'
|
APPNAME = 'cloud'
|
||||||
|
|
||||||
import shutil,os
|
import shutil,os
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user