mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch 'master' of git.cloud.com:/var/lib/git/cloudstack-oss
Conflicts: client/tomcatconf/commands.properties.in core/src/com/cloud/vm/UserVmVO.java server/src/com/cloud/configuration/DefaultComponentLibrary.java server/src/com/cloud/vm/UserVmManagerImpl.java
This commit is contained in:
commit
83b3580c32
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
build/replace.properties
|
||||
build/build.number
|
||||
bin/
|
||||
cloudstack-proprietary/
|
||||
|
||||
81
agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in
Normal file
81
agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in
Normal file
@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
|
||||
# chkconfig: 35 99 10
|
||||
# description: Cloud Agent
|
||||
|
||||
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
|
||||
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
whatami=cloud-agent
|
||||
|
||||
# set environment variables
|
||||
|
||||
SHORTNAME="$whatami"
|
||||
PIDFILE=@PIDDIR@/"$whatami".pid
|
||||
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
|
||||
LOGFILE=@AGENTLOG@
|
||||
PROGNAME="Cloud Agent"
|
||||
|
||||
unset OPTIONS
|
||||
[ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME"
|
||||
DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
|
||||
PROG=@LIBEXECDIR@/agent-runner
|
||||
|
||||
start() {
|
||||
echo -n $"Starting $PROGNAME: "
|
||||
if hostname --fqdn >/dev/null 2>&1 ; then
|
||||
daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \
|
||||
-n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
|
||||
RETVAL=$?
|
||||
echo
|
||||
else
|
||||
failure
|
||||
echo
|
||||
echo The host name does not resolve properly to an IP address. Cannot start "$PROGNAME". > /dev/stderr
|
||||
RETVAL=9
|
||||
fi
|
||||
[ $RETVAL = 0 ] && touch ${LOCKFILE}
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $PROGNAME: "
|
||||
killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
|
||||
}
|
||||
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status -p ${PIDFILE} $SHORTNAME
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
sleep 3
|
||||
start
|
||||
;;
|
||||
condrestart)
|
||||
if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
|
||||
stop
|
||||
sleep 3
|
||||
start
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
|
||||
RETVAL=3
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
|
||||
@ -77,8 +77,7 @@ import com.cloud.utils.script.Script;
|
||||
*
|
||||
**/
|
||||
public class Agent implements HandlerFactory, IAgentControl {
|
||||
private static final Logger s_logger = Logger.getLogger(Agent.class.getName());
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(Agent.class.getName());
|
||||
public enum ExitStatus {
|
||||
Normal(0), // Normal status = 0.
|
||||
Upgrade(65), // Exiting for upgrade.
|
||||
|
||||
@ -36,7 +36,7 @@ public class LibvirtCapXMLParser extends LibvirtXMLParser {
|
||||
private boolean _osType = false;
|
||||
private boolean _domainTypeKVM = false;
|
||||
private boolean _emulatorFlag = false;
|
||||
private String _emulator ;
|
||||
private final StringBuffer _emulator = new StringBuffer() ;
|
||||
private final StringBuffer _capXML = new StringBuffer();
|
||||
private static final Logger s_logger = Logger.getLogger(LibvirtCapXMLParser.class);
|
||||
private final ArrayList<String> guestOsTypes = new ArrayList<String>();
|
||||
@ -53,6 +53,7 @@ public class LibvirtCapXMLParser extends LibvirtXMLParser {
|
||||
_domainTypeKVM = false;
|
||||
} else if (qName.equalsIgnoreCase("emulator")) {
|
||||
_emulatorFlag = false;
|
||||
|
||||
} else if (_host) {
|
||||
_capXML.append("<").append("/").append(qName).append(">");
|
||||
}
|
||||
@ -65,7 +66,7 @@ public class LibvirtCapXMLParser extends LibvirtXMLParser {
|
||||
} else if (_osType) {
|
||||
guestOsTypes.add(new String(ch, start, length));
|
||||
} else if (_emulatorFlag) {
|
||||
_emulator = new String(ch, start, length);
|
||||
_emulator.append(ch, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,6 +91,7 @@ public class LibvirtCapXMLParser extends LibvirtXMLParser {
|
||||
}
|
||||
} else if (qName.equalsIgnoreCase("emulator") && _domainTypeKVM) {
|
||||
_emulatorFlag = true;
|
||||
_emulator.delete(0, _emulator.length());
|
||||
} else if (_host) {
|
||||
_capXML.append("<").append(qName);
|
||||
for (int i=0; i < attributes.getLength(); i++) {
|
||||
@ -120,7 +122,7 @@ public class LibvirtCapXMLParser extends LibvirtXMLParser {
|
||||
}
|
||||
|
||||
public String getEmulator() {
|
||||
return _emulator;
|
||||
return _emulator.toString();
|
||||
}
|
||||
|
||||
public static void main(String [] args) {
|
||||
|
||||
@ -109,6 +109,8 @@ import com.cloud.agent.api.MirrorCommand;
|
||||
import com.cloud.agent.api.ModifySshKeysCommand;
|
||||
import com.cloud.agent.api.ModifyStoragePoolAnswer;
|
||||
import com.cloud.agent.api.ModifyStoragePoolCommand;
|
||||
import com.cloud.agent.api.NetworkUsageAnswer;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.PingRoutingCommand;
|
||||
import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
|
||||
@ -1110,6 +1112,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
return _virtRouterResource.executeRequest(cmd);
|
||||
} else if (cmd instanceof CheckSshCommand) {
|
||||
return execute((CheckSshCommand) cmd);
|
||||
} else if (cmd instanceof NetworkUsageCommand) {
|
||||
return execute((NetworkUsageCommand) cmd);
|
||||
} else {
|
||||
s_logger.warn("Unsupported command ");
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
@ -2114,19 +2118,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
}
|
||||
long totMem = Long.parseLong(totMemparser.getLine());
|
||||
|
||||
double rx = 0.0;
|
||||
OutputInterpreter.OneLineParser rxParser = new OutputInterpreter.OneLineParser();
|
||||
result = executeBashScript("cat /sys/class/net/" + _publicBridgeName + "/statistics/rx_bytes", rxParser);
|
||||
if (result == null && rxParser.getLine() != null) {
|
||||
rx = Double.parseDouble(rxParser.getLine())/1000;
|
||||
}
|
||||
|
||||
double tx = 0.0;
|
||||
OutputInterpreter.OneLineParser txParser = new OutputInterpreter.OneLineParser();
|
||||
result = executeBashScript("cat /sys/class/net/" + _publicBridgeName + "/statistics/tx_bytes", txParser);
|
||||
if (result == null && txParser.getLine() != null) {
|
||||
tx = Double.parseDouble(txParser.getLine())/1000;
|
||||
}
|
||||
Pair<Double, Double> nicStats = getNicStats(_publicBridgeName);
|
||||
|
||||
int numCpus = 0;
|
||||
try {
|
||||
@ -2136,9 +2128,29 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
|
||||
}
|
||||
|
||||
HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, rx, tx, "host", totMem, freeMem, 0, 0);
|
||||
HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, nicStats.first()/1000, nicStats.second()/1000, "host", totMem, freeMem, 0, 0);
|
||||
return new GetHostStatsAnswer(cmd, hostStats);
|
||||
}
|
||||
|
||||
private Answer execute(NetworkUsageCommand cmd) {
|
||||
String vmName = cmd.getDomRName();
|
||||
try {
|
||||
Domain dm = getDomain(vmName);
|
||||
LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser();
|
||||
String xml = dm.getXMLDesc(0);
|
||||
parser.parseDomainXML(xml);
|
||||
List<String> nics = parser.getInterfaces();
|
||||
if (nics.size() != 3) {
|
||||
return new Answer(cmd, false, vmName + " doesn't have public nic");
|
||||
}
|
||||
String pubNic = nics.get(2);
|
||||
Pair<Double, Double> nicStats = getNicStats(pubNic);
|
||||
/*Note: received means bytes received by all the vms, but from host kernel's pov, it's tx*/
|
||||
return new NetworkUsageAnswer(cmd, "", nicStats.first().longValue(), nicStats.second().longValue());
|
||||
} catch (LibvirtException e) {
|
||||
return new Answer(cmd, false, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private Answer execute(RebootCommand cmd) {
|
||||
Long bytesReceived = null;
|
||||
@ -3003,7 +3015,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
long speed = 0;
|
||||
long cpus = 0;
|
||||
long ram = 0;
|
||||
String osType = null;
|
||||
String cap = null;
|
||||
try {
|
||||
final NodeInfo hosts = _conn.nodeInfo();
|
||||
|
||||
@ -3016,17 +3028,21 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
for(String s : oss) {
|
||||
/*Even host supports guest os type more than hvm, we only report hvm to management server*/
|
||||
if (s.equalsIgnoreCase("hvm")) {
|
||||
osType = "hvm";
|
||||
cap = "hvm";
|
||||
}
|
||||
}
|
||||
} catch (LibvirtException e) {
|
||||
|
||||
}
|
||||
|
||||
if (isSnapshotSupported()) {
|
||||
cap = cap + ",snapshot";
|
||||
}
|
||||
|
||||
info.add((int)cpus);
|
||||
info.add(speed);
|
||||
info.add(ram);
|
||||
info.add(osType);
|
||||
info.add(cap);
|
||||
long dom0ram = Math.min(ram/10, 768*1024*1024L);//save a maximum of 10% of system ram or 768M
|
||||
dom0ram = Math.max(dom0ram, _dom0MinMem);
|
||||
info.add(dom0ram);
|
||||
@ -3270,6 +3286,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
if (f.exists()) {
|
||||
return "/usr/bin/cloud-qemu-system-x86_64";
|
||||
} else {
|
||||
f = new File("/usr/libexec/cloud-qemu-kvm");
|
||||
if (f.exists()) {
|
||||
return "/usr/libexec/cloud-qemu-kvm";
|
||||
}
|
||||
|
||||
if (_conn == null) {
|
||||
return null;
|
||||
}
|
||||
@ -3841,5 +3862,37 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
}
|
||||
return states;
|
||||
}
|
||||
|
||||
/*online snapshot supported by enhanced qemu-kvm*/
|
||||
private boolean isSnapshotSupported() {
|
||||
File f =new File("/usr/bin/cloud-qemu-system-x86_64");
|
||||
if (f.exists()) {
|
||||
return true;
|
||||
} else {
|
||||
f = new File("/usr/libexec/cloud-qemu-kvm");
|
||||
if (f.exists()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Pair<Double, Double> getNicStats(String nicName) {
|
||||
double rx = 0.0;
|
||||
OutputInterpreter.OneLineParser rxParser = new OutputInterpreter.OneLineParser();
|
||||
String result = executeBashScript("cat /sys/class/net/" + nicName + "/statistics/rx_bytes", rxParser);
|
||||
if (result == null && rxParser.getLine() != null) {
|
||||
rx = Double.parseDouble(rxParser.getLine());
|
||||
}
|
||||
|
||||
double tx = 0.0;
|
||||
OutputInterpreter.OneLineParser txParser = new OutputInterpreter.OneLineParser();
|
||||
result = executeBashScript("cat /sys/class/net/" + nicName + "/statistics/tx_bytes", txParser);
|
||||
if (result == null && txParser.getLine() != null) {
|
||||
tx = Double.parseDouble(txParser.getLine());
|
||||
}
|
||||
|
||||
return new Pair<Double, Double>(rx, tx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -38,7 +38,6 @@ public class VirtualMachineTO {
|
||||
String bootArgs;
|
||||
String[] bootupScripts;
|
||||
boolean rebootOnCrash;
|
||||
Monitor monitor;
|
||||
|
||||
VolumeTO[] disks;
|
||||
NicTO[] nics;
|
||||
@ -70,14 +69,6 @@ public class VirtualMachineTO {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Monitor getMonitor() {
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public void setMonitor(Monitor monitor) {
|
||||
this.monitor = monitor;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@ -187,26 +178,4 @@ public class VirtualMachineTO {
|
||||
public void setNics(NicTO[] nics) {
|
||||
this.nics = nics;
|
||||
}
|
||||
|
||||
public static interface Monitor {
|
||||
|
||||
}
|
||||
|
||||
public static class SshMonitor implements Monitor {
|
||||
String ip;
|
||||
int port;
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public SshMonitor(String ip, int port) {
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,9 +9,6 @@ import java.lang.annotation.Target;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({TYPE})
|
||||
public @interface Implementation {
|
||||
// String createMethod() default "";
|
||||
// String method() default "";
|
||||
// Class<?> manager() default ManagementServer.class;
|
||||
Class<?> responseObject();
|
||||
String description() default "";
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ public class AddHostCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the host")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=false, description="hypervisor type of the host")
|
||||
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="hypervisor type of the host")
|
||||
private String hypervisor;
|
||||
|
||||
|
||||
|
||||
@ -40,8 +40,7 @@ import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.StringUtils;
|
||||
|
||||
//FIXME - add description
|
||||
@Implementation(responseObject=IngressRuleResponse.class) @SuppressWarnings("rawtypes")
|
||||
@Implementation(responseObject=IngressRuleResponse.class, description="Authorizes a particular ingress rule for this security group") @SuppressWarnings("rawtypes")
|
||||
public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(AuthorizeSecurityGroupIngressCmd.class.getName());
|
||||
|
||||
@ -54,40 +53,31 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
|
||||
@Parameter(name=ApiConstants.PROTOCOL, type=CommandType.STRING, description="TCP is default. UDP is the other supported protocol")
|
||||
private String protocol;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.START_PORT, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.START_PORT, type=CommandType.INTEGER, description="start port for this ingress rule")
|
||||
private Integer startPort;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.END_PORT, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.END_PORT, type=CommandType.INTEGER, description="end port for this ingress rule")
|
||||
private Integer endPort;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.ICMP_TYPE, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.ICMP_TYPE, type=CommandType.INTEGER, description="type of the icmp message being sent")
|
||||
private Integer icmpType;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.ICMP_CODE, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.ICMP_CODE, type=CommandType.INTEGER, description="error code for this icmp message")
|
||||
private Integer icmpCode;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, required=true)
|
||||
@Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, required=true, description="the security group name")
|
||||
private String securityGroupName;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.CIDR_LIST, type=CommandType.LIST, collectionType=CommandType.STRING)
|
||||
@Parameter(name=ApiConstants.CIDR_LIST, type=CommandType.LIST, collectionType=CommandType.STRING, description="the cidr list associated")
|
||||
private List cidrList;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.USER_SECURITY_GROUP_LIST, type=CommandType.MAP)
|
||||
@Parameter(name=ApiConstants.USER_SECURITY_GROUP_LIST, type=CommandType.MAP, description="user to security group mapping")
|
||||
private Map userSecurityGroupList;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING)
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the security group. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG)
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the security group. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
|
||||
|
||||
@ -65,14 +65,17 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the ID or VID of the VLAN. Default is an \"untagged\" VLAN.")
|
||||
private String vlan;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the VLAN. If VLAN is Zone wide, this parameter should be ommited")
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the network")
|
||||
private String accountName;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a VLAN")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a network")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network offering supports vlans")
|
||||
private Boolean isShared;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if network is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -124,6 +127,10 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||
public boolean getIsShared() {
|
||||
return isShared == null ? false : isShared;
|
||||
}
|
||||
|
||||
public Boolean isDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
||||
@ -26,8 +26,8 @@ import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.NetworkOfferingResponse;
|
||||
import com.cloud.network.Networks.Availability;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
|
||||
@Implementation(description="Creates a network offering.", responseObject=NetworkOfferingResponse.class)
|
||||
public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
@ -44,9 +44,6 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network offering")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, required=true, description="type of the network. Supported types Virtual, Direct")
|
||||
private String type;
|
||||
|
||||
@Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, required=true, description="the traffic type for the network offering, supported types are Public, Management, Control, Guest, Vlan or Storage.")
|
||||
private String traffictype;
|
||||
|
||||
@ -78,10 +75,6 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getTraffictype() {
|
||||
return traffictype;
|
||||
}
|
||||
|
||||
@ -74,11 +74,11 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements
|
||||
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
return protocol.trim();
|
||||
}
|
||||
|
||||
public String getPublicPort() {
|
||||
return publicPort;
|
||||
return publicPort.trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -133,17 +133,17 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements
|
||||
|
||||
@Override
|
||||
public Ip getSourceIpAddress() {
|
||||
return new Ip(ipAddress);
|
||||
return new Ip(ipAddress.trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourcePortStart() {
|
||||
return Integer.parseInt(publicPort);
|
||||
return Integer.parseInt(publicPort.trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourcePortEnd() {
|
||||
return Integer.parseInt(publicPort);
|
||||
return Integer.parseInt(publicPort.trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -27,8 +27,7 @@ import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SecurityGroupResponse;
|
||||
import com.cloud.network.security.SecurityGroup;
|
||||
|
||||
//TODO - add description to implementation
|
||||
@Implementation(responseObject=SecurityGroupResponse.class)
|
||||
@Implementation(responseObject=SecurityGroupResponse.class, description="Creates a security group")
|
||||
public class CreateSecurityGroupCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateSecurityGroupCmd.class.getName());
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.BITS, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.BITS, type=CommandType.INTEGER, description="32 or 64 bit")
|
||||
private Integer bits;
|
||||
|
||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the template. This is usually used for display purposes.")
|
||||
|
||||
@ -41,7 +41,7 @@ public class CreateUserCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="Creates the user under the specified account. If no account is specified, the username will be used as the account name.")
|
||||
private String accountName;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="Creates the user under the specified domain.")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="Creates the user under the specified domain. Has to be accompanied with the account parameter")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.EMAIL, type=CommandType.STRING, required=true, description="email")
|
||||
|
||||
@ -26,6 +26,7 @@ import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
|
||||
@Implementation(description="Deletes a detached disk volume.", responseObject=SuccessResponse.class)
|
||||
public class DeleteVolumeCmd extends BaseCmd {
|
||||
@ -63,7 +64,7 @@ public class DeleteVolumeCmd extends BaseCmd {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
public void execute() throws ConcurrentOperationException {
|
||||
boolean result = _storageService.deleteVolume(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
|
||||
@ -49,9 +49,6 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
|
||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="list network offerings by display text")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="list by type of the network")
|
||||
private String type;
|
||||
|
||||
@Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="list by traffic type")
|
||||
private String trafficType;
|
||||
|
||||
@ -78,11 +75,7 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
public String getTrafficType() {
|
||||
return trafficType;
|
||||
}
|
||||
|
||||
@ -57,6 +57,15 @@ public class ListNetworksCmd extends BaseListCmd {
|
||||
|
||||
@Parameter(name=ApiConstants.IS_SYSTEM, type=CommandType.BOOLEAN, description="true if network is system, false otherwise")
|
||||
private Boolean isSystem;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true if network is shared, false otherwise")
|
||||
private Boolean isShared;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if network is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
|
||||
@Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="type of the traffic")
|
||||
private String trafficType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -86,6 +95,18 @@ public class ListNetworksCmd extends BaseListCmd {
|
||||
return isSystem;
|
||||
}
|
||||
|
||||
public Boolean getIsShared() {
|
||||
return isShared;
|
||||
}
|
||||
|
||||
public Boolean isDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public String getTrafficType() {
|
||||
return trafficType;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -30,7 +30,7 @@ import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.PreallocatedLunResponse;
|
||||
|
||||
@Implementation(responseObject=PreallocatedLunResponse.class)
|
||||
@Implementation(description="List PreallocatedLuns",responseObject=PreallocatedLunResponse.class)
|
||||
public class ListPreallocatedLunsCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListPreallocatedLunsCmd.class.getName());
|
||||
|
||||
|
||||
@ -24,8 +24,7 @@ import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.PreallocatedLunResponse;
|
||||
|
||||
//TODO - add description to @Implementation
|
||||
@Implementation(responseObject=PreallocatedLunResponse.class)
|
||||
@Implementation(description="Registers PreallocatedLun", responseObject=PreallocatedLunResponse.class)
|
||||
public class RegisterPreallocatedLunCmd extends BaseCmd {
|
||||
private static final String s_name = "registerPreallocatedLunsResponse";
|
||||
|
||||
@ -33,20 +32,17 @@ public class RegisterPreallocatedLunCmd extends BaseCmd {
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.DISK_SIZE, type=CommandType.LONG, required=true)
|
||||
@Parameter(name=ApiConstants.DISK_SIZE, type=CommandType.LONG, required=true, description="Volume size")
|
||||
private Long diskSize;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.LUN, type=CommandType.INTEGER, required=true)
|
||||
@Parameter(name=ApiConstants.LUN, type=CommandType.INTEGER, required=true, description="Lun id")
|
||||
private Integer lun;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.PORTAL, type=CommandType.STRING, required=true)
|
||||
private String portal;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.TAGS, type=CommandType.STRING)
|
||||
@Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="tags for the volume")
|
||||
private String tags;
|
||||
|
||||
@Parameter(name=ApiConstants.TARGET_IQN, type=CommandType.STRING, required=true, description="the target IQN on the storage host where LUN is created")
|
||||
|
||||
@ -17,8 +17,6 @@
|
||||
*/
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
@ -32,10 +30,10 @@ import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Reapplies all ip addresses for the particular network", responseObject=IPAddressResponse.class)
|
||||
public class RestartNetworkCmd extends BaseAsyncCmd {
|
||||
@ -46,12 +44,6 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account to associate with this IP address")
|
||||
private String accountName;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the domain to associate with this IP address")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the availability zone you want to acquire an public IP address from")
|
||||
private Long zoneId;
|
||||
|
||||
@ -63,20 +55,6 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getAccountName() {
|
||||
if (accountName != null) {
|
||||
return accountName;
|
||||
}
|
||||
return UserContext.current().getCaller().getAccountName();
|
||||
}
|
||||
|
||||
public long getDomainId() {
|
||||
if (domainId != null) {
|
||||
return domainId;
|
||||
}
|
||||
return UserContext.current().getCaller().getDomainId();
|
||||
}
|
||||
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
@ -90,26 +68,16 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
|
||||
}
|
||||
|
||||
public long getEntityOwnerId() {
|
||||
List<? extends Network> networks = _networkService.getVirtualNetworksOwnedByAccountInZone(getAccountName(), getDomainId(), getZoneId());
|
||||
if (networks.size() == 0) {
|
||||
assert (networks.size() <= 1) : "No virtual network is found";
|
||||
}
|
||||
assert (networks.size() <= 1) : "Too many virtual networks. This logic should be obsolete";
|
||||
|
||||
return networks.get(0).getAccountId();
|
||||
return _networkService.getNetwork(networkId).getAccountId();
|
||||
}
|
||||
|
||||
public Long getNetworkId() {
|
||||
if (networkId != null) {
|
||||
return networkId;
|
||||
Network network = _networkService.getNetwork(networkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Unable to find network by id " + networkId);
|
||||
} else {
|
||||
return network.getId();
|
||||
}
|
||||
|
||||
List<? extends Network> networks = _networkService.getVirtualNetworksOwnedByAccountInZone(getAccountName(), getDomainId(), getZoneId());
|
||||
if (networks.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
assert (networks.size() <= 1) : "Too many virtual networks. This logic should be obsolete";
|
||||
return networks.get(0).getId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Implementation(responseObject=SuccessResponse.class)
|
||||
@Implementation(responseObject=SuccessResponse.class, description="Deletes a particular ingress rule from this security group")
|
||||
public class RevokeSecurityGroupIngressCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(RevokeSecurityGroupIngressCmd.class.getName());
|
||||
|
||||
@ -29,44 +29,34 @@ public class RevokeSecurityGroupIngressCmd extends BaseAsyncCmd {
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING)
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the security group. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.CIDR_LIST, type=CommandType.STRING)
|
||||
@Parameter(name=ApiConstants.CIDR_LIST, type=CommandType.STRING, description="the cidr list associated")
|
||||
private String cidrList;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG)
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the security group. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.END_PORT, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.END_PORT, type=CommandType.INTEGER, description="end port for this ingress rule")
|
||||
private Integer endPort;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.ICMP_CODE, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.ICMP_CODE, type=CommandType.INTEGER, description="error code for this icmp message")
|
||||
private Integer icmpCode;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.ICMP_TYPE, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.ICMP_TYPE, type=CommandType.INTEGER, description="type for this icmp message")
|
||||
private Integer icmpType;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, required=true)
|
||||
@Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, required=true, description="name of the security group")
|
||||
private String securityGroupName;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.PROTOCOL, type=CommandType.STRING)
|
||||
@Parameter(name=ApiConstants.PROTOCOL, type=CommandType.STRING, description="protocol used")
|
||||
private String protocol;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.START_PORT, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.START_PORT, type=CommandType.INTEGER,description="start port for this ingress rule")
|
||||
private Integer startPort;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.USER_SECURITY_GROUP_LIST, type=CommandType.MAP)
|
||||
@Parameter(name=ApiConstants.USER_SECURITY_GROUP_LIST, type=CommandType.MAP, description="user to security group mapping")
|
||||
private Map userSecurityGroupList;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -26,8 +26,8 @@ import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.NetworkOfferingResponse;
|
||||
import com.cloud.network.Networks.Availability;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
|
||||
@Implementation(description="Updates a network offering.", responseObject=NetworkOfferingResponse.class)
|
||||
public class UpdateNetworkOfferingCmd extends BaseCmd {
|
||||
|
||||
@ -45,10 +45,7 @@ public class DiskOfferingResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.CREATED) @Param(description="the date this disk offering was created")
|
||||
private Date created;
|
||||
|
||||
@SerializedName("ismirrored")
|
||||
private Boolean mirrored;
|
||||
|
||||
@SerializedName("iscustomized")
|
||||
@SerializedName("iscustomized") @Param(description="true if disk offering uses custom size, false otherwise")
|
||||
private Boolean customized;
|
||||
|
||||
@SerializedName(ApiConstants.TAGS) @Param(description="the tags for the disk offering")
|
||||
@ -110,14 +107,6 @@ public class DiskOfferingResponse extends BaseResponse {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public Boolean isMirrored() {
|
||||
return mirrored;
|
||||
}
|
||||
|
||||
public void setMirrored(Boolean mirrored) {
|
||||
this.mirrored = mirrored;
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ public class ExtractResponse extends BaseResponse {
|
||||
@SerializedName("accountid") @Param(description="the account id to which the extracted object belongs")
|
||||
private Long accountId;
|
||||
|
||||
@SerializedName("resultstring") @Param(description="")
|
||||
@SerializedName("resultstring") @Param(expose=false)
|
||||
private String resultString;
|
||||
|
||||
@SerializedName(ApiConstants.CREATED) @Param(description="the time and date the object was created")
|
||||
@ -51,11 +51,9 @@ public class ExtractResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="the state of the extracted object")
|
||||
private String state;
|
||||
|
||||
//FIXME - add description
|
||||
@SerializedName("storagetype")
|
||||
@SerializedName("storagetype") @Param(description="type of the storage")
|
||||
private String storageType;
|
||||
|
||||
//FIXME - add description
|
||||
@SerializedName("storage")
|
||||
private String storage;
|
||||
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class HypervisorResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.NAME)
|
||||
@SerializedName(ApiConstants.NAME) @Param(description="Hypervisor name")
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
|
||||
@ -28,12 +28,10 @@ public class IngressRuleResponse extends BaseResponse {
|
||||
@SerializedName("protocol") @Param(description="the protocol of the ingress rule")
|
||||
private String protocol;
|
||||
|
||||
//FIXME - add description
|
||||
@SerializedName(ApiConstants.ICMP_TYPE)
|
||||
@SerializedName(ApiConstants.ICMP_TYPE) @Param(description="the type of the ICMP message response")
|
||||
private Integer icmpType;
|
||||
|
||||
//FIXME - add description
|
||||
@SerializedName(ApiConstants.ICMP_CODE)
|
||||
@SerializedName(ApiConstants.ICMP_CODE) @Param(description="the code for the ICMP message response")
|
||||
private Integer icmpCode;
|
||||
|
||||
@SerializedName(ApiConstants.START_PORT) @Param(description="the starting IP of the ingress rule")
|
||||
|
||||
@ -24,9 +24,6 @@ public class NetworkOfferingResponse extends BaseResponse{
|
||||
@SerializedName("maxconnections") @Param(description="the max number of concurrent connection the network offering supports")
|
||||
private Integer maxConnections;
|
||||
|
||||
@SerializedName("type") @Param(description="type of the network. Supported types are Virtualized, DirectSingle, DirectDual")
|
||||
private String type;
|
||||
|
||||
@SerializedName("traffictype") @Param(description="the traffic type for the network offering, supported types are Public, Management, Control, Guest, Vlan or Storage.")
|
||||
private String trafficType;
|
||||
|
||||
@ -87,14 +84,6 @@ public class NetworkOfferingResponse extends BaseResponse{
|
||||
this.maxConnections = maxConnections;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getTrafficType() {
|
||||
return trafficType;
|
||||
}
|
||||
|
||||
@ -17,20 +17,16 @@ public class NetworkResponse extends BaseResponse{
|
||||
@SerializedName("displaytext") @Param(description="the displaytext of the network")
|
||||
private String displaytext;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("broadcastdomaintype")
|
||||
@SerializedName("broadcastdomaintype") @Param(description="Broadcast domain type of the network")
|
||||
private String broadcastDomainType;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("traffictype")
|
||||
@SerializedName("traffictype") @Param(description="the traffic type of the network")
|
||||
private String trafficType;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("gateway")
|
||||
@SerializedName("gateway") @Param(description="the network's gateway")
|
||||
private String gateway;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("netmask")
|
||||
@SerializedName("netmask") @Param(description="the network's netmask")
|
||||
private String netmask;
|
||||
|
||||
@SerializedName("startip") @Param(description="the start ip of the network")
|
||||
@ -39,61 +35,46 @@ public class NetworkResponse extends BaseResponse{
|
||||
@SerializedName("endip") @Param(description="the end ip of the network")
|
||||
private String endIp;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("zoneid")
|
||||
@SerializedName("zoneid") @Param(description="zone id of the network")
|
||||
private Long zoneId;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("networkofferingid")
|
||||
@SerializedName("networkofferingid") @Param(description="network offering id the network is created from")
|
||||
private Long networkOfferingId;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("networkofferingname")
|
||||
@SerializedName("networkofferingname") @Param(description="name of the network offering the network is created from")
|
||||
private String networkOfferingName;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("networkofferingdisplaytext")
|
||||
@SerializedName("networkofferingdisplaytext") @Param(description="display text of the network offering the network is created from")
|
||||
private String networkOfferingDisplayText;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("networkofferingavailability")
|
||||
@SerializedName("networkofferingavailability") @Param(description="availability of the network offering the network is created from")
|
||||
private String networkOfferingAvailability;
|
||||
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("isshared")
|
||||
@SerializedName("isshared") @Param(description="true if network is shared, false otherwise")
|
||||
private Boolean isShared;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("issystem")
|
||||
@SerializedName("issystem") @Param(description="true if network is system, false otherwise")
|
||||
private Boolean isSystem;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("state")
|
||||
@SerializedName("state") @Param(description="state of the network")
|
||||
private String state;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("related")
|
||||
|
||||
@SerializedName("related") @Param(description="related to what other network configuration")
|
||||
private Long related;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("broadcasturi")
|
||||
@SerializedName("broadcasturi") @Param(description="broadcast uri of the network")
|
||||
private String broadcastUri;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("dns1")
|
||||
@SerializedName("dns1") @Param(description="the first dns for the network")
|
||||
private String dns1;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("dns2")
|
||||
@SerializedName("dns2") @Param(description="the second dns for the network")
|
||||
private String dns2;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("type")
|
||||
@SerializedName("type") @Param(description="the type of the network")
|
||||
private String type;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("vlan")
|
||||
@SerializedName("vlan") @Param(description="the vlan of the network")
|
||||
private String vlan;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account associated with the network")
|
||||
@ -105,7 +86,10 @@ public class NetworkResponse extends BaseResponse{
|
||||
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain associated with the network")
|
||||
private String domain;
|
||||
|
||||
@SerializedName("service") @Param(description="the list of services")
|
||||
@SerializedName("isdefault") @Param(description="true if network is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
|
||||
@SerializedName("service") @Param(description="the list of services", responseObject = ServiceResponse.class)
|
||||
private List<ServiceResponse> services;
|
||||
|
||||
public Long getId() {
|
||||
@ -323,4 +307,12 @@ public class NetworkResponse extends BaseResponse{
|
||||
public void setServices(List<ServiceResponse> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
public Boolean getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setIsDefault(Boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,13 +43,14 @@ public class NicResponse extends BaseResponse {
|
||||
@SerializedName("broadcasturi") @Param(description="the broadcast uri of the nic")
|
||||
private String broadcastUri;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("traffictype")
|
||||
@SerializedName("traffictype") @Param(description="the traffic type of the nic")
|
||||
private String trafficType;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("type")
|
||||
@SerializedName("type") @Param(description="the type of the nic")
|
||||
private String type;
|
||||
|
||||
@SerializedName("isdefault") @Param(description="true if nic is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -122,4 +123,12 @@ public class NicResponse extends BaseResponse {
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Boolean getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setIsDefault(Boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public class SecurityGroupResponse extends BaseResponse {
|
||||
@SerializedName("domain") @Param(description="the domain name of the security group")
|
||||
private String domainName;
|
||||
|
||||
@SerializedName("ingressrule") @Param(description="the list of ingress rules associated with the security group")
|
||||
@SerializedName("ingressrule") @Param(description="the list of ingress rules associated with the security group", responseObject = IngressRuleResponse.class)
|
||||
private List<IngressRuleResponse> ingressRules;
|
||||
|
||||
public Long getId() {
|
||||
|
||||
@ -28,7 +28,7 @@ public class ServiceResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.NAME) @Param(description="the service name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("capability") @Param(description="the list of capabilities")
|
||||
@SerializedName("capability") @Param(description="the list of capabilities", responseObject = CapabilityResponse.class)
|
||||
private List<CapabilityResponse> capabilities;
|
||||
|
||||
public String getName() {
|
||||
|
||||
@ -142,7 +142,7 @@ public class UserVmResponse extends BaseResponse {
|
||||
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
|
||||
private Integer jobStatus;
|
||||
|
||||
@SerializedName("nic") @Param(description="the list of nics associated with vm")
|
||||
@SerializedName("nic") @Param(description="the list of nics associated with vm", responseObject = NicResponse.class)
|
||||
private List<NicResponse> nics;
|
||||
|
||||
public Long getObjectId() {
|
||||
|
||||
@ -81,13 +81,13 @@ public class VolumeResponse extends BaseResponse {
|
||||
@SerializedName("storagetype") @Param(description="shared or local storage")
|
||||
private String storageType;
|
||||
|
||||
@SerializedName("sourceid")
|
||||
@SerializedName("sourceid") @Param(description="Id of the snapshot or diskOffering volume is created from")
|
||||
private Long sourceId;
|
||||
|
||||
@SerializedName("sourcetype")
|
||||
@SerializedName("sourcetype") @Param(description="Type of the source the volume is created from. Can be: Snapshot,DiskOffering")
|
||||
private String sourceType;
|
||||
|
||||
@SerializedName(ApiConstants.HYPERVISOR)
|
||||
@SerializedName(ApiConstants.HYPERVISOR) @Param(description="Hypervisor the volume belongs to")
|
||||
private String hypervisor;
|
||||
|
||||
@SerializedName(ApiConstants.DISK_OFFERING_ID) @Param(description="ID of the disk offering")
|
||||
|
||||
@ -42,19 +42,18 @@ public class ZoneResponse extends BaseResponse {
|
||||
|
||||
@SerializedName(ApiConstants.INTERNAL_DNS2) @Param(description="the second internal DNS for the Zone")
|
||||
private String internalDns2;
|
||||
|
||||
//FIXME - add description. This parameter is called "vnet" in updateZone, and vlan in createZone - figure out which one is right.
|
||||
@SerializedName(ApiConstants.VLAN)
|
||||
|
||||
@SerializedName(ApiConstants.VLAN) @Param(description="the vlan range of the zone")
|
||||
private String vlan;
|
||||
|
||||
@SerializedName(ApiConstants.GUEST_CIDR_ADDRESS) @Param(description="the guest CIDR address for the Zone")
|
||||
private String guestCidrAddress;
|
||||
|
||||
//FIXME - do we need 2 parameters below at all?
|
||||
//TODO - generate description
|
||||
@SerializedName("status")
|
||||
private String status;
|
||||
|
||||
@SerializedName(ApiConstants.DISPLAY_TEXT)
|
||||
@SerializedName(ApiConstants.DISPLAY_TEXT) @Param(description="the display text of the zone")
|
||||
private String displayText;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN) @Param(description="Domain name for the Vms in the zone")
|
||||
|
||||
@ -10,6 +10,7 @@ import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.storage.StoragePool;
|
||||
@ -50,11 +51,11 @@ public interface DeploymentPlanner extends Adapter {
|
||||
Set<Long> _hostIds;
|
||||
Set<Long> _poolIds;
|
||||
|
||||
public void add(InsufficientCapacityException e) {
|
||||
public boolean add(InsufficientCapacityException e) {
|
||||
Class<?> scope = e.getScope();
|
||||
|
||||
if (scope == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Host.class.isAssignableFrom(scope)) {
|
||||
@ -67,7 +68,35 @@ public interface DeploymentPlanner extends Adapter {
|
||||
addCluster(e.getId());
|
||||
} else if (StoragePool.class.isAssignableFrom(scope)) {
|
||||
addPool(e.getId());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(ResourceUnavailableException e) {
|
||||
Class<?> scope = e.getScope();
|
||||
|
||||
if (scope == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Host.class.isAssignableFrom(scope)) {
|
||||
addHost(e.getResourceId());
|
||||
} else if (Pod.class.isAssignableFrom(scope)) {
|
||||
addPod(e.getResourceId());
|
||||
} else if (DataCenter.class.isAssignableFrom(scope)) {
|
||||
addDataCenter(e.getResourceId());
|
||||
} else if (Cluster.class.isAssignableFrom(scope)) {
|
||||
addCluster(e.getResourceId());
|
||||
} else if (StoragePool.class.isAssignableFrom(scope)) {
|
||||
addPool(e.getResourceId());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addPool(long poolId) {
|
||||
|
||||
21
api/src/com/cloud/event/ActionEvent.java
Normal file
21
api/src/com/cloud/event/ActionEvent.java
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.event;
|
||||
|
||||
public @interface ActionEvent {
|
||||
}
|
||||
@ -11,7 +11,6 @@ import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.utils.fsm.FiniteState;
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
|
||||
@ -21,6 +20,11 @@ import com.cloud.utils.fsm.StateMachine;
|
||||
*/
|
||||
public interface Network extends ControlledEntity {
|
||||
|
||||
public enum GuestIpType {
|
||||
Virtual,
|
||||
Direct,
|
||||
}
|
||||
|
||||
public static class Service {
|
||||
|
||||
public static final Service Vpn = new Service("Vpn", Capability.SupportedVpnTypes);
|
||||
@ -197,5 +201,7 @@ public interface Network extends ControlledEntity {
|
||||
boolean isShared();
|
||||
|
||||
String getReservationId();
|
||||
|
||||
boolean isDefault();
|
||||
|
||||
}
|
||||
|
||||
@ -55,4 +55,6 @@ public interface NetworkService {
|
||||
|
||||
int getActiveNicsInNetwork(long networkId);
|
||||
|
||||
Network getNetwork(long networkId);
|
||||
|
||||
}
|
||||
|
||||
@ -36,12 +36,6 @@ public class Networks {
|
||||
Firewall
|
||||
}
|
||||
|
||||
public enum Availability {
|
||||
Required,
|
||||
Optional,
|
||||
Unavailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Different ways to assign ip address to this network.
|
||||
*/
|
||||
|
||||
@ -61,5 +61,7 @@ public interface LoadBalancingRulesService {
|
||||
* @return list of load balancers that match the criteria
|
||||
*/
|
||||
List<? extends LoadBalancer> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd);
|
||||
|
||||
List<LoadBalancingRule> listByNetworkId(long networkId);
|
||||
|
||||
}
|
||||
|
||||
65
api/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java
Normal file
65
api/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java
Normal file
@ -0,0 +1,65 @@
|
||||
package com.cloud.network.ovs;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class OvsCreateGreTunnelAnswer extends Answer {
|
||||
String hostIp;
|
||||
String remoteIp;
|
||||
String bridge;
|
||||
String key;
|
||||
long from;
|
||||
long to;
|
||||
int port;
|
||||
|
||||
public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details) {
|
||||
super(cmd, success, details);
|
||||
}
|
||||
|
||||
public OvsCreateGreTunnelAnswer(Command cmd, boolean success,
|
||||
String details, String hostIp, String bridge) {
|
||||
super(cmd, success, details);
|
||||
OvsCreateGreTunnelCommand c = (OvsCreateGreTunnelCommand)cmd;
|
||||
this.hostIp = hostIp;
|
||||
this.bridge = bridge;
|
||||
this.remoteIp = c.getRemoteIp();
|
||||
this.key = c.getKey();
|
||||
this.port = -1;
|
||||
this.from = c.getFrom();
|
||||
this.to = c.getTo();
|
||||
}
|
||||
|
||||
public OvsCreateGreTunnelAnswer(Command cmd, boolean success,
|
||||
String details, String hostIp, String bridge, int port) {
|
||||
this(cmd, success, details, hostIp, bridge);
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getHostIp() {
|
||||
return hostIp;
|
||||
}
|
||||
|
||||
public String getRemoteIp() {
|
||||
return remoteIp;
|
||||
}
|
||||
|
||||
public String getBridge() {
|
||||
return bridge;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public long getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public long getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
}
|
||||
38
api/src/com/cloud/network/ovs/OvsCreateGreTunnelCommand.java
Normal file
38
api/src/com/cloud/network/ovs/OvsCreateGreTunnelCommand.java
Normal file
@ -0,0 +1,38 @@
|
||||
package com.cloud.network.ovs;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class OvsCreateGreTunnelCommand extends Command {
|
||||
String remoteIp;
|
||||
String key;
|
||||
long from;
|
||||
long to;
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public OvsCreateGreTunnelCommand(String remoteIp, String key, long from, long to) {
|
||||
this.remoteIp = remoteIp;
|
||||
this.key = key;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public String getRemoteIp() {
|
||||
return remoteIp;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public long getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public long getTo() {
|
||||
return to;
|
||||
}
|
||||
}
|
||||
20
api/src/com/cloud/network/ovs/OvsDeleteFlowCommand.java
Normal file
20
api/src/com/cloud/network/ovs/OvsDeleteFlowCommand.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.cloud.network.ovs;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class OvsDeleteFlowCommand extends Command {
|
||||
String vmName;
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public OvsDeleteFlowCommand(String vmName) {
|
||||
this.vmName = vmName;
|
||||
}
|
||||
}
|
||||
24
api/src/com/cloud/network/ovs/OvsSetTagAndFlowAnswer.java
Normal file
24
api/src/com/cloud/network/ovs/OvsSetTagAndFlowAnswer.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.cloud.network.ovs;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class OvsSetTagAndFlowAnswer extends Answer {
|
||||
Long vmId;
|
||||
Long seqno;
|
||||
|
||||
public OvsSetTagAndFlowAnswer(Command cmd, boolean success, String details) {
|
||||
super(cmd, success, details);
|
||||
OvsSetTagAndFlowCommand c = (OvsSetTagAndFlowCommand)cmd;
|
||||
this.vmId = c.getVmId();
|
||||
this.seqno = Long.parseLong(c.getSeqNo());
|
||||
}
|
||||
|
||||
public Long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
public Long getSeqNo() {
|
||||
return seqno;
|
||||
}
|
||||
}
|
||||
44
api/src/com/cloud/network/ovs/OvsSetTagAndFlowCommand.java
Normal file
44
api/src/com/cloud/network/ovs/OvsSetTagAndFlowCommand.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.cloud.network.ovs;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class OvsSetTagAndFlowCommand extends Command {
|
||||
String vlans;
|
||||
String vmName;
|
||||
String seqno;
|
||||
String tag;
|
||||
Long vmId;
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getSeqNo() {
|
||||
return seqno;
|
||||
}
|
||||
|
||||
public String getVlans() {
|
||||
return vlans;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public Long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public OvsSetTagAndFlowCommand(String vmName, String tag, String vlans, String seqno, Long vmId) {
|
||||
this.vmName = vmName;
|
||||
this.tag = tag;
|
||||
this.vlans = vlans;
|
||||
this.seqno = seqno;
|
||||
this.vmId = vmId;
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,6 @@
|
||||
*/
|
||||
package com.cloud.offering;
|
||||
|
||||
import com.cloud.network.Networks.Availability;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
|
||||
/**
|
||||
@ -26,16 +25,21 @@ import com.cloud.network.Networks.TrafficType;
|
||||
*/
|
||||
public interface NetworkOffering {
|
||||
|
||||
public enum GuestIpType {
|
||||
Virtual,
|
||||
Direct,
|
||||
DirectPodBased,
|
||||
public enum Availability {
|
||||
Required,
|
||||
Optional,
|
||||
Unavailable;
|
||||
}
|
||||
|
||||
public final String DefaultVirtualizedNetworkOffering = "DefaultVirtualizedNetworkOffering";
|
||||
public final String DefaultDirectNetworkOffering = "DefaultDirectNetworkOffering";
|
||||
public final String DefaultDirectPodBasedNetworkOffering = "DefaultDirectPodBasedNetworkOffering";
|
||||
public final String DefaultDirectChooseVlanNetworkOffering = "DefaultDirectChooseVlanNetworkOffering";
|
||||
public final static String SystemPublicNetwork = "System-Public-Network";
|
||||
public final static String SystemControlNetwork = "System-Control-Network";
|
||||
public final static String SystemManagementNetwork = "System-Management-Network";
|
||||
public final static String SystemStorageNetwork = "System-Storage-Network";
|
||||
public final static String SysteGuestNetwork = "System-Guest-Network";
|
||||
|
||||
public final static String DefaultVirtualizedNetworkOffering = "DefaultVirtualizedNetworkOffering";
|
||||
public final static String DefaultDirectNetworkOffering = "DefaultDirectNetworkOffering";
|
||||
public final static String DefaultDirectChooseVlanNetworkOffering = "DefaultDirectChooseVlanNetworkOffering";
|
||||
|
||||
long getId();
|
||||
|
||||
@ -59,11 +63,6 @@ public interface NetworkOffering {
|
||||
*/
|
||||
Integer getMulticastRateMbps();
|
||||
|
||||
/**
|
||||
* @return the type of IP address to allocate as the primary ip address to a guest
|
||||
*/
|
||||
GuestIpType getGuestIpType();
|
||||
|
||||
/**
|
||||
* @return concurrent connections to be supported.
|
||||
*/
|
||||
@ -81,6 +80,7 @@ public interface NetworkOffering {
|
||||
|
||||
Availability getAvailability();
|
||||
|
||||
|
||||
boolean isDnsService();
|
||||
|
||||
boolean isGatewayService();
|
||||
|
||||
@ -19,6 +19,8 @@ package com.cloud.offering;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
|
||||
/**
|
||||
* ServiceOffering models the different types of service contracts to be
|
||||
* offered.
|
||||
@ -70,7 +72,7 @@ public interface ServiceOffering {
|
||||
/**
|
||||
* @return the type of IP address to allocate as the primary ip address to a guest
|
||||
*/
|
||||
NetworkOffering.GuestIpType getGuestIpType();
|
||||
Network.GuestIpType getGuestIpType();
|
||||
|
||||
/**
|
||||
* @return whether or not the service offering requires local storage
|
||||
|
||||
@ -18,12 +18,16 @@
|
||||
|
||||
package com.cloud.serializer;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Param {
|
||||
String name() default "";
|
||||
String propName() default "";
|
||||
String description() default "";
|
||||
String description() default "";
|
||||
|
||||
// 2 parameters below are used by cloudstack api
|
||||
boolean expose() default true;
|
||||
Class<?> responseObject() default Object.class;
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import com.cloud.api.commands.DeletePoolCmd;
|
||||
import com.cloud.api.commands.DeleteVolumeCmd;
|
||||
import com.cloud.api.commands.PreparePrimaryStorageForMaintenanceCmd;
|
||||
import com.cloud.api.commands.UpdateStoragePoolCmd;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
@ -60,7 +61,7 @@ public interface StorageService {
|
||||
*/
|
||||
Volume createVolume(CreateVolumeCmd cmd);
|
||||
|
||||
boolean deleteVolume(DeleteVolumeCmd cmd) throws InvalidParameterValueException;
|
||||
boolean deleteVolume(DeleteVolumeCmd cmd) throws ConcurrentOperationException;
|
||||
/**
|
||||
* Delete the storage pool
|
||||
* @param cmd - the command specifying poolId
|
||||
|
||||
@ -38,8 +38,7 @@ public interface Volume extends ControlledEntity, BasedOn {
|
||||
Creating("The volume is being created. getPoolId() should reflect the pool where it is being created."),
|
||||
Ready("The volume is ready to be used."),
|
||||
Used("The volume is used"),
|
||||
Destroy("The volume is set to be desctroyed but can be recovered."),
|
||||
Destroyed("The volume is destroyed. Should be removed.");
|
||||
Destroy("The volume is set to be destroyed but can be recovered.");
|
||||
|
||||
String _description;
|
||||
|
||||
@ -75,16 +74,13 @@ public interface Volume extends ControlledEntity, BasedOn {
|
||||
private final static StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
|
||||
static {
|
||||
s_fsm.addTransition(Allocated, Event.Create, Creating);
|
||||
s_fsm.addTransition(Allocated, Event.Destroy, Destroyed);
|
||||
s_fsm.addTransition(Allocated, Event.Destroy, Destroy);
|
||||
s_fsm.addTransition(Creating, Event.OperationRetry, Creating);
|
||||
s_fsm.addTransition(Creating, Event.OperationFailed, Allocated);
|
||||
s_fsm.addTransition(Creating, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Creating, Event.Destroy, Destroy);
|
||||
s_fsm.addTransition(Ready, Event.Destroy, Destroy);
|
||||
s_fsm.addTransition(Ready, Event.Start, Used);
|
||||
s_fsm.addTransition(Destroy, Event.OperationSucceeded, Destroyed);
|
||||
s_fsm.addTransition(Destroy, Event.OperationFailed, Destroy);
|
||||
s_fsm.addTransition(Destroy, Event.OperationRetry, Destroy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +152,6 @@ public interface Volume extends ControlledEntity, BasedOn {
|
||||
|
||||
Date getCreated();
|
||||
AsyncInstanceCreateStatus getStatus();
|
||||
|
||||
boolean getDestroyed();
|
||||
|
||||
long getDiskOfferingId();
|
||||
|
||||
@ -104,7 +104,6 @@ public interface AccountService {
|
||||
* @param cmd - the LockAccount command defining the accountId to be locked.
|
||||
* @return account object
|
||||
*/
|
||||
//Account lockAccount(LockAccountCmd cmd);
|
||||
Account lockAccount(DisableAccountCmd cmd);
|
||||
|
||||
/**
|
||||
@ -139,6 +138,14 @@ public interface AccountService {
|
||||
|
||||
User createUser(CreateUserCmd cmd);
|
||||
boolean deleteUser(DeleteUserCmd deleteUserCmd);
|
||||
|
||||
|
||||
boolean isAdmin(short accountType);
|
||||
|
||||
Account finalizeOwner(Account caller, String accountName, Long domainId);
|
||||
|
||||
Account getActiveAccount(String accountName, Long domainId);
|
||||
|
||||
Account getAccount(Long accountId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.fsm.FiniteState;
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
|
||||
@ -223,4 +224,6 @@ public interface VirtualMachine extends RunningOn, ControlledEntity {
|
||||
public long getServiceOfferingId();
|
||||
|
||||
Type getType();
|
||||
|
||||
HypervisorType getHypervisorType();
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#Titles
|
||||
label.cloud.console=Cloud Management Console[zh]
|
||||
|
||||
label.menu.dashboard=儀器板
|
||||
|
||||
#Labels
|
||||
|
||||
#Messages
|
||||
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# @PACKAGE@-management This shell script takes care of starting and stopping Tomcat
|
||||
#
|
||||
# chkconfig: - 80 20
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: tomcat6
|
||||
# Required-Start: $network $syslog
|
||||
# Required-Stop: $network $syslog
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Description: Release implementation for Servlet 2.5 and JSP 2.1
|
||||
# Short-Description: start and stop tomcat
|
||||
### END INIT INFO
|
||||
#
|
||||
# - originally written by Henri Gomez, Keith Irwin, and Nicolas Mailhot
|
||||
# - heavily rewritten by Deepak Bhole and Jason Corley
|
||||
#
|
||||
|
||||
if [ -r /etc/rc.d/init.d/functions ]; then
|
||||
. /etc/rc.d/init.d/functions
|
||||
fi
|
||||
if [ -r /lib/lsb/init-functions ]; then
|
||||
. /lib/lsb/init-functions
|
||||
fi
|
||||
|
||||
|
||||
NAME="$(basename $0)"
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
status)
|
||||
status ${NAME}
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
. /etc/rc.d/init.d/tomcat6
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
@ -0,0 +1,6 @@
|
||||
# This file is loaded in /etc/init.d/vmopsmanagement
|
||||
# ATM we only do two things here:
|
||||
|
||||
dummy=1 ; export TOMCAT_CFG=@MSCONF@/tomcat6.conf ; . @MSCONF@/tomcat6.conf
|
||||
#--------------------------
|
||||
|
||||
@ -103,7 +103,6 @@ listVlanIpRanges=com.cloud.api.commands.ListVlanIpRangesCmd;1
|
||||
associateIpAddress=com.cloud.api.commands.AssociateIPAddrCmd;15
|
||||
disassociateIpAddress=com.cloud.api.commands.DisassociateIPAddrCmd;15
|
||||
listPublicIpAddresses=com.cloud.api.commands.ListPublicIpAddressesCmd;15
|
||||
restartNetwork=com.cloud.api.commands.RestartNetworkCmd;15
|
||||
|
||||
#### firewall commands
|
||||
listPortForwardingRules=com.cloud.api.commands.ListPortForwardingRulesCmd;15
|
||||
@ -169,7 +168,6 @@ listCapacity=com.cloud.api.commands.ListCapacityCmd;1
|
||||
addHost=com.cloud.api.commands.AddHostCmd;1
|
||||
addCluster=com.cloud.api.commands.AddClusterCmd;1
|
||||
deleteCluster=com.cloud.api.commands.DeleteClusterCmd;1
|
||||
add=com.cloud.api.commands.AddHostCmd;1
|
||||
reconnectHost=com.cloud.api.commands.ReconnectHostCmd;1
|
||||
updateHost=com.cloud.api.commands.UpdateHostCmd;1
|
||||
deleteHost=com.cloud.api.commands.DeleteHostCmd;1
|
||||
@ -247,11 +245,11 @@ listNetworkOfferings=com.cloud.api.commands.ListNetworkOfferingsCmd;15
|
||||
#### network commands
|
||||
createNetwork=com.cloud.api.commands.CreateNetworkCmd;15
|
||||
deleteNetwork=com.cloud.api.commands.DeleteNetworkCmd;15
|
||||
listNetworks=com.cloud.api.commands.ListNetworksCmd;15
|
||||
listNetworks=com.cloud.api.commands.ListNetworksCmd;15
|
||||
restartNetwork=com.cloud.api.commands.RestartNetworkCmd;15
|
||||
|
||||
#### SSH key pair commands
|
||||
registerSSHKeyPair=com.cloud.api.commands.RegisterSSHKeyPairCmd;15
|
||||
createSSHKeyPair=com.cloud.api.commands.CreateSSHKeyPairCmd;15
|
||||
deleteSSHKeyPair=com.cloud.api.commands.DeleteSSHKeyPairCmd;15
|
||||
listSSHKeyPairs=com.cloud.api.commands.ListSSHKeyPairsCmd;15
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
documented, please contact the author.
|
||||
-->
|
||||
<components.xml>
|
||||
<interceptor library="com.cloud.configuration.DefaultIntercetorLibrary"/>
|
||||
<management-server class="com.cloud.server.ManagementServerImpl" library="com.cloud.configuration.DefaultComponentLibrary">
|
||||
<adapters key="com.cloud.agent.manager.allocator.HostAllocator">
|
||||
<adapter name="FirstFitRouting" class="com.cloud.agent.manager.allocator.impl.RecreateHostAllocator"/>
|
||||
@ -45,6 +46,7 @@
|
||||
<adapter name="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru"/>
|
||||
<adapter name="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru"/>
|
||||
<adapter name="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru"/>
|
||||
<adapter name="DirectPodBasedNetworkGuru" class="com.cloud.network.guru.DirectPodBasedNetworkGuru"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.storage.secondary.SecondaryStorageVmAllocator">
|
||||
<adapter name="Balance" class="com.cloud.storage.secondary.SecondaryStorageVmDefaultAllocator"/>
|
||||
|
||||
56
cloud.spec
56
cloud.spec
@ -223,6 +223,12 @@ Requires: kvm
|
||||
Requires: qemu-cloud-system-x86
|
||||
Requires: qemu-cloud-img
|
||||
%endif
|
||||
|
||||
%if 0%{?rhel} >= 6
|
||||
Requires: cloud-qemu-kvm
|
||||
Requires: cloud-qemu-img
|
||||
%endif
|
||||
|
||||
Requires: libcgroup
|
||||
Requires: /usr/bin/uuidgen
|
||||
Requires: augeas >= 0.7.1
|
||||
@ -302,6 +308,8 @@ Obsoletes: %{name}-premium-vendor-zynga < %{version}-%{release}
|
||||
Requires: java >= 1.6.0
|
||||
Requires: %{name}-utils = %{version}-%{release}
|
||||
Requires: %{name}-premium-deps
|
||||
# there is a fsimage.so in the source code, which adds xen-libs as a dependence, needs to supress it, as rhel doesn't have this pacakge
|
||||
AutoReqProv: no
|
||||
License: CSL 1.1
|
||||
Group: System Environment/Libraries
|
||||
%description premium
|
||||
@ -431,8 +439,8 @@ fi
|
||||
%defattr(0644,root,root,0755)
|
||||
%{_javadir}/%{name}-utils.jar
|
||||
%{_javadir}/%{name}-api.jar
|
||||
%attr(755,root,root) %{_bindir}/cloud-sccs
|
||||
%attr(755,root,root) %{_bindir}/cloud-gitrevs
|
||||
%attr(0755,root,root) %{_bindir}/cloud-sccs
|
||||
%attr(0755,root,root) %{_bindir}/cloud-gitrevs
|
||||
%doc %{_docdir}/%{name}-%{version}/sccs-info
|
||||
%doc %{_docdir}/%{name}-%{version}/version-info
|
||||
%doc %{_docdir}/%{name}-%{version}/configure-info
|
||||
@ -457,7 +465,7 @@ fi
|
||||
|
||||
%files daemonize
|
||||
%defattr(-,root,root,-)
|
||||
%attr(755,root,root) %{_bindir}/%{name}-daemonize
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-daemonize
|
||||
|
||||
%files deps
|
||||
%defattr(0644,root,root,0755)
|
||||
@ -497,7 +505,7 @@ fi
|
||||
%{_prefix}/lib*/python*/site-packages/%{name}*
|
||||
%attr(0755,root,root) %{_bindir}/cloud-external-ipallocator.py
|
||||
%attr(0755,root,root) %{_initrddir}/cloud-ipallocator
|
||||
%dir %attr(770,root,root) %{_localstatedir}/log/%{name}/ipallocator
|
||||
%dir %attr(0770,root,root) %{_localstatedir}/log/%{name}/ipallocator
|
||||
|
||||
%files setup
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-setup-databases
|
||||
@ -508,30 +516,30 @@ fi
|
||||
%{_datadir}/%{name}/setup/server-setup.xml
|
||||
|
||||
%files client
|
||||
%defattr(0644,root,root,0755)
|
||||
%defattr(0644,root,root,0775)
|
||||
%{_sysconfdir}/%{name}/management/*
|
||||
%if %{_premium}
|
||||
%exclude %{_sysconfdir}/%{name}/management/*premium*
|
||||
%endif
|
||||
%config(noreplace) %attr(640,root,%{name}) %{_sysconfdir}/%{name}/management/db.properties
|
||||
%config(noreplace) %attr(0640,root,%{name}) %{_sysconfdir}/%{name}/management/db.properties
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/management/log4j-%{name}.xml
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/management/tomcat6.conf
|
||||
%dir %attr(770,root,%{name}) %{_sysconfdir}/%{name}/management/Catalina
|
||||
%dir %attr(770,root,%{name}) %{_sysconfdir}/%{name}/management/Catalina/localhost
|
||||
%dir %attr(770,root,%{name}) %{_sysconfdir}/%{name}/management/Catalina/localhost/client
|
||||
%dir %attr(0770,root,%{name}) %{_sysconfdir}/%{name}/management/Catalina
|
||||
%dir %attr(0770,root,%{name}) %{_sysconfdir}/%{name}/management/Catalina/localhost
|
||||
%dir %attr(0770,root,%{name}) %{_sysconfdir}/%{name}/management/Catalina/localhost/client
|
||||
%config %{_sysconfdir}/sysconfig/%{name}-management
|
||||
%attr(0755,root,root) %{_initrddir}/%{name}-management
|
||||
%dir %{_datadir}/%{name}/management
|
||||
%{_datadir}/%{name}/management/*
|
||||
%attr(755,root,root) %{_bindir}/%{name}-setup-management
|
||||
%attr(755,root,root) %{_bindir}/%{name}-update-xenserver-licenses
|
||||
%dir %attr(770,root,%{name}) %{_sharedstatedir}/%{name}/mnt
|
||||
%dir %attr(770,%{name},%{name}) %{_sharedstatedir}/%{name}/management
|
||||
%dir %attr(770,root,%{name}) %{_localstatedir}/cache/%{name}/management
|
||||
%dir %attr(770,root,%{name}) %{_localstatedir}/cache/%{name}/management/work
|
||||
%dir %attr(770,root,%{name}) %{_localstatedir}/cache/%{name}/management/temp
|
||||
%dir %attr(770,root,%{name}) %{_localstatedir}/log/%{name}/management
|
||||
%dir %attr(770,root,%{name}) %{_localstatedir}/log/%{name}/agent
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-setup-management
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-update-xenserver-licenses
|
||||
%dir %attr(0770,root,%{name}) %{_sharedstatedir}/%{name}/mnt
|
||||
%dir %attr(0770,%{name},%{name}) %{_sharedstatedir}/%{name}/management
|
||||
%dir %attr(0770,root,%{name}) %{_localstatedir}/cache/%{name}/management
|
||||
%dir %attr(0770,root,%{name}) %{_localstatedir}/cache/%{name}/management/work
|
||||
%dir %attr(0770,root,%{name}) %{_localstatedir}/cache/%{name}/management/temp
|
||||
%dir %attr(0770,root,%{name}) %{_localstatedir}/log/%{name}/management
|
||||
%dir %attr(0770,root,%{name}) %{_localstatedir}/log/%{name}/agent
|
||||
|
||||
%files agent-libs
|
||||
%defattr(0644,root,root,0755)
|
||||
@ -550,7 +558,7 @@ fi
|
||||
%{_libdir}/%{name}/agent/js
|
||||
%{_libdir}/%{name}/agent/images
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-setup-agent
|
||||
%dir %attr(770,root,root) %{_localstatedir}/log/%{name}/agent
|
||||
%dir %attr(0770,root,root) %{_localstatedir}/log/%{name}/agent
|
||||
|
||||
|
||||
%files console-proxy
|
||||
@ -561,7 +569,7 @@ fi
|
||||
%attr(0755,root,root) %{_libexecdir}/console-proxy-runner
|
||||
%{_libdir}/%{name}/console-proxy/*
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-setup-console-proxy
|
||||
%dir %attr(770,root,root) %{_localstatedir}/log/%{name}/console-proxy
|
||||
%dir %attr(0770,root,root) %{_localstatedir}/log/%{name}/console-proxy
|
||||
|
||||
%files cli
|
||||
%{_bindir}/%{name}-tool
|
||||
@ -574,7 +582,7 @@ fi
|
||||
|
||||
%files test
|
||||
%defattr(0644,root,root,0755)
|
||||
%attr(755,root,root) %{_bindir}/%{name}-run-test
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-run-test
|
||||
%{_javadir}/%{name}-test.jar
|
||||
%{_sharedstatedir}/%{name}/test/*
|
||||
%{_libdir}/%{name}/test/*
|
||||
@ -597,14 +605,14 @@ fi
|
||||
%{_libdir}/%{name}/agent/premium-scripts/*
|
||||
|
||||
%files usage
|
||||
%defattr(0644,root,root,0755)
|
||||
%defattr(0644,root,root,0775)
|
||||
%{_javadir}/%{name}-usage.jar
|
||||
%attr(0755,root,root) %{_initrddir}/%{name}-usage
|
||||
%attr(0755,root,root) %{_libexecdir}/usage-runner
|
||||
%dir %attr(770,root,%{name}) %{_localstatedir}/log/%{name}/usage
|
||||
%dir %attr(0770,root,%{name}) %{_localstatedir}/log/%{name}/usage
|
||||
%{_sysconfdir}/%{name}/usage/usage-components.xml
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/usage/log4j-%{name}_usage.xml
|
||||
%config(noreplace) %attr(640,root,%{name}) %{_sysconfdir}/%{name}/usage/db.properties
|
||||
%config(noreplace) %attr(0640,root,%{name}) %{_sysconfdir}/%{name}/usage/db.properties
|
||||
|
||||
%endif
|
||||
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
|
||||
# chkconfig: 35 99 10
|
||||
# description: Cloud Console Proxy
|
||||
|
||||
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
|
||||
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
whatami=cloud-console-proxy
|
||||
|
||||
# set environment variables
|
||||
|
||||
SHORTNAME="$whatami"
|
||||
PIDFILE=@PIDDIR@/"$whatami".pid
|
||||
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
|
||||
LOGFILE=@CPLOG@
|
||||
PROGNAME="Cloud Console Proxy"
|
||||
|
||||
unset OPTIONS
|
||||
[ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME"
|
||||
DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
|
||||
PROG=@LIBEXECDIR@/console-proxy-runner
|
||||
|
||||
start() {
|
||||
echo -n $"Starting $PROGNAME: "
|
||||
if hostname --fqdn >/dev/null 2>&1 ; then
|
||||
daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \
|
||||
-n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
|
||||
RETVAL=$?
|
||||
echo
|
||||
else
|
||||
failure
|
||||
echo
|
||||
echo The host name does not resolve properly to an IP address. Cannot start "$PROGNAME". > /dev/stderr
|
||||
RETVAL=9
|
||||
fi
|
||||
[ $RETVAL = 0 ] && touch ${LOCKFILE}
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $PROGNAME: "
|
||||
killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
|
||||
}
|
||||
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status -p ${PIDFILE} $SHORTNAME
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
sleep 3
|
||||
start
|
||||
;;
|
||||
condrestart)
|
||||
if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
|
||||
stop
|
||||
sleep 3
|
||||
start
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
|
||||
RETVAL=3
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
|
||||
31
console-proxy/scripts/ipfirewall.sh
Executable file
31
console-proxy/scripts/ipfirewall.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASE_DIR="/var/www/html/copy/"
|
||||
HTACCESS="$BASE_DIR/.htaccess"
|
||||
|
||||
config_htaccess() {
|
||||
mkdir -p $BASE_DIR
|
||||
result=$?
|
||||
echo "Options -Indexes" > $HTACCESS
|
||||
let "result=$result+$?"
|
||||
echo "order deny,allow" >> $HTACCESS
|
||||
let "result=$result+$?"
|
||||
echo "deny from all" >> $HTACCESS
|
||||
let "result=$result+$?"
|
||||
return $result
|
||||
}
|
||||
|
||||
ips(){
|
||||
echo "allow from $1" >> $HTACCESS
|
||||
result=$?
|
||||
return $result
|
||||
}
|
||||
|
||||
|
||||
config_htaccess
|
||||
for i in $@
|
||||
do
|
||||
ips "$i"
|
||||
done
|
||||
exit $?
|
||||
|
||||
26
core/src/com/cloud/agent/api/PingRoutingWithOvsCommand.java
Normal file
26
core/src/com/cloud/agent/api/PingRoutingWithOvsCommand.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
public class PingRoutingWithOvsCommand extends PingRoutingCommand {
|
||||
List<Pair<String, Long>> states;
|
||||
|
||||
protected PingRoutingWithOvsCommand() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PingRoutingWithOvsCommand(Host.Type type, long id,
|
||||
Map<String, State> states, List<Pair<String, Long>> ovsStates) {
|
||||
super(type, id, states);
|
||||
this.states = ovsStates;
|
||||
}
|
||||
|
||||
public List<Pair<String, Long>> getStates() {
|
||||
return states;
|
||||
}
|
||||
}
|
||||
12
core/src/com/cloud/agent/api/storage/CreateEntityDownloadURLCommand.java
Normal file → Executable file
12
core/src/com/cloud/agent/api/storage/CreateEntityDownloadURLCommand.java
Normal file → Executable file
@ -4,15 +4,17 @@ import com.cloud.agent.api.Command;
|
||||
|
||||
public class CreateEntityDownloadURLCommand extends AbstractDownloadCommand {
|
||||
|
||||
public CreateEntityDownloadURLCommand(String installPath) {
|
||||
public CreateEntityDownloadURLCommand(String installPath, String uuid) {
|
||||
super();
|
||||
this.installPath = installPath;
|
||||
this.extractLinkUUID = uuid;
|
||||
}
|
||||
|
||||
public CreateEntityDownloadURLCommand() {
|
||||
}
|
||||
|
||||
private String installPath;
|
||||
private String extractLinkUUID;
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
@ -27,4 +29,12 @@ public class CreateEntityDownloadURLCommand extends AbstractDownloadCommand {
|
||||
this.installPath = installPath;
|
||||
}
|
||||
|
||||
public String getExtractLinkUUID() {
|
||||
return extractLinkUUID;
|
||||
}
|
||||
|
||||
public void setExtractLinkUUID(String extractLinkUUID) {
|
||||
this.extractLinkUUID = extractLinkUUID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,13 +4,15 @@ import com.cloud.storage.Upload;
|
||||
|
||||
public class DeleteEntityDownloadURLCommand extends AbstractDownloadCommand {
|
||||
|
||||
String path;
|
||||
Upload.Type type;
|
||||
private String path;
|
||||
private String extractUrl;
|
||||
private Upload.Type type;
|
||||
|
||||
public DeleteEntityDownloadURLCommand(String path, Upload.Type type) {
|
||||
public DeleteEntityDownloadURLCommand(String path, Upload.Type type, String url) {
|
||||
super();
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
this.extractUrl = url;
|
||||
}
|
||||
|
||||
public DeleteEntityDownloadURLCommand() {
|
||||
@ -33,4 +35,12 @@ public class DeleteEntityDownloadURLCommand extends AbstractDownloadCommand {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getExtractUrl() {
|
||||
return extractUrl;
|
||||
}
|
||||
|
||||
public void setExtractUrl(String extractUrl) {
|
||||
this.extractUrl = extractUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -63,6 +63,9 @@ public class UsageEventVO implements UsageEvent {
|
||||
|
||||
@Column(name="size")
|
||||
private Long size;
|
||||
|
||||
@Column(name="processed")
|
||||
boolean processed;
|
||||
|
||||
|
||||
public UsageEventVO() {
|
||||
@ -163,4 +166,12 @@ public class UsageEventVO implements UsageEvent {
|
||||
return size;
|
||||
}
|
||||
|
||||
public boolean isProcessed() {
|
||||
return processed;
|
||||
}
|
||||
|
||||
public void setProcessed(boolean processed) {
|
||||
this.processed = processed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,13 +29,9 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
public interface UsageEventDao extends GenericDao<UsageEventVO, Long> {
|
||||
|
||||
public List<UsageEventVO> searchAllUsageEvents(SearchCriteria<UsageEventVO> sc, Filter filter);
|
||||
public List<UsageEventVO> listLatestEvents(Date endDate);
|
||||
|
||||
public List<UsageEventVO> listLatestEvents(Date recentEventDate, Date endDate);
|
||||
|
||||
public List<UsageEventVO> listAllEvents(Date endDate);
|
||||
|
||||
public List<UsageEventVO> getLatestEventDate();
|
||||
public List<UsageEventVO> getLatestEvent();
|
||||
|
||||
List<UsageEventVO> getRecentEvents(Date endDate) throws UsageServerException;
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
package com.cloud.event.dao;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
@ -31,6 +30,7 @@ import org.apache.log4j.Logger;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.exception.UsageServerException;
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
@ -42,58 +42,40 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem
|
||||
public static final Logger s_logger = Logger.getLogger(UsageEventDaoImpl.class.getName());
|
||||
|
||||
private final SearchBuilder<UsageEventVO> latestEventsSearch;
|
||||
private final SearchBuilder<UsageEventVO> allEventsSearch;
|
||||
private static final String GET_LATEST_EVENT_DATE = "SELECT created FROM usage_event ORDER BY created DESC LIMIT 1";
|
||||
private static final String COPY_EVENTS = "INSERT INTO cloud_usage.usage_event SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size FROM cloud.usage_event vmevt WHERE vmevt.created > ? and vmevt.created <= ? ";
|
||||
private static final String COPY_ALL_EVENTS = "INSERT INTO cloud_usage.usage_event SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size FROM cloud.usage_event where created <= ? ";
|
||||
private static final String COPY_EVENTS = "INSERT INTO cloud_usage.usage_event (id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size) " +
|
||||
"SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size FROM cloud.usage_event vmevt WHERE vmevt.id > ? and vmevt.created <= ? ";
|
||||
private static final String COPY_ALL_EVENTS = "INSERT INTO cloud_usage.usage_event (id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size) " +
|
||||
"SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size FROM cloud.usage_event where id <= ? ";
|
||||
|
||||
|
||||
public UsageEventDaoImpl () {
|
||||
latestEventsSearch = createSearchBuilder();
|
||||
latestEventsSearch.and("recentEventDate", latestEventsSearch.entity().getCreateDate(), SearchCriteria.Op.GT);
|
||||
latestEventsSearch.and("processed", latestEventsSearch.entity().isProcessed(), SearchCriteria.Op.EQ);
|
||||
latestEventsSearch.and("enddate", latestEventsSearch.entity().getCreateDate(), SearchCriteria.Op.LTEQ);
|
||||
latestEventsSearch.done();
|
||||
|
||||
allEventsSearch = createSearchBuilder();
|
||||
allEventsSearch.and("enddate", allEventsSearch.entity().getCreateDate(), SearchCriteria.Op.LTEQ);
|
||||
allEventsSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UsageEventVO> listLatestEvents(Date recentEventDate, Date endDate) {
|
||||
public List<UsageEventVO> listLatestEvents(Date endDate) {
|
||||
Filter filter = new Filter(UsageEventVO.class, "createDate", Boolean.TRUE, null, null);
|
||||
SearchCriteria<UsageEventVO> sc = latestEventsSearch.create();
|
||||
sc.setParameters("recentEventDate", recentEventDate);
|
||||
sc.setParameters("processed", false);
|
||||
sc.setParameters("enddate", endDate);
|
||||
return listBy(sc, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UsageEventVO> listAllEvents(Date endDate) {
|
||||
Filter filter = new Filter(UsageEventVO.class, "createDate", Boolean.TRUE, null, null);
|
||||
SearchCriteria<UsageEventVO> sc = latestEventsSearch.create();
|
||||
sc.setParameters("enddate", endDate);
|
||||
return listBy(sc, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UsageEventVO> getLatestEventDate() {
|
||||
Filter filter = new Filter(UsageEventVO.class, "createDate", Boolean.FALSE, null, 1L);
|
||||
public List<UsageEventVO> getLatestEvent() {
|
||||
Filter filter = new Filter(UsageEventVO.class, "id", Boolean.FALSE, Long.valueOf(0), Long.valueOf(1));
|
||||
return listAll(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UsageEventVO> searchAllUsageEvents(SearchCriteria<UsageEventVO> sc, Filter filter) {
|
||||
return listIncludingRemovedBy(sc, filter);
|
||||
}
|
||||
|
||||
|
||||
@DB
|
||||
public synchronized List<UsageEventVO> getRecentEvents(Date endDate) throws UsageServerException {
|
||||
Transaction txn = Transaction.open(Transaction.USAGE_DB);
|
||||
Date recentEventDate = getMostRecentEventDate();
|
||||
long recentEventId = getMostRecentEventId();
|
||||
String sql = COPY_EVENTS;
|
||||
if (recentEventDate == null) {
|
||||
if (recentEventId == 0) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("no recent event date, copying all events");
|
||||
}
|
||||
@ -105,13 +87,13 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem
|
||||
txn.start();
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
int i = 1;
|
||||
if (recentEventDate != null) {
|
||||
pstmt.setString(i++, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), recentEventDate));
|
||||
if (recentEventId != 0) {
|
||||
pstmt.setLong(i++, recentEventId);
|
||||
}
|
||||
pstmt.setString(i, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), endDate));
|
||||
pstmt.executeUpdate();
|
||||
txn.commit();
|
||||
return findRecentEvents(recentEventDate, endDate);
|
||||
return findRecentEvents(endDate);
|
||||
} catch (Exception ex) {
|
||||
txn.rollback();
|
||||
s_logger.error("error copying events from cloud db to usage db", ex);
|
||||
@ -121,37 +103,31 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem
|
||||
}
|
||||
}
|
||||
|
||||
private Date getMostRecentEventDate() throws UsageServerException {
|
||||
@DB
|
||||
private long getMostRecentEventId() throws UsageServerException {
|
||||
Transaction txn = Transaction.open(Transaction.USAGE_DB);
|
||||
PreparedStatement pstmt = null;
|
||||
String sql = GET_LATEST_EVENT_DATE;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
String mostRecentTimestampStr = rs.getString(1);
|
||||
if (mostRecentTimestampStr != null) {
|
||||
return DateUtil.parseDateString(s_gmtTimeZone, mostRecentTimestampStr);
|
||||
List<UsageEventVO> latestEvents = getLatestEvent();
|
||||
|
||||
if(latestEvents !=null && latestEvents.size() == 1){
|
||||
UsageEventVO latestEvent = latestEvents.get(0);
|
||||
if(latestEvent != null){
|
||||
return latestEvent.getId();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("error getting most recent event date", ex);
|
||||
s_logger.error("error getting most recent event id", ex);
|
||||
throw new UsageServerException(ex.getMessage());
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<UsageEventVO> findRecentEvents(Date recentEventDate, Date endDate) throws UsageServerException {
|
||||
private List<UsageEventVO> findRecentEvents(Date endDate) throws UsageServerException {
|
||||
Transaction txn = Transaction.open(Transaction.USAGE_DB);
|
||||
try {
|
||||
int i = 1;
|
||||
if (recentEventDate == null) {
|
||||
return listAllEvents(endDate);
|
||||
} else {
|
||||
return listLatestEvents(recentEventDate, endDate);
|
||||
}
|
||||
return listLatestEvents(endDate);
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("error getting most recent event date", ex);
|
||||
throw new UsageServerException(ex.getMessage());
|
||||
|
||||
@ -94,6 +94,7 @@ import com.cloud.agent.api.ModifyStoragePoolCommand;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.PingRoutingCommand;
|
||||
import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
|
||||
import com.cloud.agent.api.PingRoutingWithOvsCommand;
|
||||
import com.cloud.agent.api.PingTestCommand;
|
||||
import com.cloud.agent.api.PoolEjectCommand;
|
||||
import com.cloud.agent.api.PrepareForMigrationAnswer;
|
||||
@ -148,17 +149,22 @@ import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.PortForwardingRuleTO;
|
||||
import com.cloud.agent.api.to.StorageFilerTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO.Monitor;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO.SshMonitor;
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.HAProxyConfigurator;
|
||||
import com.cloud.network.LoadBalancerConfigurator;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.ovs.OvsCreateGreTunnelAnswer;
|
||||
import com.cloud.network.ovs.OvsCreateGreTunnelCommand;
|
||||
import com.cloud.network.ovs.OvsDeleteFlowCommand;
|
||||
import com.cloud.network.ovs.OvsSetTagAndFlowAnswer;
|
||||
import com.cloud.network.ovs.OvsSetTagAndFlowCommand;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
@ -245,6 +251,7 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
|
||||
protected StorageLayer _storage;
|
||||
protected boolean _canBridgeFirewall = false;
|
||||
protected boolean _isOvs = false;
|
||||
protected HashMap<StoragePoolType, StoragePoolResource> _pools = new HashMap<StoragePoolType, StoragePoolResource>(5);
|
||||
|
||||
public enum SRType {
|
||||
@ -443,6 +450,12 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
return execute((CheckSshCommand)cmd);
|
||||
} else if (cmd instanceof SecurityIngressRulesCmd) {
|
||||
return execute((SecurityIngressRulesCmd) cmd);
|
||||
} else if (cmd instanceof OvsCreateGreTunnelCommand) {
|
||||
return execute((OvsCreateGreTunnelCommand)cmd);
|
||||
} else if (cmd instanceof OvsSetTagAndFlowCommand) {
|
||||
return execute((OvsSetTagAndFlowCommand)cmd);
|
||||
} else if (cmd instanceof OvsDeleteFlowCommand) {
|
||||
return execute((OvsDeleteFlowCommand)cmd);
|
||||
} else {
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
@ -467,6 +480,86 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
throw new CloudRuntimeException("Unsupported network type: " + type);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a tricky to create network in xenserver.
|
||||
* if you create a network then create bridge by brctl or openvswitch yourself,
|
||||
* then you will get an expection that is "REQUIRED_NETWROK" when you start a
|
||||
* vm with this network. The soultion is, create a vif of dom0 and plug it in
|
||||
* network, xenserver will create the bridge on behalf of you
|
||||
* @throws XmlRpcException
|
||||
* @throws XenAPIException
|
||||
*/
|
||||
private void enableXenServerNetwork(Connection conn, Network nw,
|
||||
String vifNameLabel, String networkDesc) throws XenAPIException, XmlRpcException {
|
||||
/* Make sure there is a physical bridge on this network */
|
||||
VIF dom0vif = null;
|
||||
Pair<VM, VM.Record> vm = getControlDomain(conn);
|
||||
VM dom0 = vm.first();
|
||||
Set<VIF> vifs = dom0.getVIFs(conn);
|
||||
if (vifs.size() != 0) {
|
||||
for (VIF vif : vifs) {
|
||||
Map<String, String> otherConfig = vif.getOtherConfig(conn);
|
||||
if (otherConfig != null) {
|
||||
String nameLabel = otherConfig.get("nameLabel");
|
||||
if ((nameLabel != null) && nameLabel.equalsIgnoreCase(vifNameLabel)) {
|
||||
dom0vif = vif;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* create temp VIF0 */
|
||||
if (dom0vif == null) {
|
||||
s_logger.debug("Can't find a vif on dom0 for " + networkDesc + ", creating a new one");
|
||||
VIF.Record vifr = new VIF.Record();
|
||||
vifr.VM = dom0;
|
||||
vifr.device = getLowestAvailableVIFDeviceNum(conn, dom0);
|
||||
if (vifr.device == null) {
|
||||
s_logger.debug("Failed to create " + networkDesc + ", no vif available");
|
||||
return;
|
||||
}
|
||||
Map<String, String> config = new HashMap<String, String>();
|
||||
config.put("nameLabel", vifNameLabel);
|
||||
vifr.otherConfig = config;
|
||||
vifr.MAC = "FE:FF:FF:FF:FF:FF";
|
||||
vifr.network = nw;
|
||||
dom0vif = VIF.create(conn, vifr);
|
||||
dom0vif.plug(conn);
|
||||
} else {
|
||||
s_logger.debug("already have a vif on dom0 for " + networkDesc);
|
||||
if (!dom0vif.getCurrentlyAttached(conn)) {
|
||||
dom0vif.plug(conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized Network setupvSwitchNetwork(Connection conn) {
|
||||
try {
|
||||
if (_host.vswitchNetwork == null) {
|
||||
Network vswitchNw = null;
|
||||
Network.Record rec = new Network.Record();
|
||||
String nwName = Networks.BroadcastScheme.VSwitch.toString();
|
||||
Set<Network> networks = Network.getByNameLabel(conn, nwName);
|
||||
|
||||
if (networks.size() == 0) {
|
||||
rec.nameDescription = "vswitch network for " + nwName;
|
||||
rec.nameLabel = nwName;
|
||||
vswitchNw = Network.create(conn, rec);
|
||||
} else {
|
||||
vswitchNw = networks.iterator().next();
|
||||
}
|
||||
|
||||
enableXenServerNetwork(conn, vswitchNw, "vswitch",
|
||||
"vswicth network");
|
||||
_host.vswitchNetwork = vswitchNw;
|
||||
}
|
||||
return _host.vswitchNetwork;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Network getNetwork(Connection conn, NicTO nic) throws XenAPIException, XmlRpcException {
|
||||
Pair<Network, String> network = getNativeNetworkForTraffic(conn, nic.getType());
|
||||
if (nic.getBroadcastUri() != null && nic.getBroadcastUri().toString().contains("untagged")) {
|
||||
@ -478,7 +571,9 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
return enableVlanNetwork(conn, vlan, network.first(), network.second());
|
||||
} else if (nic.getBroadcastType() == BroadcastDomainType.Native || nic.getBroadcastType() == BroadcastDomainType.LinkLocal) {
|
||||
return network.first();
|
||||
}
|
||||
} else if (nic.getBroadcastType() == BroadcastDomainType.Vswitch) {
|
||||
return setupvSwitchNetwork(conn);
|
||||
}
|
||||
|
||||
throw new CloudRuntimeException("Unable to support this type of network broadcast domain: " + nic.getBroadcastUri());
|
||||
}
|
||||
@ -828,25 +923,6 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Monitor monitor = vmSpec.getMonitor();
|
||||
if (monitor != null && monitor instanceof SshMonitor) {
|
||||
SshMonitor sshMon = (SshMonitor)monitor;
|
||||
String privateIp = sshMon.getIp();
|
||||
int cmdPort = sshMon.getPort();
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Ping command port, " + privateIp + ":" + cmdPort);
|
||||
}
|
||||
|
||||
String result = connect(conn, vmName, privateIp, cmdPort);
|
||||
if (result != null) {
|
||||
throw new CloudRuntimeException("Can not ping System vm " + vmName + "due to:" + result);
|
||||
}
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Ping command port succeeded for vm " + vmName);
|
||||
}
|
||||
}
|
||||
|
||||
state = State.Running;
|
||||
return new StartAnswer(cmd);
|
||||
@ -2163,6 +2239,18 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
}
|
||||
s_logger.warn(logX(sr, "Unable to remove SR"));
|
||||
}
|
||||
|
||||
private boolean isPVInstalled(Connection conn, VM vm) throws BadServerResponse, XenAPIException, XmlRpcException {
|
||||
VMGuestMetrics vmmetric = vm.getGuestMetrics(conn);
|
||||
if (isRefNull(vmmetric)) {
|
||||
return false;
|
||||
}
|
||||
Map<String, String> PVversion = vmmetric.getPVDriversVersion(conn);
|
||||
if (PVversion != null && PVversion.containsKey("major")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected MigrateAnswer execute(final MigrateCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
@ -2186,15 +2274,18 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if it is windows, we will not fake it is migrateable,
|
||||
// windows requires PV driver to migrate
|
||||
|
||||
if ( dsthost == null ) {
|
||||
String msg = "Migration failed due to unable to find host " + ipaddr + " in XenServer pool " + _host.pool;
|
||||
s_logger.warn(msg);
|
||||
return new MigrateAnswer(cmd, false, msg, null);
|
||||
}
|
||||
for (VM vm : vms) {
|
||||
if (!cmd.isWindows()) {
|
||||
if (vm.getPVBootloader(conn).equals("pygrub") && !isPVInstalled(conn, vm)) {
|
||||
// Only fake PV driver for PV kernel, the PV driver is installed, but XenServer doesn't think it is installed
|
||||
String uuid = vm.getUuid(conn);
|
||||
String result = callHostPlugin(conn, "vmops", "preparemigration", "uuid", uuid);
|
||||
if (result == null || result.isEmpty()) {
|
||||
return new MigrateAnswer(cmd, false, "migration failed", null);
|
||||
return new MigrateAnswer(cmd, false, "migration failed due to preparemigration failed", null);
|
||||
}
|
||||
// check if pv version is successfully set up
|
||||
int i = 0;
|
||||
@ -2203,45 +2294,34 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
Thread.sleep(1000);
|
||||
} catch (final InterruptedException ex) {
|
||||
}
|
||||
VMGuestMetrics vmmetric = vm.getGuestMetrics(conn);
|
||||
|
||||
if (isRefNull(vmmetric)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<String, String> PVversion = vmmetric.getPVDriversVersion(conn);
|
||||
if (PVversion != null && PVversion.containsKey("major")) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
Set<VBD> vbds = vm.getVBDs(conn);
|
||||
for( VBD vbd : vbds) {
|
||||
VBD.Record vbdRec = vbd.getRecord(conn);
|
||||
if( vbdRec.type.equals(Types.VbdType.CD.toString()) && !vbdRec.empty ) {
|
||||
vbd.eject(conn);
|
||||
if( isPVInstalled(conn, vm) ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= 20) {
|
||||
String msg = "migration failed due to can not fake PV driver for " + vmName;
|
||||
s_logger.warn(msg);
|
||||
return new MigrateAnswer(cmd, false, msg, null);
|
||||
s_logger.warn("Can not fake PV driver for " + vmName);
|
||||
}
|
||||
}
|
||||
final Map<String, String> options = new HashMap<String, String>();
|
||||
vm.poolMigrate(conn, dsthost, options);
|
||||
Set<VBD> vbds = vm.getVBDs(conn);
|
||||
for( VBD vbd : vbds) {
|
||||
VBD.Record vbdRec = vbd.getRecord(conn);
|
||||
if( vbdRec.type.equals(Types.VbdType.CD.toString()) && !vbdRec.empty ) {
|
||||
vbd.eject(conn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
vm.poolMigrate(conn, dsthost, new HashMap<String, String>());
|
||||
} catch (Types.VmMissingPvDrivers e1) {
|
||||
// if PV driver is missing, just shutdown the VM
|
||||
s_logger.warn("VM " + vmName + " is stopped when trying to migrate it because PV driver is missing, Please install PV driver for this VM");
|
||||
vm.hardShutdown(conn);
|
||||
}
|
||||
state = State.Stopping;
|
||||
|
||||
}
|
||||
return new MigrateAnswer(cmd, true, "migration succeeded", null);
|
||||
} catch (XenAPIException e) {
|
||||
String msg = "migration failed due to " + e.toString();
|
||||
s_logger.warn(msg, e);
|
||||
return new MigrateAnswer(cmd, false, msg, null);
|
||||
} catch (XmlRpcException e) {
|
||||
String msg = "migration failed due to " + e.getMessage();
|
||||
} catch (Exception e) {
|
||||
String msg = "Catch Exception " + e.getClass().getName() + ": Migration failed due to " + e.toString();
|
||||
s_logger.warn(msg, e);
|
||||
return new MigrateAnswer(cmd, false, msg, null);
|
||||
} finally {
|
||||
@ -2603,7 +2683,7 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
}
|
||||
}
|
||||
|
||||
void startVM(Connection conn, Host host, VM vm, String vmName) {
|
||||
void startVM(Connection conn, Host host, VM vm, String vmName) throws XmlRpcException {
|
||||
try {
|
||||
vm.startOn(conn, host, false, true);
|
||||
} catch (Exception e) {
|
||||
@ -2942,7 +3022,7 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
Set<VIF> routerVIFs = router.getVIFs(conn);
|
||||
for (VIF vif : routerVIFs) {
|
||||
Network vifNetwork = vif.getNetwork(conn);
|
||||
if (vlanId.equals("untagged")) {
|
||||
if (vlanId.equalsIgnoreCase(Vlan.UNTAGGED)) {
|
||||
if (vifNetwork.getUuid(conn).equals(_host.publicNetwork)) {
|
||||
return vif;
|
||||
}
|
||||
@ -3237,9 +3317,12 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
if (newStates == null) {
|
||||
newStates = new HashMap<String, State>();
|
||||
}
|
||||
if (!_canBridgeFirewall) {
|
||||
if (!_canBridgeFirewall && !_isOvs) {
|
||||
return new PingRoutingCommand(getType(), id, newStates);
|
||||
} else {
|
||||
} else if (_isOvs) {
|
||||
List<Pair<String, Long>>ovsStates = ovsFullSyncStates();
|
||||
return new PingRoutingWithOvsCommand(getType(), id, newStates, ovsStates);
|
||||
}else {
|
||||
HashMap<String, Pair<Long, Long>> nwGrpStates = syncNetworkGroups(conn, id);
|
||||
return new PingRoutingWithNwGroupsCommand(getType(), id, newStates, nwGrpStates);
|
||||
}
|
||||
@ -3745,6 +3828,112 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
return Boolean.valueOf(callHostPlugin(conn, "vmops", "can_bridge_firewall", "host_uuid", _host.uuid));
|
||||
}
|
||||
|
||||
private Answer execute(OvsDeleteFlowCommand cmd) {
|
||||
_isOvs = true;
|
||||
|
||||
Connection conn = getConnection();
|
||||
try {
|
||||
Network nw = setupvSwitchNetwork(conn);
|
||||
String bridge = nw.getBridge(conn);
|
||||
String result = callHostPlugin(conn, "ovsgre", "ovs_delete_flow", "bridge", bridge,
|
||||
"vmName", cmd.getVmName());
|
||||
|
||||
if (result.equalsIgnoreCase("SUCCESS")) {
|
||||
return new Answer(cmd, true, "success to delete flows for " + cmd.getVmName());
|
||||
} else {
|
||||
return new Answer(cmd, false, result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Answer(cmd, false, "failed to delete flow for " + cmd.getVmName());
|
||||
}
|
||||
|
||||
private List<Pair<String, Long>> ovsFullSyncStates() {
|
||||
Connection conn = getConnection();
|
||||
try {
|
||||
String result = callHostPlugin(conn, "ovsgre", "ovs_get_vm_log", "host_uuid", _host.uuid);
|
||||
String [] logs = result != null ?result.split(";"): new String [0];
|
||||
List<Pair<String, Long>> states = new ArrayList<Pair<String, Long>>();
|
||||
for (String log: logs){
|
||||
String [] info = log.split(",");
|
||||
if (info.length != 5) {
|
||||
s_logger.warn("Wrong element number in ovs log(" + log +")");
|
||||
continue;
|
||||
}
|
||||
|
||||
//','.join([bridge, vmName, vmId, seqno, tag])
|
||||
try {
|
||||
states.add(new Pair<String,Long>(info[0], Long.parseLong(info[3])));
|
||||
} catch (NumberFormatException nfe) {
|
||||
states.add(new Pair<String,Long>(info[0], -1L));
|
||||
}
|
||||
}
|
||||
|
||||
return states;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private OvsSetTagAndFlowAnswer execute(OvsSetTagAndFlowCommand cmd) {
|
||||
_isOvs = true;
|
||||
|
||||
Connection conn = getConnection();
|
||||
try {
|
||||
Network nw = setupvSwitchNetwork(conn);
|
||||
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
|
||||
*/
|
||||
String result = callHostPlugin(conn, "ovsgre", "ovs_set_tag_and_flow", "bridge", bridge,
|
||||
"vmName", cmd.getVmName(), "tag", cmd.getTag(),
|
||||
"vlans", cmd.getVlans(), "seqno", cmd.getSeqNo());
|
||||
s_logger.debug("set flow for " + cmd.getVmName() + " " + result);
|
||||
|
||||
if (result.equalsIgnoreCase("SUCCESS")) {
|
||||
return new OvsSetTagAndFlowAnswer(cmd, true, result);
|
||||
} else {
|
||||
return new OvsSetTagAndFlowAnswer(cmd, false, result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new OvsSetTagAndFlowAnswer(cmd, false, "EXCEPTION");
|
||||
}
|
||||
|
||||
|
||||
private OvsCreateGreTunnelAnswer execute(OvsCreateGreTunnelCommand cmd) {
|
||||
_isOvs = true;
|
||||
|
||||
Connection conn = getConnection();
|
||||
String bridge = "unkonwn";
|
||||
try {
|
||||
Network nw = setupvSwitchNetwork(conn);
|
||||
bridge = nw.getBridge(conn);
|
||||
|
||||
String result = callHostPlugin(conn, "ovsgre", "ovs_create_gre", "bridge", bridge,
|
||||
"remoteIP", cmd.getRemoteIp(), "greKey", cmd.getKey(), "from",
|
||||
Long.toString(cmd.getFrom()), "to", Long.toString(cmd.getTo()));
|
||||
String[] res = result.split(":");
|
||||
if (res.length != 2 || (res.length == 2 && res[1] == "[]")) {
|
||||
return new OvsCreateGreTunnelAnswer(cmd, false, result,
|
||||
_host.ip, bridge);
|
||||
} else {
|
||||
return new OvsCreateGreTunnelAnswer(cmd, true, result, _host.ip, bridge, Integer.parseInt(res[1]));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new OvsCreateGreTunnelAnswer(cmd, false, "EXCEPTION", _host.ip, bridge);
|
||||
}
|
||||
|
||||
private Answer execute(SecurityIngressRulesCmd cmd) {
|
||||
Connection conn = getConnection();
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
@ -3846,7 +4035,8 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
}
|
||||
}
|
||||
// assume the memory Virtualization overhead is 1/64
|
||||
ram = (ram - dom0Ram) * 63/64;
|
||||
// xen hypervisor used 128 M
|
||||
ram = (ram - dom0Ram - (128 * 1024 * 1024)) * 63/64;
|
||||
cmd.setMemory(ram);
|
||||
cmd.setDom0MinMemory(dom0Ram);
|
||||
|
||||
@ -5521,6 +5711,7 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
public String publicNetwork;
|
||||
public String privateNetwork;
|
||||
public String linkLocalNetwork;
|
||||
public Network vswitchNetwork;
|
||||
public String storageNetwork1;
|
||||
public String storageNetwork2;
|
||||
public String guestNetwork;
|
||||
|
||||
@ -45,7 +45,6 @@ import com.cloud.agent.api.SecStorageSetupCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupStorageCommand;
|
||||
import com.cloud.agent.api.SecStorageFirewallCfgCommand.PortConfig;
|
||||
import com.cloud.agent.api.storage.CreateEntityDownloadURLAnswer;
|
||||
import com.cloud.agent.api.storage.CreateEntityDownloadURLCommand;
|
||||
import com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand;
|
||||
import com.cloud.agent.api.storage.DeleteTemplateCommand;
|
||||
@ -94,6 +93,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
||||
UploadManager _upldMgr;
|
||||
private String _configSslScr;
|
||||
private String _configAuthScr;
|
||||
private String _configIpFirewallScr;
|
||||
private String _publicIp;
|
||||
private String _hostname;
|
||||
private String _localgw;
|
||||
@ -189,26 +189,21 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
||||
if (!_inSystemVM){
|
||||
return new Answer(cmd, true, null);
|
||||
}
|
||||
List<String> iptablesCfg = new ArrayList<String>();
|
||||
iptablesCfg.add("iptables -F HTTP");
|
||||
|
||||
List<String> ipList = new ArrayList<String>();
|
||||
|
||||
for (PortConfig pCfg:cmd.getPortConfigs()){
|
||||
if (pCfg.isAdd()) {
|
||||
iptablesCfg.add("iptables -A HTTP -i " + pCfg.getIntf() + " -s " + pCfg.getSourceIp() + " -p tcp -m state --state NEW -m tcp --dport " + pCfg.getPort() + " -j ACCEPT");
|
||||
ipList.add(pCfg.getSourceIp());
|
||||
}
|
||||
}
|
||||
boolean success = true;
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (String rule: iptablesCfg) {
|
||||
Script command = new Script("/bin/bash", s_logger);
|
||||
command.add("-c");
|
||||
command.add(rule);
|
||||
String tmpresult = command.execute();
|
||||
if (tmpresult != null) {
|
||||
result.append(tmpresult);
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
return new Answer(cmd, success, result.toString());
|
||||
String result;
|
||||
result = configureIpFirewall(ipList);
|
||||
if (result !=null)
|
||||
success = false;
|
||||
|
||||
return new Answer(cmd, success, result);
|
||||
}
|
||||
|
||||
protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
|
||||
@ -351,6 +346,11 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
||||
s_logger.info("config_auth.sh found in " + _configAuthScr);
|
||||
}
|
||||
|
||||
_configIpFirewallScr = Script.findScript(getDefaultScriptsDir(), "ipfirewall.sh");
|
||||
if (_configIpFirewallScr != null) {
|
||||
s_logger.info("_configIpFirewallScr found in " + _configIpFirewallScr);
|
||||
}
|
||||
|
||||
_guid = (String)params.get("guid");
|
||||
if (_guid == null) {
|
||||
throw new ConfigurationException("Unable to find the guid");
|
||||
@ -525,6 +525,19 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
||||
return result;
|
||||
}
|
||||
|
||||
private String configureIpFirewall(List<String> ipList){
|
||||
Script command = new Script(_configIpFirewallScr);
|
||||
for (String ip : ipList){
|
||||
command.add(ip);
|
||||
}
|
||||
|
||||
String result = command.execute();
|
||||
if (result != null) {
|
||||
s_logger.warn("Unable to configure firewall for command : " +command);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected String mount(String path, String parent) {
|
||||
String mountPoint = null;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
13
core/src/com/cloud/storage/template/DownloadManagerImpl.java
Normal file → Executable file
13
core/src/com/cloud/storage/template/DownloadManagerImpl.java
Normal file → Executable file
@ -873,17 +873,8 @@ public class DownloadManagerImpl implements DownloadManager {
|
||||
|
||||
command = new Script("/bin/bash", s_logger);
|
||||
command.add("-c");
|
||||
command.add("iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j DROP;" +
|
||||
"iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j HTTP;" +
|
||||
"iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j DROP;" +
|
||||
"iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j HTTP;" +
|
||||
"iptables -F HTTP;" +
|
||||
"iptables -X HTTP;" +
|
||||
"iptables -N HTTP;" +
|
||||
"iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j DROP;" +
|
||||
"iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j DROP;" +
|
||||
"iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j HTTP;" +
|
||||
"iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j HTTP;");
|
||||
command.add("iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j ACCEPT;" +
|
||||
"iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j ACCEPT;");
|
||||
|
||||
result = command.execute();
|
||||
if (result != null) {
|
||||
|
||||
@ -331,9 +331,10 @@ public class UploadManagerImpl implements UploadManager {
|
||||
return new CreateEntityDownloadURLAnswer(errorString, CreateEntityDownloadURLAnswer.RESULT_FAILURE);
|
||||
}
|
||||
// Create the directory structure so that its visible under apache server root
|
||||
String extractDir = "/var/www/html/userdata/";
|
||||
Script command = new Script("mkdir", s_logger);
|
||||
command.add("-p");
|
||||
command.add("/var/www/html/copy");
|
||||
command.add(extractDir);
|
||||
String result = command.execute();
|
||||
if (result != null) {
|
||||
String errorString = "Error in creating directory =" + result;
|
||||
@ -341,11 +342,23 @@ public class UploadManagerImpl implements UploadManager {
|
||||
return new CreateEntityDownloadURLAnswer(errorString, CreateEntityDownloadURLAnswer.RESULT_FAILURE);
|
||||
}
|
||||
|
||||
// Create a symbolic link from the actual directory to the template location. The entity would be directly visible under /var/www/html/
|
||||
// Create a random file under the directory for security reasons.
|
||||
String uuid = cmd.getExtractLinkUUID();
|
||||
command = new Script("touch", s_logger);
|
||||
command.add(extractDir + uuid);
|
||||
result = command.execute();
|
||||
if (result != null) {
|
||||
String errorString = "Error in creating file " +uuid+ " ,error: " + result;
|
||||
s_logger.warn(errorString);
|
||||
return new CreateEntityDownloadURLAnswer(errorString, CreateEntityDownloadURLAnswer.RESULT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
// Create a symbolic link from the actual directory to the template location. The entity would be directly visible under /var/www/html/userdata
|
||||
cmd.getInstallPath();
|
||||
command = new Script("/bin/bash", s_logger);
|
||||
command.add("-c");
|
||||
command.add("ln -sf " + extractMountPoint + File.separator + cmd.getInstallPath() + " /var/www/html/copy/");
|
||||
command.add("ln -sf " + extractMountPoint + File.separator + cmd.getInstallPath() + " " + extractDir + uuid);
|
||||
result = command.execute();
|
||||
if (result != null) {
|
||||
String errorString = "Error in linking err=" + result;
|
||||
@ -365,8 +378,10 @@ public class UploadManagerImpl implements UploadManager {
|
||||
String path = cmd.getPath();
|
||||
Script command = new Script("/bin/bash", s_logger);
|
||||
command.add("-c");
|
||||
//We just need to remove the UUID.vhd
|
||||
command.add("unlink /var/www/html/copy/" +path.substring(path.lastIndexOf(File.separator) + 1));
|
||||
|
||||
//We just need to remove the UUID.vhd
|
||||
String extractUrl = cmd.getExtractUrl();
|
||||
command.add("unlink /var/www/html/userdata/" +extractUrl.substring(extractUrl.lastIndexOf(File.separator) + 1));
|
||||
String result = command.execute();
|
||||
if (result != null) {
|
||||
String errorString = "Error in deleting =" + result;
|
||||
@ -617,7 +632,7 @@ public class UploadManagerImpl implements UploadManager {
|
||||
//Apache Server is not running. Try to start it.
|
||||
if (result != null) {
|
||||
|
||||
s_logger.warn("Apache server not running, trying to start it");
|
||||
/*s_logger.warn("Apache server not running, trying to start it");
|
||||
String port = Integer.toString(TemplateConstants.DEFAULT_TMPLT_COPY_PORT);
|
||||
String intf = TemplateConstants.DEFAULT_TMPLT_COPY_INTF;
|
||||
|
||||
@ -639,7 +654,7 @@ public class UploadManagerImpl implements UploadManager {
|
||||
if (result != null) {
|
||||
s_logger.warn("Error in opening up httpd port err=" + result );
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
command = new Script("/bin/bash", s_logger);
|
||||
command.add("-c");
|
||||
|
||||
@ -28,6 +28,8 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
/**
|
||||
* ConsoleProxyVO domain object
|
||||
@ -97,64 +99,11 @@ public class ConsoleProxyVO extends VMInstanceVO implements ConsoleProxy {
|
||||
/**
|
||||
* Correct constructor to use.
|
||||
*/
|
||||
public ConsoleProxyVO(long id, long serviceOfferingId, String name, long templateId, long guestOSId, long dataCenterId, long domainId, long accountId, int activeSession) {
|
||||
super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, guestOSId, domainId, accountId, false);
|
||||
public ConsoleProxyVO(long id, long serviceOfferingId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long dataCenterId, long domainId, long accountId, int activeSession) {
|
||||
super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, hypervisorType, guestOSId, domainId, accountId, false);
|
||||
this.activeSession = activeSession;
|
||||
}
|
||||
|
||||
public ConsoleProxyVO(ConsoleProxyVO that) {
|
||||
this(that.id, that.serviceOfferingId, that.instanceName, that.guestMacAddress, that.guestIpAddress, that.guestNetmask, that.privateMacAddress, that.privateIpAddress, that.privateNetmask, that.templateId, that.guestOSId, that.publicMacAddress, that.publicIpAddress, that.publicNetmask, that.vlanDbId, that.vlanId, that.podId, that.dataCenterId, that.domainId, that.accountId, that.gateway, that.hostId, that.dns1, that.dns2, that.domain, that.ramSize, that.activeSession);
|
||||
this.vncPassword = that.vncPassword;
|
||||
this.sslEnabled = that.sslEnabled;
|
||||
this.sessionDetails = that.sessionDetails;
|
||||
}
|
||||
|
||||
public ConsoleProxyVO(
|
||||
long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String guestMacAddress,
|
||||
String guestIpAddress,
|
||||
String guestNetMask,
|
||||
String privateMacAddress,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
long templateId,
|
||||
long guestOSId,
|
||||
String publicMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetmask,
|
||||
Long vlanDbId,
|
||||
String vlanId,
|
||||
long podId,
|
||||
long dataCenterId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
String gateway,
|
||||
Long hostId,
|
||||
String dns1,
|
||||
String dns2,
|
||||
String domain,
|
||||
int ramSize,
|
||||
int activeSession) {
|
||||
super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, guestOSId,
|
||||
privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, hostId);
|
||||
this.gateway = gateway;
|
||||
this.publicIpAddress = publicIpAddress;
|
||||
this.publicNetmask = publicNetmask;
|
||||
this.publicMacAddress = publicMacAddress;
|
||||
this.guestIpAddress = guestIpAddress;
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
this.guestNetmask = guestNetMask;
|
||||
this.vlanDbId = vlanDbId;
|
||||
this.vlanId = vlanId;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.domain = domain;
|
||||
this.ramSize = ramSize;
|
||||
this.activeSession = activeSession;
|
||||
}
|
||||
|
||||
protected ConsoleProxyVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import javax.persistence.Enumerated;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@ -92,66 +93,17 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Role role = Role.DHCP_FIREWALL_LB_PASSWD_USERDATA;
|
||||
|
||||
public DomainRouterVO(DomainRouterVO that) {
|
||||
this(that.id, that.serviceOfferingId, that.instanceName, that.privateMacAddress, that.privateIpAddress, that.privateNetmask, that.templateId, that.guestOSId, that.guestMacAddress, that.guestIpAddress, that.guestNetmask, that.accountId, that.domainId, that.publicMacAddress, that.publicIpAddress, that.publicNetmask, that.vlanDbId, that.vlanId, that.podId, that.dataCenterId, that.ramSize, that.gateway, that.domain, that.dns1, that.dns2);
|
||||
this.vnet = that.vnet;
|
||||
this.role = that.role;
|
||||
}
|
||||
|
||||
public DomainRouterVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String privateMacAddress,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
long templateId,
|
||||
long guestOSId,
|
||||
String guestMacAddress,
|
||||
String guestIpAddress,
|
||||
String guestNetmask,
|
||||
long accountId,
|
||||
long domainId,
|
||||
String publicMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetMask,
|
||||
Long vlanDbId, String vlanId,
|
||||
long podId,
|
||||
long dataCenterId,
|
||||
int ramSize,
|
||||
String gateway,
|
||||
String domain,
|
||||
String dns1,
|
||||
String dns2) {
|
||||
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, guestOSId, privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, null);
|
||||
this.privateMacAddress = privateMacAddress;
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
this.guestIpAddress = guestIpAddress;
|
||||
this.publicIpAddress = publicIpAddress;
|
||||
this.publicMacAddress = publicMacAddress;
|
||||
this.publicNetmask = publicNetMask;
|
||||
this.vlanDbId = vlanDbId;
|
||||
this.vlanId = vlanId;
|
||||
this.ramSize = ramSize;
|
||||
this.gateway = gateway;
|
||||
this.domain = domain;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.guestNetmask = guestNetmask;
|
||||
}
|
||||
|
||||
public DomainRouterVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
long templateId,
|
||||
HypervisorType hypervisorType,
|
||||
long guestOSId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
long networkConfigurationId,
|
||||
boolean haEnabled) {
|
||||
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, guestOSId, domainId, accountId, haEnabled);
|
||||
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
|
||||
this.networkId = networkConfigurationId;
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,8 @@ import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
/**
|
||||
* SecondaryStorageVmVO domain object
|
||||
@ -89,63 +91,11 @@ public class SecondaryStorageVmVO extends VMInstanceVO implements SecondaryStora
|
||||
|
||||
|
||||
|
||||
public SecondaryStorageVmVO(long id, long serviceOfferingId, String name, long templateId, long guestOSId, long dataCenterId,
|
||||
public SecondaryStorageVmVO(long id, long serviceOfferingId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long dataCenterId,
|
||||
long domainId, long accountId) {
|
||||
super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, templateId, guestOSId, domainId, accountId, true);
|
||||
super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, templateId, hypervisorType, guestOSId, domainId, accountId, true);
|
||||
}
|
||||
|
||||
public SecondaryStorageVmVO(
|
||||
long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String guestMacAddress,
|
||||
String guestIpAddress,
|
||||
String guestNetMask,
|
||||
String privateMacAddress,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
long templateId,
|
||||
long guestOSId,
|
||||
String publicMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetmask,
|
||||
Long vlanDbId,
|
||||
String vlanId,
|
||||
long podId,
|
||||
long dataCenterId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
String gateway,
|
||||
Long hostId,
|
||||
String dns1,
|
||||
String dns2,
|
||||
String domain,
|
||||
int ramSize,
|
||||
String guid,
|
||||
String nfsShare) {
|
||||
super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, templateId, guestOSId,
|
||||
privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, hostId);
|
||||
this.gateway = gateway;
|
||||
this.publicIpAddress = publicIpAddress;
|
||||
this.publicNetmask = publicNetmask;
|
||||
this.publicMacAddress = publicMacAddress;
|
||||
this.guestIpAddress = guestIpAddress;
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
this.guestNetmask = guestNetMask;
|
||||
this.vlanDbId = vlanDbId;
|
||||
this.vlanId = vlanId;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.domain = domain;
|
||||
this.ramSize = ramSize;
|
||||
this.setGuid(guid);
|
||||
this.nfsShare = nfsShare;
|
||||
}
|
||||
|
||||
public SecondaryStorageVmVO(SecondaryStorageVmVO that) {
|
||||
this(that.id, that.serviceOfferingId, that.instanceName, that.guestMacAddress, that.guestIpAddress, that.guestNetmask, that.privateMacAddress, that.privateIpAddress, that.privateNetmask, that.templateId, that.guestOSId, that.publicMacAddress, that.publicIpAddress, that.publicNetmask, that.vlanDbId, that.vlanId, that.podId, that.dataCenterId, that.domainId, that.accountId, that.gateway, that.hostId, that.dns1, that.dns2, that.domain, that.ramSize, that.guid, that.nfsShare);
|
||||
}
|
||||
|
||||
protected SecondaryStorageVmVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
@Entity
|
||||
@ -68,7 +69,8 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
||||
private String sshPublicKey;
|
||||
|
||||
transient String password;
|
||||
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
@ -152,6 +154,7 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
||||
String instanceName,
|
||||
String displayName,
|
||||
long templateId,
|
||||
HypervisorType hypervisorType,
|
||||
long guestOsId,
|
||||
boolean haEnabled,
|
||||
long domainId,
|
||||
@ -160,44 +163,12 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
||||
String userData,
|
||||
String name,
|
||||
String sshPublicKey) {
|
||||
super(id, serviceOfferingId, name, instanceName, Type.User, templateId, guestOsId, domainId, accountId, haEnabled);
|
||||
super(id, serviceOfferingId, name, instanceName, Type.User, templateId, hypervisorType, guestOsId, domainId, accountId, haEnabled);
|
||||
this.userData = userData;
|
||||
this.displayName = displayName != null ? displayName : null;
|
||||
this.sshPublicKey = sshPublicKey;
|
||||
}
|
||||
|
||||
public UserVmVO(long id,
|
||||
String name,
|
||||
long templateId,
|
||||
long guestOSId,
|
||||
long accountId,
|
||||
long domainId,
|
||||
long serviceOfferingId,
|
||||
String guestMacAddress,
|
||||
String guestIpAddress,
|
||||
String guestNetMask,
|
||||
String externalIpAddress,
|
||||
String externalMacAddress,
|
||||
Long vlanDbId,
|
||||
Long routerId,
|
||||
long podId,
|
||||
long dcId,
|
||||
boolean haEnabled,
|
||||
String displayName,
|
||||
String userData) {
|
||||
super(id, serviceOfferingId, name, name, Type.User, templateId, guestOSId, guestMacAddress, guestIpAddress, guestNetMask, dcId, podId, domainId, accountId, haEnabled, null);
|
||||
this.domainRouterId = routerId;
|
||||
this.guestIpAddress = guestIpAddress;
|
||||
this.guestNetmask = guestNetMask;
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
this.externalIpAddress = externalIpAddress;
|
||||
this.externalMacAddress = externalMacAddress;
|
||||
this.setUserData(userData);
|
||||
this.setExternalVlanDbId(vlanDbId);
|
||||
this.isoId = null;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
protected UserVmVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ import javax.persistence.TableGenerator;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.StateMachine;
|
||||
import com.cloud.utils.fsm.FiniteStateObject;
|
||||
@ -139,12 +140,17 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
@Column(name="reservation_id")
|
||||
protected String reservationId;
|
||||
|
||||
@Column(name="hypervisor_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
protected HypervisorType hypervisorType;
|
||||
|
||||
public VMInstanceVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String instanceName,
|
||||
Type type,
|
||||
Long vmTemplateId,
|
||||
HypervisorType hypervisorType,
|
||||
long guestOSId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
@ -164,52 +170,9 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
this.hypervisorType = hypervisorType;
|
||||
}
|
||||
|
||||
|
||||
public VMInstanceVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String instanceName,
|
||||
Type type,
|
||||
long vmTemplateId,
|
||||
long guestOSId,
|
||||
String privateMacAddress,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
long dataCenterId,
|
||||
long podId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
boolean haEnabled,
|
||||
Long hostId) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
if (vmTemplateId > -1) {
|
||||
this.templateId = vmTemplateId;
|
||||
} else {
|
||||
this.templateId = null;
|
||||
}
|
||||
this.guestOSId = guestOSId;
|
||||
this.privateIpAddress = privateIpAddress;
|
||||
this.privateMacAddress = privateMacAddress;
|
||||
this.privateNetmask = privateNetmask;
|
||||
this.hostId = hostId;
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.podId = podId;
|
||||
this.type = type;
|
||||
this.haEnabled = haEnabled;
|
||||
this.instanceName = instanceName;
|
||||
this.updated = 0;
|
||||
this.updateTime = new Date();
|
||||
this.vncPassword = Long.toHexString(new Random().nextLong());
|
||||
this.state = State.Creating;
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
protected VMInstanceVO() {
|
||||
}
|
||||
|
||||
@ -239,6 +202,11 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
return hypervisorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -429,7 +429,7 @@ signature() {
|
||||
(cd ${scriptdir}/vpn; tar rvf ${MOUNTPOINT}/usr/share/cloud/cloud-scripts.tar *)
|
||||
gzip -c ${MOUNTPOINT}/usr/share/cloud/cloud-scripts.tar > ${MOUNTPOINT}/usr/share/cloud/cloud-scripts.tgz
|
||||
md5sum ${MOUNTPOINT}/usr/share/cloud/cloud-scripts.tgz |awk '{print $1}' > ${MOUNTPOINT}/var/cache/cloud/cloud-scripts-signature
|
||||
echo "Cloudstack Release 2.2 $(date)" > ${MOUNTPOINT}/etc/cloudstack-release
|
||||
echo "Cloudstack Release $CLOUDSTACK_RELEASE $(date)" > ${MOUNTPOINT}/etc/cloudstack-release
|
||||
}
|
||||
|
||||
mkdir -p $IMAGENAME
|
||||
|
||||
@ -180,8 +180,13 @@ setup_common() {
|
||||
ip route add $MGMTNET via $LOCAL_GW dev eth1
|
||||
fi
|
||||
|
||||
ip route delete default
|
||||
ip route add default via $GW dev eth2
|
||||
ip route delete default
|
||||
if [ -n "$3" ]
|
||||
then
|
||||
ip route add default via $GW dev $3
|
||||
else
|
||||
ip route add default via $GW dev eth0
|
||||
fi
|
||||
}
|
||||
|
||||
setup_dnsmasq() {
|
||||
|
||||
2
patches/systemvm/debian/config/etc/iptables/iptables-secstorage
Normal file → Executable file
2
patches/systemvm/debian/config/etc/iptables/iptables-secstorage
Normal file → Executable file
@ -12,8 +12,6 @@ COMMIT
|
||||
-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 -i eth2 -p tcp -m state --state NEW -m tcp --dport 80 -j HTTP
|
||||
-A INPUT -i eth2 -p tcp -m state --state NEW -m tcp --dport 80 -j DROP
|
||||
-A INPUT -i lo -j ACCEPT
|
||||
-A INPUT -p icmp -j ACCEPT
|
||||
-A INPUT -i eth0 -p tcp -m state --state NEW --dport 3922 -j ACCEPT
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
|
||||
# chkconfig: 35 99 10
|
||||
# description: Cloud Agent
|
||||
|
||||
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
|
||||
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
whatami=cloud-external-ipallocator
|
||||
|
||||
# set environment variables
|
||||
|
||||
SHORTNAME="$whatami"
|
||||
PIDFILE=@PIDDIR@/"$whatami".pid
|
||||
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
|
||||
LOGFILE=@AGENTLOG@
|
||||
PROGNAME="Cloud Agent"
|
||||
|
||||
unset OPTIONS
|
||||
[ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME"
|
||||
DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
|
||||
PROG=@BINDIR@/@PACKAGE@-external-ipallocator.py
|
||||
OPTIONS=8083
|
||||
|
||||
start() {
|
||||
echo -n $"Starting $PROGNAME: "
|
||||
if hostname --fqdn >/dev/null 2>&1 ; then
|
||||
daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \
|
||||
-n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
|
||||
RETVAL=$?
|
||||
echo
|
||||
else
|
||||
failure
|
||||
echo
|
||||
echo The host name does not resolve properly to an IP address. Cannot start "$PROGNAME". > /dev/stderr
|
||||
RETVAL=9
|
||||
fi
|
||||
[ $RETVAL = 0 ] && touch ${LOCKFILE}
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $PROGNAME: "
|
||||
killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
|
||||
}
|
||||
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status -p ${PIDFILE} $SHORTNAME
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
sleep 3
|
||||
start
|
||||
;;
|
||||
condrestart)
|
||||
if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
|
||||
stop
|
||||
sleep 3
|
||||
start
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
|
||||
RETVAL=3
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
|
||||
@ -34,6 +34,7 @@ Unknown = 0
|
||||
Fedora = 1
|
||||
CentOS = 2
|
||||
Ubuntu = 3
|
||||
RHEL6 = 4
|
||||
|
||||
IPV4 = 4
|
||||
IPV6 = 6
|
||||
@ -42,10 +43,14 @@ IPV6 = 6
|
||||
|
||||
if os.path.exists("/etc/fedora-release"): distro = Fedora
|
||||
elif os.path.exists("/etc/centos-release"): distro = CentOS
|
||||
elif os.path.exists("/etc/redhat-release") and not os.path.exists("/etc/fedora-release"): distro = CentOS
|
||||
elif os.path.exists("/etc/redhat-release"):
|
||||
version = file("/etc/redhat-release").readline()
|
||||
if version.find("Red Hat Enterprise Linux Server release 6") != -1:
|
||||
distro = RHEL6
|
||||
elif version.find("CentOS release") != -1:
|
||||
distro = CentOS
|
||||
elif os.path.exists("/etc/legal") and "Ubuntu" in file("/etc/legal").read(-1): distro = Ubuntu
|
||||
else: distro = Unknown
|
||||
|
||||
logFileName=None
|
||||
# ================== LIBRARY UTILITY CODE=============
|
||||
def setLogFile(logFile):
|
||||
@ -264,7 +269,7 @@ def check_hostname():
|
||||
|
||||
#check function
|
||||
def check_kvm():
|
||||
if distro in (Fedora,CentOS):
|
||||
if distro in (Fedora,CentOS,RHEL6):
|
||||
if os.path.exists("/dev/kvm"): return True
|
||||
raise CheckFailed("KVM is not correctly installed on this system, or support for it is not enabled in the BIOS")
|
||||
else:
|
||||
@ -284,7 +289,7 @@ def check_cgroups():
|
||||
|
||||
#check function
|
||||
def check_selinux():
|
||||
if distro not in [Fedora,CentOS]: return # no selinux outside of those
|
||||
if distro not in [Fedora,CentOS,RHEL6]: return # no selinux outside of those
|
||||
enforcing = False
|
||||
try:
|
||||
output = getenforce().stdout.strip()
|
||||
@ -365,7 +370,7 @@ class SetupNetworking(ConfigTask):
|
||||
self.runtime_state_changed = False
|
||||
self.was_nm_service_running = None
|
||||
self.was_net_service_running = None
|
||||
if distro in (Fedora, CentOS):
|
||||
if distro in (Fedora, CentOS, RHEL6):
|
||||
self.nmservice = 'NetworkManager'
|
||||
self.netservice = 'network'
|
||||
else:
|
||||
@ -376,7 +381,7 @@ class SetupNetworking(ConfigTask):
|
||||
def done(self):
|
||||
try:
|
||||
alreadysetup = False
|
||||
if distro in (Fedora,CentOS):
|
||||
if distro in (Fedora,CentOS, RHEL6):
|
||||
if self.pubNic != None:
|
||||
alreadysetup = alreadysetup or augtool._print("/files/etc/sysconfig/network-scripts/ifcfg-%s"%self.pubNic).stdout.strip()
|
||||
if self.prvNic != None:
|
||||
@ -463,12 +468,12 @@ class SetupNetworking(ConfigTask):
|
||||
|
||||
self.old_net_device = dev
|
||||
|
||||
if distro in (Fedora, CentOS):
|
||||
if distro in (Fedora, CentOS, RHEL6):
|
||||
inconfigfile = "/".join(augtool.match("/files/etc/sysconfig/network-scripts/*/DEVICE",dev).stdout.strip().split("/")[:-1])
|
||||
if not inconfigfile: raise TaskFailed("Device %s has not been set up in /etc/sysconfig/network-scripts"%dev)
|
||||
pathtoconfigfile = inconfigfile[6:]
|
||||
|
||||
if distro in (Fedora, CentOS):
|
||||
if distro in (Fedora, CentOS, RHEL6):
|
||||
automatic = augtool.match("%s/ONBOOT"%inconfigfile,"yes").stdout.strip()
|
||||
else:
|
||||
automatic = augtool.match("/files/etc/network/interfaces/auto/*/",dev).stdout.strip()
|
||||
@ -476,17 +481,17 @@ class SetupNetworking(ConfigTask):
|
||||
if distro is Fedora: raise TaskFailed("Device %s has not been set up in %s as automatic on boot"%dev,pathtoconfigfile)
|
||||
else: raise TaskFailed("Device %s has not been set up in /etc/network/interfaces as automatic on boot"%dev)
|
||||
|
||||
if distro not in (Fedora , CentOS):
|
||||
if distro not in (Fedora , CentOS, RHEL6):
|
||||
inconfigfile = augtool.match("/files/etc/network/interfaces/iface",dev).stdout.strip()
|
||||
if not inconfigfile: raise TaskFailed("Device %s has not been set up in /etc/network/interfaces"%dev)
|
||||
|
||||
if distro in (Fedora, CentOS):
|
||||
if distro in (Fedora, CentOS, RHEL6):
|
||||
isstatic = augtool.match(inconfigfile + "/BOOTPROTO","none").stdout.strip()
|
||||
if not isstatic: isstatic = augtool.match(inconfigfile + "/BOOTPROTO","static").stdout.strip()
|
||||
else:
|
||||
isstatic = augtool.match(inconfigfile + "/method","static").stdout.strip()
|
||||
if not isstatic:
|
||||
if distro in (Fedora, CentOS): raise TaskFailed("Device %s has not been set up as a static device in %s"%(dev,pathtoconfigfile))
|
||||
if distro in (Fedora, CentOS, RHEL6): raise TaskFailed("Device %s has not been set up as a static device in %s"%(dev,pathtoconfigfile))
|
||||
else: raise TaskFailed("Device %s has not been set up as a static device in /etc/network/interfaces"%dev)
|
||||
|
||||
if is_service_running(self.nmservice):
|
||||
@ -503,7 +508,7 @@ class SetupNetworking(ConfigTask):
|
||||
|
||||
yield "Creating Cloud bridging device and making device %s member of this bridge"%dev
|
||||
|
||||
if distro in (Fedora, CentOS):
|
||||
if distro in (Fedora, CentOS, RHEL6):
|
||||
ifcfgtext = file(pathtoconfigfile).read()
|
||||
newf = "/etc/sysconfig/network-scripts/ifcfg-%s"%self.brname
|
||||
#def restore():
|
||||
@ -687,7 +692,7 @@ class SetupLibvirt(ConfigTask):
|
||||
cfgline = "export CGROUP_DAEMON='cpu:/virt'"
|
||||
def done(self):
|
||||
try:
|
||||
if distro in (Fedora,CentOS): libvirtfile = "/etc/sysconfig/libvirtd"
|
||||
if distro in (Fedora,CentOS, RHEL6): libvirtfile = "/etc/sysconfig/libvirtd"
|
||||
elif distro is Ubuntu: libvirtfile = "/etc/default/libvirt-bin"
|
||||
else: raise AssertionError, "We should not reach this"
|
||||
return self.cfgline in file(libvirtfile,"r").read(-1)
|
||||
@ -696,14 +701,14 @@ class SetupLibvirt(ConfigTask):
|
||||
raise
|
||||
|
||||
def execute(self):
|
||||
if distro in (Fedora,CentOS): libvirtfile = "/etc/sysconfig/libvirtd"
|
||||
if distro in (Fedora,CentOS, RHEL6): libvirtfile = "/etc/sysconfig/libvirtd"
|
||||
elif distro is Ubuntu: libvirtfile = "/etc/default/libvirt-bin"
|
||||
else: raise AssertionError, "We should not reach this"
|
||||
libvirtbin = file(libvirtfile,"r").read(-1)
|
||||
libvirtbin = libvirtbin + "\n" + self.cfgline + "\n"
|
||||
file(libvirtfile,"w").write(libvirtbin)
|
||||
|
||||
if distro in (CentOS, Fedora): svc = "libvirtd"
|
||||
if distro in (CentOS, Fedora, RHEL6): svc = "libvirtd"
|
||||
else: svc = "libvirt-bin"
|
||||
stop_service(svc)
|
||||
enable_service(svc)
|
||||
@ -731,7 +736,7 @@ class SetupLiveMigration(ConfigTask):
|
||||
startswith = stanza.split("=")[0] + '='
|
||||
replace_or_add_line("/etc/libvirt/libvirtd.conf",startswith,stanza)
|
||||
|
||||
if distro is Fedora:
|
||||
if distro in (Fedora, RHEL6):
|
||||
replace_or_add_line("/etc/sysconfig/libvirtd","LIBVIRTD_ARGS=","LIBVIRTD_ARGS=-l")
|
||||
|
||||
elif distro is Ubuntu:
|
||||
@ -743,7 +748,7 @@ class SetupLiveMigration(ConfigTask):
|
||||
else:
|
||||
raise AssertionError("Unsupported distribution")
|
||||
|
||||
if distro in (CentOS, Fedora): svc = "libvirtd"
|
||||
if distro in (CentOS, Fedora, RHEL6): svc = "libvirtd"
|
||||
else: svc = "libvirt-bin"
|
||||
stop_service(svc)
|
||||
enable_service(svc)
|
||||
@ -753,14 +758,14 @@ class SetupRequiredServices(ConfigTask):
|
||||
name = "required services setup"
|
||||
|
||||
def done(self):
|
||||
if distro is Fedora: nfsrelated = "rpcbind nfslock"
|
||||
if distro in (Fedora, RHEL6): nfsrelated = "rpcbind nfslock"
|
||||
elif distro is CentOS: nfsrelated = "portmap nfslock"
|
||||
else: return True
|
||||
return all( [ is_service_running(svc) for svc in nfsrelated.split() ] )
|
||||
|
||||
def execute(self):
|
||||
|
||||
if distro is Fedora: nfsrelated = "rpcbind nfslock"
|
||||
if distro in (Fedora, RHEL6): nfsrelated = "rpcbind nfslock"
|
||||
elif distro is CentOS: nfsrelated = "portmap nfslock"
|
||||
else: raise AssertionError("Unsupported distribution")
|
||||
|
||||
@ -772,7 +777,7 @@ class SetupFirewall(ConfigTask):
|
||||
|
||||
def done(self):
|
||||
|
||||
if distro in (Fedora, CentOS):
|
||||
if distro in (Fedora, CentOS,RHEL6):
|
||||
if not os.path.exists("/etc/sysconfig/iptables"): return True
|
||||
if ":on" not in chkconfig("--list","iptables").stdout: return True
|
||||
else:
|
||||
@ -784,7 +789,7 @@ class SetupFirewall(ConfigTask):
|
||||
|
||||
def execute(self):
|
||||
ports = "22 1798 16509".split()
|
||||
if distro in (Fedora , CentOS):
|
||||
if distro in (Fedora , CentOS, RHEL6):
|
||||
for p in ports: iptables("-I","INPUT","1","-p","tcp","--dport",p,'-j','ACCEPT')
|
||||
o = service.iptables.save() ; print o.stdout + o.stderr
|
||||
else:
|
||||
@ -800,7 +805,7 @@ class SetupFirewall2(ConfigTask):
|
||||
|
||||
def done(self):
|
||||
|
||||
if distro in (Fedora, CentOS):
|
||||
if distro in (Fedora, CentOS, RHEL6):
|
||||
if not os.path.exists("/etc/sysconfig/iptables"): return True
|
||||
if ":on" not in chkconfig("--list","iptables").stdout: return True
|
||||
rule = "FORWARD -i %s -o %s -j ACCEPT"%(self.brname,self.brname)
|
||||
@ -817,7 +822,7 @@ class SetupFirewall2(ConfigTask):
|
||||
|
||||
yield "Permitting traffic in the bridge interface, migration port and for VNC ports"
|
||||
|
||||
if distro in (Fedora , CentOS):
|
||||
if distro in (Fedora , CentOS, RHEL6):
|
||||
|
||||
for rule in (
|
||||
"-I FORWARD -i %s -o %s -j ACCEPT"%(self.brname,self.brname),
|
||||
@ -856,7 +861,7 @@ def config_tasks(brname, pubNic, prvNic):
|
||||
SetupFirewall(),
|
||||
SetupFirewall2(brname),
|
||||
)
|
||||
elif distro in (Ubuntu,Fedora):
|
||||
elif distro in (Ubuntu,Fedora, RHEL6):
|
||||
config_tasks = (
|
||||
SetupNetworking(brname, pubNic, prvNic),
|
||||
SetupCgConfig(),
|
||||
@ -929,7 +934,7 @@ def prompt_for_hostpods(zonespods):
|
||||
def device_exist(devName):
|
||||
try:
|
||||
alreadysetup = False
|
||||
if distro in (Fedora,CentOS):
|
||||
if distro in (Fedora,CentOS, RHEL6):
|
||||
alreadysetup = augtool._print("/files/etc/sysconfig/network-scripts/ifcfg-%s"%devName).stdout.strip()
|
||||
else:
|
||||
alreadysetup = augtool.match("/files/etc/network/interfaces/iface",devName).stdout.strip()
|
||||
|
||||
777
scripts/vm/hypervisor/xenserver/ovsgre
Executable file
777
scripts/vm/hypervisor/xenserver/ovsgre
Executable file
@ -0,0 +1,777 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# A plugin for executing script needed by vmops cloud
|
||||
|
||||
import os, sys, time
|
||||
import XenAPIPlugin
|
||||
sys.path.append("/opt/xensource/sm/")
|
||||
import util
|
||||
from util import CommandException
|
||||
import hostvmstats
|
||||
import socket
|
||||
import stat
|
||||
import base64
|
||||
import tempfile
|
||||
from os.path import exists as _exists
|
||||
from time import localtime as _localtime, asctime as _asctime
|
||||
|
||||
vSwitchDBPidFile = "/var/run/openvswitch/ovsdb-server.pid"
|
||||
vSwitchDBDaemonName = "ovsdb-server"
|
||||
vSwitchPidFile = "/var/run/openvswitch/ovs-vswitchd.pid"
|
||||
vsctlPath = "/usr/bin/ovs-vsctl"
|
||||
vSwitchDaemonName = "ovs-vswitchd"
|
||||
|
||||
logFile = "/var/log/ovsgre.log"
|
||||
fLog = None
|
||||
|
||||
global result
|
||||
|
||||
errors = \
|
||||
{"NO_DB_PID_FILE" : "NO_DB_PID_FILE", \
|
||||
"DB_NOT_RUN" : "DB_NOT_RUN", \
|
||||
"NO_SWITCH_PID_FILE" : "NO_SWITCH_PID_FILE", \
|
||||
"SWITCH_NOT_RUN" : "SWITCH_NOT_RUN", \
|
||||
"NO_VSCTL" : "NO_VSCTL", \
|
||||
"COMMAND_FAILED" : "COMMAND_FAILED", \
|
||||
"TUNNEL_EXISTED" : "TUNNEL_EXISTED", \
|
||||
"NO_INPORT" : "NO_INPORT", \
|
||||
"NO_OFPORT" : "NO_OFPORT", \
|
||||
|
||||
"ERR_ARGS_NUM" : "ERR_ARGS_NUM", \
|
||||
"ERROR_OP" : "ERROR_OP", \
|
||||
"SUCCESS" : "SUCCESS", \
|
||||
}
|
||||
|
||||
class ovs_log(object):
|
||||
def __init__(self, name):
|
||||
n = "ovs-%s" % name;
|
||||
logfilename = "/var/run/cloud/" + n +".log"
|
||||
|
||||
self.name = logfilename
|
||||
self.vmName = name
|
||||
self.bridge = ""
|
||||
self.domId = ""
|
||||
self.seqno = ""
|
||||
self.tag = ""
|
||||
self.vifs = ""
|
||||
self.macs = ""
|
||||
self.vlans = ""
|
||||
self.ofports = ""
|
||||
|
||||
def write(self):
|
||||
log = open(self.name, "w")
|
||||
log.write("vmName=%s" % self.vmName)
|
||||
log.write("\n")
|
||||
log.write("bridge=%s" % self.bridge)
|
||||
log.write("\n")
|
||||
log.write("domId=%s" % self.domId)
|
||||
log.write("\n")
|
||||
log.write("seqno=%s" % self.seqno)
|
||||
log.write("\n")
|
||||
log.write("tag=%s" % self.tag)
|
||||
log.write("\n")
|
||||
log.write("vifs=%s" % self.vifs)
|
||||
log.write("\n")
|
||||
log.write("macs=%s" % self.macs)
|
||||
log.write("\n")
|
||||
log.write("vlans=%s" % self.vlans)
|
||||
log.write("\n")
|
||||
log.write("ofports=%s" % self.ofports)
|
||||
log.close()
|
||||
|
||||
def read(self):
|
||||
try:
|
||||
lines = [line.rstrip() for line in open(self.name)]
|
||||
for i in lines:
|
||||
if "=" not in i:
|
||||
util.SMlog("invalid line(%s) in %s" % (i, self.name))
|
||||
continue
|
||||
|
||||
(key,value) = i.split("=")
|
||||
if key == "vmName":
|
||||
self.vmName = value
|
||||
elif key == "bridge":
|
||||
self.bridge = value
|
||||
elif key == "domId":
|
||||
self.domId = value
|
||||
elif key == "seqno":
|
||||
self.seqno = value
|
||||
elif key == "tag":
|
||||
self.tag = value
|
||||
elif key == "vifs":
|
||||
self.vifs = value
|
||||
elif key == "macs":
|
||||
self.macs = value
|
||||
elif key == "vlans":
|
||||
self.vlans = value
|
||||
elif key == "ofports":
|
||||
self.ofports = value
|
||||
except Exception, e:
|
||||
util.SMlog(e.__str__())
|
||||
util.SMlog("Failed to open ovs log %s" % self.name);
|
||||
|
||||
def get_common_info(self):
|
||||
self.read()
|
||||
return "%s,%s,%s,%s,%s" % (self.vmName, self.bridge, self.domId,
|
||||
self.seqno, self.tag)
|
||||
|
||||
def remove(self):
|
||||
try:
|
||||
os.remove(self.name)
|
||||
except:
|
||||
util.SMlog("Failed to delete ovs log file " + self.name)
|
||||
|
||||
def open_log ():
|
||||
global fLog
|
||||
|
||||
try:
|
||||
if fLog == None:
|
||||
fLog = open (logFile, "a")
|
||||
except IOError, e:
|
||||
#print e
|
||||
pass
|
||||
|
||||
def pr (str):
|
||||
global fLog
|
||||
|
||||
if fLog != None:
|
||||
str = "[%s]:" % _asctime (_localtime()) + str + "\n"
|
||||
fLog.write (str)
|
||||
|
||||
def close_log ():
|
||||
global fLog
|
||||
|
||||
if fLog != None:
|
||||
fLog.close ()
|
||||
|
||||
def is_process_run (pidFile, name):
|
||||
try:
|
||||
fpid = open (pidFile, "r")
|
||||
pid = fpid.readline ()
|
||||
fpid.close ()
|
||||
except IOError, e:
|
||||
return -1
|
||||
|
||||
pid = pid[:-1]
|
||||
ps = os.popen ("ps -ae")
|
||||
for l in ps:
|
||||
if pid in l and name in l:
|
||||
ps.close ()
|
||||
return 0
|
||||
|
||||
ps.close ()
|
||||
return -2
|
||||
|
||||
def is_tool_exist (name):
|
||||
if _exists (name):
|
||||
return 0
|
||||
return -1
|
||||
|
||||
|
||||
def check_switch ():
|
||||
global result
|
||||
|
||||
ret = is_process_run (vSwitchDBPidFile, vSwitchDBDaemonName);
|
||||
if ret < 0:
|
||||
if ret == -1: result = errors["NO_DB_PID_FILE"]
|
||||
if ret == -2: result = errors["DB_NOT_RUN"]
|
||||
return -1
|
||||
|
||||
ret = is_process_run (vSwitchPidFile, vSwitchDaemonName)
|
||||
if ret < 0:
|
||||
if ret == -1: result = errors["NO_SWITCH_PID_FILE"]
|
||||
if ret == -2: result = errors["SWITCH_NOT_RUN"]
|
||||
return -1
|
||||
|
||||
if is_tool_exist (vsctlPath) < 0:
|
||||
result = errors["NO_VSCTL"]
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
def do_cmd (cmds, lines=False):
|
||||
cmd = ""
|
||||
for i in cmds:
|
||||
cmd += " "
|
||||
cmd += i
|
||||
|
||||
pr("do command '%s'" % cmd)
|
||||
f = os.popen (cmd)
|
||||
if lines == True:
|
||||
res = f.readlines ()
|
||||
else:
|
||||
res = f.readline ()
|
||||
res = res[:-1]
|
||||
f.close ()
|
||||
|
||||
if lines == False:
|
||||
pr("command output '%s'" % res)
|
||||
return res
|
||||
|
||||
######################## GRE creation utils ##########################
|
||||
# UUID's format is 8-4-4-4-12
|
||||
def is_uuid (uuid):
|
||||
list = uuid.split ("-")
|
||||
|
||||
if len (list) != 5:
|
||||
return -1
|
||||
|
||||
if len (list[0]) != 8 or len (list[1]) != 4 \
|
||||
or len (list[2]) != 4 or len (list[3]) != 4 \
|
||||
or len (list[4]) != 12:
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
def check_gre (bridge, remoteIP, greKey):
|
||||
ports = get_ports_on_bridge(bridge)
|
||||
if ports == None:
|
||||
return "[]"
|
||||
|
||||
for i in ports:
|
||||
ifaces = get_interface_on_port(i)
|
||||
if ifaces == None:
|
||||
continue
|
||||
|
||||
for j in ifaces:
|
||||
if j == '[]':
|
||||
continue
|
||||
options = get_field_of_interface(j, "options")
|
||||
if remoteIP in options and greKey in options:
|
||||
pr("WARNING: GRE tunnel for remote_ip=%s key=%s already here, \
|
||||
interface(%s)" % (remoteIP, greKey, j))
|
||||
return get_field_of_interface(j, "ofport")
|
||||
|
||||
return "[]"
|
||||
|
||||
def ovs_create_gre (session, args):
|
||||
global result
|
||||
bridge = args.pop("bridge")
|
||||
remoteIP = args.pop("remoteIP")
|
||||
greKey = args.pop("greKey")
|
||||
srcHost = args.pop("from")
|
||||
dstHost = args.pop("to")
|
||||
|
||||
name = "%s-%s" % (srcHost, dstHost)
|
||||
res = check_gre(bridge, remoteIP, greKey)
|
||||
if res != "[]":
|
||||
result = "SUCCESS:%s" % res
|
||||
return result
|
||||
|
||||
wait = [vsctlPath, "--timeout=30 wait-until bridge %s -- get bridge %s name" % \
|
||||
(bridge, bridge)]
|
||||
res = do_cmd(wait)
|
||||
if bridge not in res:
|
||||
pr("WARNIING:Can't find bridge %s for creating tunnel!" % bridge)
|
||||
result = errors["COMMAND_FAILED"]
|
||||
return result
|
||||
|
||||
createInterface = [vsctlPath, "create interface", "name=%s" % name, \
|
||||
'type=gre options:"remote_ip=%s key=%s"' % (remoteIP, greKey)]
|
||||
ifaceUUID = do_cmd (createInterface)
|
||||
if is_uuid (ifaceUUID) < 0:
|
||||
result = errors["COMMAND_FAILED"];
|
||||
return result
|
||||
|
||||
createPort = [vsctlPath, "create port", "name=%s" % name, \
|
||||
"interfaces=[%s]" % ifaceUUID]
|
||||
portUUID = do_cmd (createPort)
|
||||
if is_uuid (portUUID) < 0:
|
||||
result = errors["COMMAND_FAILED"];
|
||||
return result
|
||||
|
||||
addBridge = [vsctlPath, "add bridge %s" % bridge, "ports %s" % portUUID]
|
||||
do_cmd (addBridge)
|
||||
|
||||
wait = [vsctlPath, "--timeout=5 wait-until port %s -- get port %s name" % \
|
||||
(name, name)]
|
||||
res = do_cmd(wait)
|
||||
if name in res:
|
||||
port = get_field_of_interface(name, "ofport");
|
||||
result = "SUCCESS:%s" % port
|
||||
else:
|
||||
result = errors["COMMAND_FAILED"]
|
||||
|
||||
return result
|
||||
######################## End GRE creation utils ##########################
|
||||
|
||||
######################## Flow creation utils ##########################
|
||||
def get_ports_on_bridge(bridge):
|
||||
listBr = [vsctlPath, "list br", bridge]
|
||||
res = do_cmd(listBr, True)
|
||||
|
||||
for i in res:
|
||||
if "ports" in i:
|
||||
(x, str) = i.split(":")
|
||||
str = str.lstrip().rstrip()
|
||||
str = str[1:]
|
||||
str = str[:-1]
|
||||
return str.split(",")
|
||||
return None
|
||||
|
||||
def get_filed_of_port(nameOruuid, field):
|
||||
listport = [vsctlPath, "list port", nameOruuid]
|
||||
res = do_cmd(listport, True)
|
||||
|
||||
for i in res:
|
||||
if field in i:
|
||||
(x, r) = i.split(":")
|
||||
return r.lstrip().rstrip()
|
||||
return None
|
||||
|
||||
def get_field_of_interface(nameOruuid, field):
|
||||
listIface = [vsctlPath, "list interface", nameOruuid]
|
||||
res = do_cmd(listIface, True)
|
||||
|
||||
for i in res:
|
||||
if field in i:
|
||||
(x, r) = i.split(":")
|
||||
return r.lstrip().rstrip()
|
||||
return None
|
||||
|
||||
def strip(str, direction="default"):
|
||||
str = str.lstrip().rstrip()
|
||||
if direction == "left":
|
||||
return str[1:]
|
||||
if direction == "right":
|
||||
return str[:-1]
|
||||
if direction == "both":
|
||||
str = str[1:]
|
||||
str = str[:-1]
|
||||
return str
|
||||
return str
|
||||
|
||||
def get_vif_port(bridge, vifName):
|
||||
portUuids = get_ports_on_bridge(bridge)
|
||||
if portUuids == None:
|
||||
pr("No ports on bridge %s" % bridge)
|
||||
return None
|
||||
|
||||
for i in portUuids:
|
||||
name = get_filed_of_port(i, "name")
|
||||
if name == None:
|
||||
pr("WARNING: no name found for %s" % name)
|
||||
continue
|
||||
|
||||
name = strip(name, "both")
|
||||
if name == vifName:
|
||||
return get_field_of_interface(vifName, "ofport")
|
||||
return None
|
||||
|
||||
def get_interface_on_port(nameOruuid):
|
||||
listPort = [vsctlPath, "list port", nameOruuid]
|
||||
res = do_cmd(listPort, True)
|
||||
|
||||
for i in res:
|
||||
if "interfaces" in i:
|
||||
(x, str) = i.split(":")
|
||||
str = strip(str, "both")
|
||||
return str.split(",")
|
||||
return None
|
||||
|
||||
def get_ofports_by_tag(bridge, tag):
|
||||
portUuids = get_ports_on_bridge(bridge)
|
||||
if portUuids == None:
|
||||
pr("WARNING:No ports on bridge %s" % bridge)
|
||||
return []
|
||||
|
||||
OfPorts = []
|
||||
for i in portUuids:
|
||||
t = get_filed_of_port(i, "tag")
|
||||
if t != tag:
|
||||
pr("Skip port %s with tag=%s" % (i, t))
|
||||
continue
|
||||
|
||||
iface = get_filed_of_port(i, "interfaces")
|
||||
iface = strip(iface, "both")
|
||||
port = get_field_of_interface(iface, "ofport")
|
||||
if port != '[]':
|
||||
OfPorts.append(port)
|
||||
|
||||
return OfPorts
|
||||
|
||||
def format_flow(inPort, vlan, mac, outPut):
|
||||
flow = "in_port=%s dl_vlan=%s dl_dst=%s idle_timeout=0 hard_timeout=0 \
|
||||
priority=10000 actions=strip_vlan,output:%s" % (inPort, vlan, mac, outPut)
|
||||
return flow
|
||||
|
||||
def format_drop_flow(inPort, vlan):
|
||||
flow = "in_port=%s dl_vlan=%s priority=0 idle_timeout=0 hard_timeout=0 \
|
||||
actions=drop" % (inPort, vlan)
|
||||
return flow
|
||||
|
||||
def del_flow(bridge, mac):
|
||||
param = "dl_dst=%s" % mac
|
||||
flow = ["ovs-ofctl del-flows %s" % bridge, '"%s"' % param]
|
||||
do_cmd(flow)
|
||||
|
||||
def del_arp_and_dhcp_flow(bridge, vlan, inPort):
|
||||
param = "dl_type=0x0806 dl_vlan=%s in_port=%s" % (vlan, inPort)
|
||||
flow = ["ovs-ofctl del-flows %s" % bridge, '"%s"' % param]
|
||||
do_cmd(flow)
|
||||
|
||||
param = "dl_type=0x0800 nw_proto=17 tp_dst=68 dl_vlan=%s, in_port=%s" % (vlan, inPort)
|
||||
flow = ["ovs-ofctl del-flows %s" % bridge, '"%s"' % param]
|
||||
do_cmd(flow)
|
||||
|
||||
param = "dl_type=0x0800 nw_proto=17 tp_dst=67 dl_vlan=%s, in_port=%s" % (vlan, inPort)
|
||||
flow = ["ovs-ofctl del-flows %s" % bridge, '"%s"' % param]
|
||||
do_cmd(flow)
|
||||
|
||||
def del_drop_flow(bridge, vlan):
|
||||
param = "priority=0 dl_vlan=%s" % vlan
|
||||
flow = ["ovs-ofctl del-flows %s" % bridge, '"%s"' % param]
|
||||
do_cmd(flow)
|
||||
|
||||
def format_normal_flow():
|
||||
flow = "priority=0 idle_timeout=0 hard_timeout=0 actions=normal"
|
||||
return flow
|
||||
|
||||
def format_dhcp_flow(bridge, inPort, vlan, ports):
|
||||
outputs = ''
|
||||
for i in ports:
|
||||
str = "output:%s," % i
|
||||
outputs += str
|
||||
outputs = outputs[:-1]
|
||||
flow = "in_port=%s dl_vlan=%s dl_type=0x0800 nw_proto=17 tp_dst=67 idle_timeout=0 hard_timeout=0 \
|
||||
priority=10000 actions=strip_vlan,%s" % (inPort, vlan, outputs)
|
||||
return flow
|
||||
|
||||
def format_dhcp_client_flow(bridge, inPort, vlan, ports):
|
||||
outputs = ''
|
||||
for i in ports:
|
||||
str = "output:%s," % i
|
||||
outputs += str
|
||||
outputs = outputs[:-1]
|
||||
flow = "in_port=%s dl_vlan=%s dl_type=0x0800 nw_proto=17 tp_dst=68 idle_timeout=0 hard_timeout=0 \
|
||||
priority=10000 actions=strip_vlan,%s" % (inPort, vlan, outputs)
|
||||
return flow
|
||||
|
||||
def format_arp_flow(bridge, inPort, vlan, ports):
|
||||
outputs = ''
|
||||
for i in ports:
|
||||
str = "output:%s," % i
|
||||
outputs += str
|
||||
|
||||
outputs = outputs[:-1]
|
||||
flow = "in_port=%s dl_vlan=%s dl_type=0x0806 idle_timeout=0 hard_timeout=0 \
|
||||
priority=10000 actions=strip_vlan,%s" % (inPort, vlan, outputs)
|
||||
return flow
|
||||
|
||||
def create_flow (bridge, vifName, mac, vlans):
|
||||
global result
|
||||
|
||||
output = get_vif_port(bridge, vifName)
|
||||
if output == None:
|
||||
pr("WARNING: cannot find ofport for %s" % vifName)
|
||||
return errors["NO_OFPORT"]
|
||||
return -1
|
||||
if output == '[]':
|
||||
pr("WARNING: ofport is [] for %s" % vifName)
|
||||
return errors["NO_OFPORT"]
|
||||
return -1
|
||||
|
||||
#set remap here, remap has format e.g. 1/22/200/13/16
|
||||
pr("")
|
||||
pr("Create flow for vlans=%s" % vlans)
|
||||
for v in vlans.split(","):
|
||||
try:
|
||||
(vlan, inPort) = v.split(":")
|
||||
flow = format_drop_flow(inPort, vlan)
|
||||
add_flow(bridge, flow)
|
||||
|
||||
flow = format_flow(inPort, vlan, mac, output)
|
||||
add_flow(bridge, flow)
|
||||
except Exception, e:
|
||||
pr(e.__str__())
|
||||
pr("invalid map")
|
||||
|
||||
# add normal flow make switch work as L2/L3 switch
|
||||
flow = format_normal_flow()
|
||||
add_flow(bridge, flow)
|
||||
|
||||
return errors["SUCCESS"]
|
||||
######################## End Flow creation utils ##########################
|
||||
|
||||
def set_tag(bridge, vifName, vlan):
|
||||
# The startVM command is slow, we may wait for a while for it creates vif on
|
||||
# open vswitch
|
||||
pr("Waiting for %s ..." % vifName)
|
||||
waitPortCmd = [vsctlPath, "--timeout=10 wait-until port %s -- get port %s name" % \
|
||||
(vifName, vifName)]
|
||||
do_cmd (waitPortCmd)
|
||||
pr("%s is here" % vifName)
|
||||
|
||||
if get_vif_port(bridge, vifName) == None:
|
||||
pr("WARNING: %s is not on bridge %s" % (vifName, bridge))
|
||||
return 0
|
||||
|
||||
pr("Set tag")
|
||||
set_tagCmd = [vsctlPath, "set port", vifName, "tag=%s"%vlan]
|
||||
do_cmd (set_tagCmd)
|
||||
return 0
|
||||
|
||||
def ask_ports(bridge, vifNames):
|
||||
vifs = vifNames.split(",")
|
||||
if len(vifs) == 0:
|
||||
return ' '
|
||||
|
||||
ofports = []
|
||||
for vif in vifs:
|
||||
op = get_vif_port(bridge, vif)
|
||||
if op == None:
|
||||
pr("ask_ports: no port(bridge:%s, vif:%s)" % (bridge, vif))
|
||||
continue
|
||||
ofports.append(op)
|
||||
|
||||
return ",".join(ofports)
|
||||
|
||||
def delete_vm_flows(bridge, vmName, reCreate=True):
|
||||
log = ovs_log(vmName)
|
||||
log.read()
|
||||
|
||||
macs = log.macs;
|
||||
for i in macs.split(","):
|
||||
del_flow(bridge, i)
|
||||
pr("Delete flows for %s" % i)
|
||||
|
||||
vlans = log.vlans
|
||||
for v in vlans.split(","):
|
||||
try:
|
||||
(vlan, inPort) = v.split(":")
|
||||
del_arp_and_dhcp_flow(bridge, vlan, inPort)
|
||||
except Exception, e:
|
||||
pr(e.__str__())
|
||||
pr("invalid map")
|
||||
|
||||
for v in vlans:
|
||||
try:
|
||||
(vlan, inport) = v.split(":")
|
||||
del_drop_flow(bridge, vlan)
|
||||
except Exception, e:
|
||||
pr(e.__str__())
|
||||
pr("invalid map")
|
||||
|
||||
if reCreate == False:
|
||||
return
|
||||
|
||||
bridge = log.bridge
|
||||
tag = log.tag
|
||||
noneGreOfPorts = get_ofports_by_tag(bridge, tag)
|
||||
|
||||
try:
|
||||
noneGreOfPorts.remove(log.ofports)
|
||||
except Exception, e:
|
||||
pr(e.__str__())
|
||||
pr("ofport %s of %s is not on bridge %s" % (log.ofports, log.vmName,
|
||||
bridge))
|
||||
|
||||
if len(noneGreOfPorts) != 0:
|
||||
set_arp_and_dhcp_flow(bridge, vlans, tag, noneGreOfPorts)
|
||||
|
||||
# add normal flow make switch work as L2/L3 switch
|
||||
flow = format_normal_flow()
|
||||
add_flow(bridge, flow)
|
||||
|
||||
log.remove()
|
||||
|
||||
def echo(fn):
|
||||
def wrapped(*v, **k):
|
||||
name = fn.__name__
|
||||
util.SMlog("#### VMOPS enter %s ####" % name )
|
||||
res = fn(*v, **k)
|
||||
util.SMlog("#### VMOPS exit %s ####" % name )
|
||||
return res
|
||||
return wrapped
|
||||
|
||||
|
||||
def ovs_handle_rebooted_vm(session, vmName):
|
||||
curr_domid = '-1'
|
||||
log = ovs_log(vmName)
|
||||
log.read()
|
||||
|
||||
(curr_domid, vifrs, hostuuid) = ovs_get_domid_vifrs_hostuuid(session, vmName)
|
||||
|
||||
old_id = log.domId;
|
||||
if curr_domid == old_id:
|
||||
util.SMlog("OvsInfo:%s is normal" % vmName)
|
||||
return True
|
||||
|
||||
util.SMlog("%s rebooted, reset flow for it" % vmName)
|
||||
vlans = log.vlans;
|
||||
bridge = log.bridge
|
||||
tag = log.tag
|
||||
for vifr in vifrs:
|
||||
vifName = "vif" + curr_domid + "." + vifr[0]
|
||||
set_tag(bridge, vifName, tag)
|
||||
create_flow(bridge, vifName, vifr[1], vlans)
|
||||
|
||||
log.domId = curr_domid
|
||||
log.write()
|
||||
|
||||
return True
|
||||
|
||||
@echo
|
||||
def ovs_get_vm_log(session, args):
|
||||
host_uuid = args.pop('host_uuid')
|
||||
try:
|
||||
thishost = session.xenapi.host.get_by_uuid(host_uuid)
|
||||
hostrec = session.xenapi.host.get_record(thishost)
|
||||
vms = hostrec.get('resident_VMs')
|
||||
except Exception, e:
|
||||
util.SMlog("Failed to get host from uuid %s, exception: %s" % (host_uuid, e.__str__()))
|
||||
return ' '
|
||||
|
||||
result = []
|
||||
try:
|
||||
for name in [session.xenapi.VM.get_name_label(x) for x in vms]:
|
||||
if 1 not in [ name.startswith(c) for c in ['r-', 'i-'] ]:
|
||||
continue
|
||||
ovs_handle_rebooted_vm(session, name)
|
||||
if name.startswith('i-'):
|
||||
log = ovs_log(name)
|
||||
info = log.get_common_info()
|
||||
result.append(info)
|
||||
except Exception, e:
|
||||
util.SMlog(e.__str__())
|
||||
util.SMlog("OVs failed to get logs, better luck next time!")
|
||||
|
||||
return ";".join(result)
|
||||
|
||||
def ovs_write_vm_log(bridge, vmName, vmId, seqno, vifNames, macs, tag, vlans, ofports):
|
||||
log = ovs_log(vmName)
|
||||
log.read()
|
||||
log.bridge = bridge
|
||||
log.vmName = vmName
|
||||
log.domId = vmId
|
||||
log.seqno = seqno
|
||||
log.vifs = vifNames
|
||||
log.macs = macs
|
||||
log.tag = tag
|
||||
log.vlans = vlans
|
||||
log.ofports = ofports
|
||||
log.write()
|
||||
|
||||
util.SMlog("Writing ovs log to " + log.name)
|
||||
|
||||
@echo
|
||||
def ovs_delete_flow(session, args):
|
||||
bridge = args.pop('bridge')
|
||||
vmName = args.pop('vmName')
|
||||
|
||||
delete_vm_flows(bridge, vmName)
|
||||
return 'SUCCESS'
|
||||
|
||||
def ovs_get_domid_vifrs_hostuuid(session, vmName):
|
||||
def get_vif_field(name, field):
|
||||
return session.xenapi.VIF.get_record(name).get(field)
|
||||
|
||||
try:
|
||||
vm = session.xenapi.VM.get_by_name_label(vmName)
|
||||
if len(vm) != 1:
|
||||
return 'NO_VM'
|
||||
vm_rec = session.xenapi.VM.get_record(vm[0])
|
||||
vm_vifs = vm_rec.get('VIFs')
|
||||
vifrs = []
|
||||
for vif in vm_vifs:
|
||||
rec = (get_vif_field(vif, 'device'), get_vif_field(vif, 'MAC'))
|
||||
vifrs.append(rec)
|
||||
domid = vm_rec.get('domid')
|
||||
host = vm_rec.get('resident_on')
|
||||
host_rec = session.xenapi.host.get_record(host)
|
||||
uuid = host_rec.get('uuid')
|
||||
util.SMlog("OVSINFO: (domid:%s, uuid:%s)" % (domid, uuid))
|
||||
return (domid, vifrs, uuid)
|
||||
|
||||
except:
|
||||
util.SMlog("### Failed to get domid or vif list for vm ##" + vmName)
|
||||
return (-1, [], "-1")
|
||||
|
||||
def add_flow(bridge, flow):
|
||||
param = bridge + ' "%s"' % flow
|
||||
addflow = ["ovs-ofctl add-flow", param]
|
||||
do_cmd (addflow)
|
||||
|
||||
def set_arp_and_dhcp_flow(bridge, vlans, tag, ofports):
|
||||
for v in vlans.split(","):
|
||||
try:
|
||||
(vlan, inPort) = v.split(":")
|
||||
arpFlow = format_arp_flow(bridge, inPort, vlan, ofports)
|
||||
add_flow(bridge, arpFlow)
|
||||
|
||||
dhcpFlow = format_dhcp_flow(bridge, inPort, vlan, ofports)
|
||||
add_flow(bridge, dhcpFlow)
|
||||
|
||||
dhcpClientFlow = format_dhcp_client_flow(bridge, inPort, vlan, ofports)
|
||||
add_flow(bridge, dhcpClientFlow)
|
||||
except Exception, e:
|
||||
pr(e.__str__())
|
||||
pr("invalid map")
|
||||
|
||||
@echo
|
||||
def ovs_set_arp_and_dhcp_flow(session, args):
|
||||
vlans = args.pop('vlans')
|
||||
bridge = args.pop('bridge')
|
||||
tag = args.pop('tag')
|
||||
|
||||
pr("ovs_set_arp_and_dhcp_flow: bridge=%s, vlans=%s, tag=%s" % (bridge,
|
||||
vlans, tag))
|
||||
if vlans == '[]':
|
||||
pr("No need to create arp and dhcp flow")
|
||||
return 'SUCCESS'
|
||||
|
||||
ofports = get_ofports_by_tag(bridge, tag)
|
||||
if len(ofports) == 0:
|
||||
pr("No VMs, skip set arp and dhcp flow for tag=%s" % tag)
|
||||
return 'SUCCESS'
|
||||
|
||||
set_arp_and_dhcp_flow(bridge, vlans, tag, ofports)
|
||||
return 'SUCCESS'
|
||||
|
||||
@echo
|
||||
def ovs_set_tag_and_flow(session, args):
|
||||
bridge = args.pop('bridge')
|
||||
vmName = args.pop('vmName')
|
||||
vlans = args.pop('vlans')
|
||||
tag = args.pop('tag')
|
||||
seqno = args.pop('seqno')
|
||||
|
||||
(domid, vifrs, hostuuid) = ovs_get_domid_vifrs_hostuuid(session, vmName)
|
||||
|
||||
if domid == '-1':
|
||||
util.SMlog("### Failed to get domid for vm (-1): " + vmName)
|
||||
return 'NO_DOMID'
|
||||
|
||||
if len(vifrs) == 0:
|
||||
return 'SUCCESS'
|
||||
|
||||
pr("ovs_set_tag_and_flow: bridge=%s, vmName=%s, vlans=%s, tag=%s, seqno=%s" %
|
||||
(bridge, vmName, vlans, tag, seqno))
|
||||
#delete old flows first
|
||||
delete_vm_flows(bridge, vmName, False)
|
||||
|
||||
vifNames = []
|
||||
vlans = strip(vlans, "both")
|
||||
macs = []
|
||||
for vifr in vifrs:
|
||||
vifName = "vif" + domid + "." + vifr[0]
|
||||
vifNames.append(vifName)
|
||||
mac = vifr[1]
|
||||
macs.append(mac)
|
||||
set_tag(bridge, vifName, tag)
|
||||
create_flow(bridge, vifName, mac, vlans)
|
||||
|
||||
vifs = ",".join(vifNames)
|
||||
ofports = ask_ports(bridge, vifs)
|
||||
ovs_write_vm_log(bridge, vmName, domid, seqno, vifs, ",".join(macs), tag, vlans, ofports)
|
||||
|
||||
#see if there is rebooted vm to handle
|
||||
ovs_get_vm_log(session, {"host_uuid":hostuuid})
|
||||
ovs_set_arp_and_dhcp_flow(session, {"bridge":bridge, "tag":tag, "vlans":vlans})
|
||||
return 'SUCCESS'
|
||||
|
||||
if __name__ == "__main__":
|
||||
open_log()
|
||||
XenAPIPlugin.dispatch({"ovs_create_gre":ovs_create_gre, "ovs_set_tag_and_flow":ovs_set_tag_and_flow, "ovs_get_vm_log":ovs_get_vm_log,"ovs_delete_flow":ovs_delete_flow})
|
||||
close_log()
|
||||
|
||||
@ -358,7 +358,7 @@ def can_bridge_firewall(session, args):
|
||||
util.pread2(['iptables', '-D', 'FORWARD', '-j', 'RH-Firewall-1-INPUT'])
|
||||
except:
|
||||
util.SMlog('Chain BRIDGE-FIREWALL already exists')
|
||||
privnic = get_private_nic(session,args)
|
||||
privnic = get_private_nic(session, args)
|
||||
result = 'true'
|
||||
try:
|
||||
util.pread2(['/bin/bash', '-c', 'iptables -n -L FORWARD | grep BRIDGE-FIREWALL'])
|
||||
@ -374,7 +374,7 @@ def can_bridge_firewall(session, args):
|
||||
os.makedirs('/var/run/cloud')
|
||||
|
||||
cleanup_rules_for_dead_vms(session)
|
||||
cleanup_rules(session)
|
||||
cleanup_rules(session, args)
|
||||
|
||||
return result
|
||||
|
||||
@ -414,13 +414,13 @@ def destroy_network_rules_for_vm(session, args):
|
||||
vmchain = '-'.join(vm_name.split('-')[:-1])
|
||||
vmchain_default = '-'.join(vm_name.split('-')[:-2]) + "-def"
|
||||
|
||||
destroy_ebtables_rules(vmchain)
|
||||
try:
|
||||
util.pread2(['iptables', '-F', vmchain_default])
|
||||
util.pread2(['iptables', '-X', vmchain_default])
|
||||
except:
|
||||
util.SMlog("Ignoring failure to delete chain " + vmchain_default)
|
||||
|
||||
try:
|
||||
util.pread2(['iptables', '-F', vmchain_default])
|
||||
util.pread2(['iptables', '-X', vmchain_default])
|
||||
except:
|
||||
util.SMlog("Ignoring failure to delete chain " + vmchain_default)
|
||||
destroy_ebtables_rules(vmchain)
|
||||
|
||||
try:
|
||||
util.pread2(['iptables', '-F', vmchain])
|
||||
@ -518,8 +518,7 @@ def default_ebtables_rules(vm_name, vif, vm_ip, vm_mac):
|
||||
except:
|
||||
util.SMlog("Failed to program default ebtables OUT rules")
|
||||
return 'false'
|
||||
|
||||
|
||||
|
||||
@echo
|
||||
def default_network_rules_systemvm(session, args):
|
||||
vm_name = args.pop('vmName')
|
||||
@ -591,15 +590,21 @@ def default_network_rules(session, args):
|
||||
return 'false'
|
||||
|
||||
vif = "vif" + domid + ".0"
|
||||
tap = "tap" + domid + ".0"
|
||||
vifs = [vif]
|
||||
try:
|
||||
util.pread2(['ifconfig', tap])
|
||||
vifs.append(tap)
|
||||
except:
|
||||
pass
|
||||
|
||||
delete_rules_for_vm_in_bridge_firewall_chain(vm_name)
|
||||
|
||||
|
||||
vm_name = '-'.join(vm_name.split('-')[:-1])
|
||||
vmchain = vm_name
|
||||
vmchain_default = '-'.join(vmchain.split('-')[:-1]) + "-def"
|
||||
vmchain = '-'.join(vm_name.split('-')[:-1])
|
||||
vmchain_default = '-'.join(vm_name.split('-')[:-2]) + "-def"
|
||||
|
||||
destroy_ebtables_rules(vm_name)
|
||||
destroy_ebtables_rules(vmchain)
|
||||
|
||||
|
||||
try:
|
||||
@ -630,7 +635,8 @@ def default_network_rules(session, args):
|
||||
util.SMlog("Failed to program default rules for vm " + vm_name)
|
||||
return 'false'
|
||||
|
||||
default_ebtables_rules(vm_name, vif, vm_ip, vm_mac)
|
||||
for v in vifs:
|
||||
default_ebtables_rules(vm_name, v, vm_ip, vm_mac)
|
||||
|
||||
if write_rule_log_for_vm(vmName, vm_id, vm_ip, domid, '_initial_', '-1') == False:
|
||||
util.SMlog("Failed to log default network rules, ignoring")
|
||||
@ -666,10 +672,9 @@ def check_domid_changed(session, vmName):
|
||||
|
||||
def delete_rules_for_vm_in_bridge_firewall_chain(vmName):
|
||||
vm_name = vmName
|
||||
if vm_name.startswith('i-') or vm_name.startswith('r-'):
|
||||
vm_name = '-'.join(vm_name.split('-')[:-2])
|
||||
|
||||
vmchain = vm_name
|
||||
if vm_name.startswith('i-') or vm_name.startswith('r-'):
|
||||
vmchain = '-'.join(vm_name.split('-')[:-1])
|
||||
|
||||
delcmd = "iptables -S BRIDGE-FIREWALL | grep " + vmchain + " | sed 's/-A/-D/'"
|
||||
delcmds = util.pread2(['/bin/bash', '-c', delcmd]).split('\n')
|
||||
@ -726,7 +731,7 @@ def network_rules_for_rebooted_vm(session, vmName):
|
||||
inscmd2 = "iptables -S " + vmchain_default + " | grep physdev-in | grep tap | sed -r 's/tap[0-9]+.0/" + tap + "/' | sed 's/-A/-I/'"
|
||||
|
||||
ipts = []
|
||||
for cmd in [delcmd, inscmd]:
|
||||
for cmd in [delcmd, inscmd, inscmd2]:
|
||||
cmds = util.pread2(['/bin/bash', '-c', cmd]).split('\n')
|
||||
cmds.pop()
|
||||
for c in cmds:
|
||||
@ -824,7 +829,7 @@ def cleanup_rules_for_dead_vms(session):
|
||||
|
||||
|
||||
@echo
|
||||
def cleanup_rules(session):
|
||||
def cleanup_rules(session, args):
|
||||
try:
|
||||
chainscmd = "iptables-save | grep '^:' | grep -v '.*-def' | awk '{print $1}' | cut -d':' -f2"
|
||||
chains = util.pread2(['/bin/bash', '-c', chainscmd]).split('\n')
|
||||
@ -851,9 +856,12 @@ def cleanup_rules(session):
|
||||
for vmname in cleanup:
|
||||
destroy_network_rules_for_vm(session, {'vmName':vmname})
|
||||
|
||||
util.SMlog("Cleaned up rules for " + str(len(cleanup)) + " chains")
|
||||
util.SMlog("Cleaned up rules for " + str(len(cleanup)) + " chains")
|
||||
return str(len(cleanup))
|
||||
except:
|
||||
util.SMlog("Failed to cleanup rules !")
|
||||
return '-1';
|
||||
|
||||
|
||||
@echo
|
||||
def check_rule_log_for_vm(vmName, vmID, vmIP, domID, signature, seqno):
|
||||
@ -939,6 +947,13 @@ def network_rules(session, args):
|
||||
return 'false'
|
||||
|
||||
vif = "vif" + domid + ".0"
|
||||
tap = "tap" + domid + ".0"
|
||||
vifs = [vif]
|
||||
try:
|
||||
util.pread2(['ifconfig', tap])
|
||||
vifs.append(tap)
|
||||
except:
|
||||
pass
|
||||
vm_name = '-'.join(vm_name.split('-')[:-1])
|
||||
vmchain = vm_name
|
||||
|
||||
@ -1017,5 +1032,5 @@ def network_rules(session, args):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats": gethostvmstats, "getvncport": getvncport, "getgateway": getgateway, "preparemigration": preparemigration, "setIptables": setIptables, "pingdomr": pingdomr, "pingxenserver": pingxenserver, "ipassoc": ipassoc, "vm_data": vm_data, "savePassword": savePassword, "saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule, "setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile, "deleteFile": deleteFile, "networkUsage": networkUsage, "network_rules":network_rules, "can_bridge_firewall":can_bridge_firewall, "default_network_rules":default_network_rules, "destroy_network_rules_for_vm":destroy_network_rules_for_vm, "default_network_rules_systemvm":default_network_rules_systemvm, "get_rule_logs_for_vms":get_rule_logs_for_vms, "setLinkLocalIP":setLinkLocalIP, "lt2p_vpn":lt2p_vpn})
|
||||
XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats": gethostvmstats, "getvncport": getvncport, "getgateway": getgateway, "preparemigration": preparemigration, "setIptables": setIptables, "pingdomr": pingdomr, "pingxenserver": pingxenserver, "ipassoc": ipassoc, "vm_data": vm_data, "savePassword": savePassword, "saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule, "setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile, "deleteFile": deleteFile, "networkUsage": networkUsage, "network_rules":network_rules, "can_bridge_firewall":can_bridge_firewall, "default_network_rules":default_network_rules, "destroy_network_rules_for_vm":destroy_network_rules_for_vm, "default_network_rules_systemvm":default_network_rules_systemvm, "get_rule_logs_for_vms":get_rule_logs_for_vms, "setLinkLocalIP":setLinkLocalIP, "lt2p_vpn":lt2p_vpn, "cleanup_rules":cleanup_rules})
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
NFSSR.py=/opt/xensource/sm
|
||||
nfs.py=/opt/xensource/sm
|
||||
vmops=..,0755,/etc/xapi.d/plugins
|
||||
ovsgre=..,0755,/etc/xapi.d/plugins
|
||||
vmopsSnapshot=..,0755,/etc/xapi.d/plugins
|
||||
hostvmstats.py=..,0755,/opt/xensource/sm
|
||||
systemvm.iso=../../../../../vms,0644,/opt/xensource/packages/iso
|
||||
|
||||
@ -486,7 +486,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
|
||||
final ServiceOfferingVO offering, final VMTemplateVO template,
|
||||
VMInstanceVO vm, Host currentHost, final Set<Host> avoid) {
|
||||
VirtualMachineProfileImpl<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>(
|
||||
vm, template, offering, null, null, null);
|
||||
vm, template, offering, null, null);
|
||||
DeployDestination dest = null;
|
||||
DataCenterDeployment plan = new DataCenterDeployment(dc.getId(),
|
||||
pod.getId(), sp.getClusterId(), null);
|
||||
@ -1531,7 +1531,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
|
||||
Long dcId = host.getDataCenterId();
|
||||
ReadyCommand ready = new ReadyCommand(dcId);
|
||||
Answer answer = easySend(hostId, ready);
|
||||
if (answer == null) {
|
||||
if (answer == null || !answer.getResult()) {
|
||||
// this is tricky part for secondary storage
|
||||
// make it as disconnected, wait for secondary storage VM to be up
|
||||
// return the attache instead of null, even it is disconnectede
|
||||
|
||||
@ -60,6 +60,10 @@ public class Commands {
|
||||
addCommand(null, cmd);
|
||||
}
|
||||
|
||||
public void addCommand(int index, Command cmd) {
|
||||
_cmds.add(index, cmd);
|
||||
}
|
||||
|
||||
public Answer getAnswer(String id) {
|
||||
int i = _ids.indexOf(id);
|
||||
return i == -1 ? null : _answers[i];
|
||||
|
||||
@ -38,7 +38,7 @@ import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
@ -250,14 +250,14 @@ public class UserConcentratedAllocator implements PodAllocator {
|
||||
so = _offeringDao.findById(userVm.getServiceOfferingId());
|
||||
} else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomP", 1,
|
||||
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
_proxyRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else {
|
||||
assert(false) : "Unsupported system vm type";
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
}
|
||||
|
||||
if(capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {
|
||||
|
||||
@ -509,7 +509,7 @@ public class ApiDBUtils {
|
||||
}
|
||||
|
||||
public static long getPublicNetworkIdByZone(long zoneId) {
|
||||
return _networkMgr.getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(zoneId, TrafficType.Public, null);
|
||||
return _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
}
|
||||
|
||||
public static Long getVlanNetworkId(long vlanId) {
|
||||
|
||||
@ -113,7 +113,6 @@ import com.cloud.network.security.SecurityGroup;
|
||||
import com.cloud.network.security.SecurityGroupRules;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.server.Criteria;
|
||||
@ -740,7 +739,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
volResponse.setDeviceId(volume.getDeviceId());
|
||||
|
||||
Long instanceId = volume.getInstanceId();
|
||||
if (instanceId != null) {
|
||||
if (instanceId != null && volume.getState() != Volume.State.Destroy) {
|
||||
VMInstanceVO vm = ApiDBUtils.findVMInstanceById(instanceId);
|
||||
volResponse.setVirtualMachineId(vm.getId());
|
||||
volResponse.setVirtualMachineName(vm.getName());
|
||||
@ -1084,16 +1083,11 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
if (singleNic.getIsolationUri() != null) {
|
||||
nicResponse.setIsolationUri(singleNic.getIsolationUri().toString());
|
||||
}
|
||||
}
|
||||
//Set traffic type
|
||||
}
|
||||
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
|
||||
nicResponse.setTrafficType(network.getTrafficType().toString());
|
||||
|
||||
//Set type
|
||||
NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
|
||||
if (networkOffering.getGuestIpType() != null) {
|
||||
nicResponse.setType(networkOffering.getGuestIpType().toString());
|
||||
}
|
||||
nicResponse.setType(network.getGuestType().toString());
|
||||
nicResponse.setIsDefault(singleNic.isDefaultNic());
|
||||
|
||||
nicResponse.setObjectName("nic");
|
||||
|
||||
@ -2174,9 +2168,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setDisplayText(offering.getDisplayText());
|
||||
response.setTags(offering.getTags());
|
||||
response.setTrafficType(offering.getTrafficType().toString());
|
||||
if (offering.getGuestIpType() != null) {
|
||||
response.setType(offering.getGuestIpType().toString());
|
||||
}
|
||||
response.setMaxconnections(offering.getConcurrentConnections());
|
||||
response.setIsDefault(offering.isDefault());
|
||||
response.setSpecifyVlan(offering.getSpecifyVlan());
|
||||
@ -2232,6 +2223,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
}
|
||||
|
||||
response.setIsShared(network.isShared());
|
||||
response.setIsDefault(network.isDefault());
|
||||
response.setState(network.getState().toString());
|
||||
response.setRelated(network.getRelated());
|
||||
response.setDns1(network.getDns1());
|
||||
|
||||
@ -28,6 +28,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
@ -39,8 +40,8 @@ public class ApiXmlDocReader {
|
||||
String oldFile = null;
|
||||
String dirName = "";
|
||||
|
||||
HashMap<String, Command> commands = new HashMap<String,Command>();
|
||||
HashMap<String, Command> oldCommands = new HashMap<String,Command>();
|
||||
LinkedHashMap<String, Command> commands = new LinkedHashMap<String,Command>();
|
||||
LinkedHashMap<String, Command> oldCommands = new LinkedHashMap<String,Command>();
|
||||
ArrayList<Command> addedCommands = new ArrayList<Command>();
|
||||
ArrayList<Command> removedCommands = new ArrayList<Command>();
|
||||
HashMap<String, Command> stableCommands = new HashMap<String, Command>();
|
||||
@ -117,13 +118,23 @@ public class ApiXmlDocReader {
|
||||
//Print added commands
|
||||
out.write("Added commands:\n");
|
||||
for (Command c : addedCommands) {
|
||||
out.write("\n " + c.getName() + " (" + c.getDescription() + "\n");
|
||||
if (c.getDescription() != null && !c.getDescription().isEmpty()) {
|
||||
out.write("\n " + c.getName() + " (" + c.getDescription() + ")\n");
|
||||
} else {
|
||||
out.write("\n " + c.getName() + "\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Print removed commands
|
||||
out.write("\nRemoved commands:\n");
|
||||
for (Command c : removedCommands) {
|
||||
out.write("\n " + c.getName() + " (" + c.getDescription() + ")\n");
|
||||
if (c.getDescription() != null && !c.getDescription().isEmpty()) {
|
||||
out.write("\n " + c.getName() + " (" + c.getDescription() + ")\n");
|
||||
} else {
|
||||
out.write("\n " + c.getName() + "\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Print differences between commands arguments
|
||||
@ -167,18 +178,21 @@ public class ApiXmlDocReader {
|
||||
}
|
||||
|
||||
//Check if any response arguments were added in new version
|
||||
for (Argument arg : newCommand.getResponse()) {
|
||||
if (oldCommand.getResArgByName(arg.getName()) == null) {
|
||||
newRespArgs.add(arg);
|
||||
}
|
||||
if (newCommand.getResponse() != null && oldCommand.getResponse() != null) {
|
||||
for (Argument arg : newCommand.getResponse()) {
|
||||
if (oldCommand.getResArgByName(arg.getName()) == null) {
|
||||
newRespArgs.add(arg);
|
||||
}
|
||||
}
|
||||
|
||||
//Check if any response arguments were removed in new version
|
||||
for (Argument arg : oldCommand.getResponse()) {
|
||||
if (newCommand.getResArgByName(arg.getName()) == null) {
|
||||
removedRespArgs.add(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check if any response arguments were removed in new version
|
||||
for (Argument arg : oldCommand.getResponse()) {
|
||||
if (newCommand.getResArgByName(arg.getName()) == null) {
|
||||
removedRespArgs.add(arg);
|
||||
}
|
||||
}
|
||||
|
||||
if (newReqArgs.size() != 0 || newRespArgs.size() != 0 || removedReqArgs.size() != 0 || removedRespArgs.size() != 0 || stableReqArgs.size() != 0 || stableReqArgs.size() != 0) {
|
||||
out.write("\n\t" + key);
|
||||
@ -186,21 +200,33 @@ public class ApiXmlDocReader {
|
||||
if (newReqArgs.size() != 0 || removedReqArgs.size() != 0 || stableReqArgs.size() != 0) {
|
||||
out.write("\n\t\tRequest");
|
||||
if (newReqArgs.size() != 0){
|
||||
out.write("\n\t\t\tNew parameters: ");
|
||||
StringBuffer newParameters = new StringBuffer();
|
||||
newParameters.append("\n\t\t\tNew parameters: ");
|
||||
for (Argument newArg: newReqArgs) {
|
||||
out.write(newArg.getName());
|
||||
String isRequiredParam = "optional";
|
||||
if (newArg.isRequired()) {
|
||||
isRequiredParam = "required";
|
||||
}
|
||||
newParameters.append(newArg.getName() + " (" + isRequiredParam + "), ");
|
||||
}
|
||||
newParameters.delete(newParameters.length()-2, newParameters.length()-1);
|
||||
out.write(newParameters.toString());
|
||||
out.write("\n");
|
||||
}
|
||||
if (removedReqArgs.size() != 0){
|
||||
out.write("\n\t\t\tRemoved parameters: ");
|
||||
StringBuffer removedParameters = new StringBuffer();
|
||||
removedParameters.append("\n\t\t\tRemoved parameters: ");
|
||||
for (Argument removedArg: removedReqArgs) {
|
||||
out.write(removedArg.getName());
|
||||
removedParameters.append(removedArg.getName() + ", ");
|
||||
}
|
||||
removedParameters.delete(removedParameters.length()-2, removedParameters.length()-1);
|
||||
out.write(removedParameters.toString());
|
||||
out.write("\n");
|
||||
}
|
||||
out.write("\n");
|
||||
|
||||
if (stableReqArgs.size() != 0){
|
||||
out.write("\n\t\t\tChanged parameters: ");
|
||||
StringBuffer changedParameters = new StringBuffer();
|
||||
changedParameters.append("\n\t\t\tChanged parameters: ");
|
||||
for (Argument stableArg: stableReqArgs.values()) {
|
||||
String newRequired = "optional";
|
||||
String oldRequired = "optional";
|
||||
@ -208,29 +234,37 @@ public class ApiXmlDocReader {
|
||||
oldRequired = "required";
|
||||
if (newCommand.getReqArgByName(stableArg.getName()).isRequired() == true)
|
||||
newRequired = "required";
|
||||
|
||||
out.write(stableArg.getName() + " (old version - " + oldRequired + ", new version - " + newRequired + ") ");
|
||||
changedParameters.append(stableArg.getName() + " (old version - " + oldRequired + ", new version - " + newRequired + "), ");
|
||||
}
|
||||
changedParameters.delete(changedParameters.length() - 2, changedParameters.length() - 1);
|
||||
out.write(changedParameters.toString());
|
||||
out.write("\n");
|
||||
}
|
||||
out.write("\n");
|
||||
|
||||
}
|
||||
|
||||
//Response
|
||||
if (newRespArgs.size() != 0 || removedRespArgs.size() != 0 || stableRespArgs.size() != 0) {
|
||||
out.write("\n\t\tResponse:");
|
||||
StringBuffer changedResponseParams = new StringBuffer();
|
||||
changedResponseParams.append("\n\t\tResponse:");
|
||||
if (newRespArgs.size() != 0){
|
||||
changedResponseParams.append("\n\t\t\tNew parameters: ");
|
||||
out.write("\n\t\t\tNew parameters: ");
|
||||
for (Argument newArg: newRespArgs) {
|
||||
out.write(newArg.getName());
|
||||
changedResponseParams.append(newArg.getName() + ", ");
|
||||
}
|
||||
changedResponseParams.delete(changedResponseParams.length() - 2, changedResponseParams.length() - 1);
|
||||
out.write("\n");
|
||||
}
|
||||
if (removedRespArgs.size() != 0){
|
||||
out.write("\n\t\t\tRemoved parameters: ");
|
||||
changedResponseParams.append("\n\t\t\tRemoved parameters: ");
|
||||
for (Argument removedArg: removedRespArgs) {
|
||||
changedResponseParams.append(removedArg.getName());
|
||||
out.write(removedArg.getName());
|
||||
}
|
||||
}
|
||||
changedResponseParams.delete(changedResponseParams.length() - 2, changedResponseParams.length() - 1);
|
||||
out.write(changedResponseParams.toString());
|
||||
out.write("\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,18 +18,26 @@
|
||||
|
||||
package com.cloud.api.doc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.TreeMap;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -39,21 +47,27 @@ import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.BaseResponse;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
public class ApiXmlDocWriter {
|
||||
public static final Logger s_logger = Logger
|
||||
.getLogger(ApiXmlDocWriter.class.getName());
|
||||
private static Properties api_commands = new Properties();
|
||||
public static final Logger s_logger = Logger.getLogger(ApiXmlDocWriter.class.getName());
|
||||
|
||||
private static final short DOMAIN_ADMIN_COMMAND = 2;
|
||||
private static final short USER_COMMAND = 8;
|
||||
private static LinkedHashMap<Object, String> all_api_commands = new LinkedHashMap<Object, String>();
|
||||
private static LinkedHashMap<Object, String> domain_admin_api_commands = new LinkedHashMap<Object, String>();
|
||||
private static LinkedHashMap<Object, String> regular_user_api_commands = new LinkedHashMap<Object, String>();
|
||||
private static TreeMap<Object, String> all_api_commands_sorted = new TreeMap<Object, String>();
|
||||
private static TreeMap<Object, String> domain_admin_api_commands_sorted = new TreeMap<Object, String>();
|
||||
private static TreeMap<Object, String> regular_user_api_commands_sorted = new TreeMap<Object, String>();
|
||||
private static String dirName="";
|
||||
|
||||
public static void main (String[] args) {
|
||||
Properties preProcessedCommands = new Properties();
|
||||
Enumeration command = null;
|
||||
LinkedProperties preProcessedCommands = new LinkedProperties();
|
||||
String[] fileNames = null;
|
||||
ArrayList<Command> commands = new ArrayList<Command>();
|
||||
|
||||
List<String> argsList = Arrays.asList(args);
|
||||
Iterator<String> iter = argsList.iterator();
|
||||
@ -86,98 +100,273 @@ public class ApiXmlDocWriter {
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<?> propertiesIterator = preProcessedCommands.keys.iterator();
|
||||
//Get command classes and response object classes
|
||||
for (Object key : preProcessedCommands.keySet()) {
|
||||
String preProcessedCommand = preProcessedCommands.getProperty((String)key);
|
||||
while (propertiesIterator.hasNext()) {
|
||||
String key = (String)propertiesIterator.next();
|
||||
String preProcessedCommand = preProcessedCommands.getProperty(key);
|
||||
String[] commandParts = preProcessedCommand.split(";");
|
||||
api_commands.put(key, commandParts[0]);
|
||||
String commandName = commandParts[0];
|
||||
all_api_commands.put(key, commandName);
|
||||
|
||||
short cmdPermissions = 1;
|
||||
if (commandParts.length > 1 && commandParts[1] != null) {
|
||||
cmdPermissions = Short.parseShort(commandParts[1]);
|
||||
}
|
||||
|
||||
if ((cmdPermissions & DOMAIN_ADMIN_COMMAND) != 0) {
|
||||
domain_admin_api_commands.put(key, commandName);
|
||||
}
|
||||
if ((cmdPermissions & USER_COMMAND) != 0) {
|
||||
regular_user_api_commands.put(key, commandName);
|
||||
}
|
||||
}
|
||||
|
||||
command = api_commands.propertyNames();
|
||||
all_api_commands_sorted.putAll(all_api_commands);
|
||||
domain_admin_api_commands_sorted.putAll(domain_admin_api_commands);
|
||||
regular_user_api_commands_sorted.putAll(regular_user_api_commands);
|
||||
|
||||
try {
|
||||
//Create object writer
|
||||
XStream xs = new XStream();
|
||||
xs.alias("command", Command.class);
|
||||
xs.alias("arg", Argument.class);
|
||||
String xmlDocDir = dirName + "/xmldoc";
|
||||
String rootAdminDirName = xmlDocDir + "/root_admin";
|
||||
String domainAdminDirName = xmlDocDir + "/domain_admin";
|
||||
String regularUserDirName = xmlDocDir + "/regular_user";
|
||||
(new File(rootAdminDirName)).mkdirs();
|
||||
(new File(domainAdminDirName)).mkdirs();
|
||||
(new File(regularUserDirName)).mkdirs();
|
||||
|
||||
ObjectOutputStream out = xs.createObjectOutputStream(new FileWriter(dirName + "/commands.xml"), "commands");
|
||||
ObjectOutputStream rootAdmin = xs.createObjectOutputStream(new FileWriter(rootAdminDirName + "/" + "rootAdminSummary.xml"), "commands");
|
||||
ObjectOutputStream rootAdminSorted = xs.createObjectOutputStream(new FileWriter(rootAdminDirName + "/" + "rootAdminSummarySorted.xml"), "commands");
|
||||
ObjectOutputStream domainAdmin = xs.createObjectOutputStream(new FileWriter(domainAdminDirName + "/" + "domainAdminSummary.xml"), "commands");
|
||||
ObjectOutputStream outDomainAdminSorted = xs.createObjectOutputStream(new FileWriter(domainAdminDirName + "/" + "domainAdminSummarySorted.xml"), "commands");
|
||||
ObjectOutputStream regularUser = xs.createObjectOutputStream(new FileWriter(regularUserDirName + "/regularUserSummary.xml"), "commands");
|
||||
ObjectOutputStream regularUserSorted = xs.createObjectOutputStream(new FileWriter(regularUserDirName + "/regularUserSummarySorted.xml"), "commands");
|
||||
|
||||
while (command.hasMoreElements()) {
|
||||
String key = (String) command.nextElement();
|
||||
Class clas = Class.forName(api_commands.getProperty(key));
|
||||
ArrayList<Argument> request = new ArrayList<Argument>();
|
||||
ArrayList<Argument> response = new ArrayList<Argument>();
|
||||
//Write commands in the order they are represented in commands.properties.in file
|
||||
Iterator<?> it = all_api_commands.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = (String)it.next();
|
||||
|
||||
//Create a new command, set name and description
|
||||
Command apiCommand = new Command();
|
||||
apiCommand.setName(key);
|
||||
//Write admin commands
|
||||
writeCommand(out, key);
|
||||
writeCommand(rootAdmin, key);
|
||||
|
||||
//Write single commands to separate xml files
|
||||
ObjectOutputStream singleRootAdminCommandOs = xs.createObjectOutputStream(new FileWriter(rootAdminDirName + "/" + key + ".xml"), "command");
|
||||
writeCommand(singleRootAdminCommandOs, key);
|
||||
singleRootAdminCommandOs.close();
|
||||
|
||||
|
||||
Implementation impl = (Implementation)clas.getAnnotation(Implementation.class);
|
||||
if (impl == null)
|
||||
impl = (Implementation)clas.getSuperclass().getAnnotation(Implementation.class);
|
||||
String commandDescription = impl.description();
|
||||
if (commandDescription != null)
|
||||
apiCommand.setDescription(commandDescription);
|
||||
else
|
||||
System.out.println("Command " + apiCommand.getName() + " misses description");
|
||||
|
||||
//Get request parameters
|
||||
Field[] fields = clas.getDeclaredFields();
|
||||
|
||||
//Get fields from superclass
|
||||
Class<?> superClass = clas.getSuperclass();
|
||||
String superName = superClass.getName();
|
||||
if (!superName.equals(BaseCmd.class.getName()) && !superName.equals(BaseAsyncCmd.class.getName()) && !superName.equals(BaseAsyncCreateCmd.class.getName())) {
|
||||
Field[] superClassFields = superClass.getDeclaredFields();
|
||||
if (superClassFields != null && !superClass.getName().equals(BaseListCmd.class.getName())) {
|
||||
Field[] tmpFields = new Field[fields.length + superClassFields.length];
|
||||
System.arraycopy(fields, 0, tmpFields, 0, fields.length);
|
||||
System.arraycopy(superClassFields, 0, tmpFields, fields.length, superClassFields.length);
|
||||
fields = tmpFields;
|
||||
}
|
||||
superClass = superClass.getSuperclass();
|
||||
}
|
||||
|
||||
for (Field f : fields) {
|
||||
Parameter parameterAnnotation = f.getAnnotation(Parameter.class);
|
||||
if (parameterAnnotation != null) {
|
||||
Argument reqArg = new Argument(parameterAnnotation.name());
|
||||
reqArg.setRequired(parameterAnnotation.required());
|
||||
if (!parameterAnnotation.description().isEmpty() && parameterAnnotation.expose())
|
||||
reqArg.setDescription(parameterAnnotation.description());
|
||||
else if (parameterAnnotation.expose()) {
|
||||
//System.out.println("Description is missing for the parameter " + parameterAnnotation.name() + " of the command " + apiCommand.getName() );
|
||||
}
|
||||
request.add(reqArg);
|
||||
}
|
||||
if (domain_admin_api_commands.containsKey(key)){
|
||||
writeCommand(domainAdmin, key);
|
||||
ObjectOutputStream singleDomainAdminCommandOs = xs.createObjectOutputStream(new FileWriter(domainAdminDirName + "/" + key + ".xml"), "command");
|
||||
writeCommand(singleDomainAdminCommandOs, key);
|
||||
singleDomainAdminCommandOs.close();
|
||||
}
|
||||
|
||||
Class responseClas = impl.responseObject();
|
||||
|
||||
//Get response parameters
|
||||
Field[] responseFields = responseClas.getDeclaredFields();
|
||||
for (Field responseField : responseFields) {
|
||||
SerializedName nameAnnotation = responseField.getAnnotation(SerializedName.class);
|
||||
Param descAnnotation = responseField.getAnnotation(Param.class);
|
||||
Argument respArg = new Argument(nameAnnotation.value());
|
||||
if (descAnnotation != null)
|
||||
respArg.setDescription(descAnnotation.description());
|
||||
response.add(respArg);
|
||||
if (regular_user_api_commands.containsKey(key)){
|
||||
writeCommand(regularUser, key);
|
||||
ObjectOutputStream singleRegularUserCommandOs = xs.createObjectOutputStream(new FileWriter(regularUserDirName + "/" + key + ".xml"), "command");
|
||||
writeCommand(singleRegularUserCommandOs, key);
|
||||
singleRegularUserCommandOs.close();
|
||||
}
|
||||
|
||||
apiCommand.setRequest(request);
|
||||
apiCommand.setResponse(response);
|
||||
commands.add(apiCommand);
|
||||
|
||||
//Write command to xml file
|
||||
out.writeObject(apiCommand);
|
||||
}
|
||||
|
||||
//Write sorted commands
|
||||
it = all_api_commands_sorted.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = (String)it.next();
|
||||
writeCommand(rootAdminSorted, key);
|
||||
|
||||
|
||||
if (domain_admin_api_commands.containsKey(key)){
|
||||
writeCommand(outDomainAdminSorted, key);
|
||||
}
|
||||
|
||||
if (regular_user_api_commands.containsKey(key)){
|
||||
writeCommand(regularUserSorted, key);
|
||||
}
|
||||
}
|
||||
|
||||
out.close();
|
||||
rootAdmin.close();
|
||||
rootAdminSorted.close();
|
||||
domainAdmin.close();
|
||||
outDomainAdminSorted.close();
|
||||
regularUser.close();
|
||||
regularUserSorted.close();
|
||||
|
||||
//gzip directory with xml doc
|
||||
zipDir(dirName + "xmldoc.zip", xmlDocDir);
|
||||
|
||||
//Delete directory
|
||||
deleteDir(new File(xmlDocDir));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void writeCommand(ObjectOutputStream out, String command) throws ClassNotFoundException, IOException{
|
||||
Class<?> clas = Class.forName(all_api_commands.get(command));
|
||||
ArrayList<Argument> request = new ArrayList<Argument>();
|
||||
ArrayList<Argument> response = new ArrayList<Argument>();
|
||||
|
||||
//Create a new command, set name and description
|
||||
Command apiCommand = new Command();
|
||||
apiCommand.setName(command);
|
||||
|
||||
Implementation impl = (Implementation)clas.getAnnotation(Implementation.class);
|
||||
if (impl == null)
|
||||
impl = (Implementation)clas.getSuperclass().getAnnotation(Implementation.class);
|
||||
String commandDescription = impl.description();
|
||||
if (commandDescription != null)
|
||||
apiCommand.setDescription(commandDescription);
|
||||
else
|
||||
System.out.println("Command " + apiCommand.getName() + " misses description");
|
||||
|
||||
//Set request parameters
|
||||
Field[] fields = clas.getDeclaredFields();
|
||||
|
||||
//Get fields from superclass
|
||||
Class<?> superClass = clas.getSuperclass();
|
||||
String superName = superClass.getName();
|
||||
if (!superName.equals(BaseCmd.class.getName()) && !superName.equals(BaseAsyncCmd.class.getName()) && !superName.equals(BaseAsyncCreateCmd.class.getName())) {
|
||||
Field[] superClassFields = superClass.getDeclaredFields();
|
||||
if (superClassFields != null && !superClass.getName().equals(BaseListCmd.class.getName())) {
|
||||
Field[] tmpFields = new Field[fields.length + superClassFields.length];
|
||||
System.arraycopy(fields, 0, tmpFields, 0, fields.length);
|
||||
System.arraycopy(superClassFields, 0, tmpFields, fields.length, superClassFields.length);
|
||||
fields = tmpFields;
|
||||
}
|
||||
superClass = superClass.getSuperclass();
|
||||
}
|
||||
request = setRequestFields(fields);
|
||||
|
||||
|
||||
//Get response parameters
|
||||
Class<?> responseClas = impl.responseObject();
|
||||
Field[] responseFields = responseClas.getDeclaredFields();
|
||||
response = setResponseFields(responseFields);
|
||||
|
||||
apiCommand.setRequest(request);
|
||||
apiCommand.setResponse(response);
|
||||
|
||||
out.writeObject(apiCommand);
|
||||
}
|
||||
|
||||
|
||||
private static ArrayList<Argument> setRequestFields(Field[] fields) {
|
||||
ArrayList<Argument> arguments = new ArrayList<Argument>();
|
||||
for (Field f : fields) {
|
||||
Parameter parameterAnnotation = f.getAnnotation(Parameter.class);
|
||||
if (parameterAnnotation != null && parameterAnnotation.expose()) {
|
||||
Argument reqArg = new Argument(parameterAnnotation.name());
|
||||
reqArg.setRequired(parameterAnnotation.required());
|
||||
if (!parameterAnnotation.description().isEmpty()) {
|
||||
reqArg.setDescription(parameterAnnotation.description());
|
||||
}
|
||||
arguments.add(reqArg);
|
||||
}
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private static ArrayList<Argument> setResponseFields(Field[] responseFields) {
|
||||
ArrayList<Argument> arguments = new ArrayList<Argument>();
|
||||
for (Field responseField : responseFields) {
|
||||
SerializedName nameAnnotation = responseField.getAnnotation(SerializedName.class);
|
||||
Param paramAnnotation = responseField.getAnnotation(Param.class);
|
||||
Argument respArg = new Argument(nameAnnotation.value());
|
||||
boolean toExpose = true;
|
||||
if (paramAnnotation != null) {
|
||||
String description = paramAnnotation.description();
|
||||
Class fieldClass = paramAnnotation.responseObject();
|
||||
toExpose = paramAnnotation.expose();
|
||||
if (description != null && !description.isEmpty()) {
|
||||
respArg.setDescription(description);
|
||||
}
|
||||
|
||||
if (fieldClass != null) {
|
||||
Class<?> superClass = fieldClass.getSuperclass();
|
||||
if (superClass != null) {
|
||||
String superName = superClass.getName();
|
||||
if (superName.equals(BaseResponse.class.getName())) {
|
||||
ArrayList<Argument> fieldArguments = new ArrayList<Argument>();
|
||||
Field[] fields = fieldClass.getDeclaredFields();
|
||||
fieldArguments = setResponseFields(fields);
|
||||
respArg.setArguments(fieldArguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (toExpose) {
|
||||
arguments.add(respArg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private static void zipDir(String zipFileName, String dir) throws Exception {
|
||||
File dirObj = new File(dir);
|
||||
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName));
|
||||
addDir(dirObj, out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
static void addDir(File dirObj, ZipOutputStream out) throws IOException {
|
||||
File[] files = dirObj.listFiles();
|
||||
byte[] tmpBuf = new byte[1024];
|
||||
String pathToDir = dirName;
|
||||
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].isDirectory()) {
|
||||
addDir(files[i], out);
|
||||
continue;
|
||||
}
|
||||
FileInputStream in = new FileInputStream(files[i].getPath());
|
||||
out.putNextEntry(new ZipEntry(files[i].getPath().substring(pathToDir.length())));
|
||||
int len;
|
||||
while ((len = in.read(tmpBuf)) > 0) {
|
||||
out.write(tmpBuf, 0, len);
|
||||
}
|
||||
out.closeEntry();
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteDir(File dir) {
|
||||
if (dir.isDirectory()) {
|
||||
String[] children = dir.list();
|
||||
for (int i=0; i<children.length; i++) {
|
||||
deleteDir(new File(dir, children[i]));
|
||||
}
|
||||
}
|
||||
dir.delete();
|
||||
}
|
||||
|
||||
|
||||
private static class LinkedProperties extends Properties {
|
||||
private final LinkedList<Object> keys = new LinkedList<Object>();
|
||||
|
||||
public Enumeration<Object> keys() {
|
||||
return Collections.<Object>enumeration(keys);
|
||||
}
|
||||
|
||||
public Object put(Object key, Object value) {
|
||||
//System.out.println("Adding key" + key);
|
||||
keys.add(key);
|
||||
return super.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -18,10 +18,13 @@
|
||||
|
||||
package com.cloud.api.doc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Argument{
|
||||
private String name;
|
||||
private String description;
|
||||
private Boolean required;
|
||||
private List<Argument> arguments;
|
||||
|
||||
public Argument(String name) {
|
||||
this.name = name;
|
||||
@ -45,5 +48,12 @@ public class Argument{
|
||||
public void setRequired(Boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
|
||||
public List<Argument> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public void setArguments(List<Argument> arguments) {
|
||||
this.arguments = arguments;
|
||||
}
|
||||
}
|
||||
|
||||
12
server/src/com/cloud/configuration/Config.java
Normal file → Executable file
12
server/src/com/cloud/configuration/Config.java
Normal file → Executable file
@ -60,6 +60,7 @@ public enum Config {
|
||||
NetworkThrottlingRate("Network", ManagementServer.class, Integer.class, "network.throttling.rate", "200", "Default data transfer rate in megabits per second allowed.", null),
|
||||
GuestDomainSuffix("Network", AgentManager.class, String.class, "guest.domain.suffix", "cloud-test.cloud.internal", "Default domain name for vms inside virtualized networks fronted by router", null),
|
||||
DirectNetworkNoDefaultRoute("Network", ManagementServer.class, Boolean.class, "direct.network.no.default.route", "false", "Direct Network Dhcp Server should not send a default route", "true/false"),
|
||||
OvsNetwork("Network", ManagementServer.class, Boolean.class, "open.vswitch.network", "false", "enable/disable open vswitch network", null),
|
||||
|
||||
//VPN
|
||||
RemoteAccessVpnPskLength("Network", AgentManager.class, Integer.class, "remote.access.vpn.psk.length", "24", "The length of the ipsec preshared key (minimum 8, maximum 256)", null),
|
||||
@ -120,6 +121,7 @@ public enum Config {
|
||||
ExpungeDelay("Advanced", UserVmManager.class, Integer.class, "expunge.delay", "86400", "Determines how long to wait before actually expunging destroyed vm. The default value = the default value of expunge.interval", null),
|
||||
ExpungeInterval("Advanced", UserVmManager.class, Integer.class, "expunge.interval", "86400", "The interval to wait before running the expunge thread.", null),
|
||||
ExpungeWorkers("Advanced", UserVmManager.class, Integer.class, "expunge.workers", "1", "Number of workers performing expunge ", null),
|
||||
ExtractURLCleanUpInterval("Advanced", ManagementServer.class, Integer.class, "extract.url.cleanup.interval", "120", "The interval to wait before cleaning up the extract URL's ", null),
|
||||
HostStatsInterval("Advanced", ManagementServer.class, Integer.class, "host.stats.interval", "60000", "The interval in milliseconds when host stats are retrieved from agents.", null),
|
||||
HostRetry("Advanced", AgentManager.class, Integer.class, "host.retry", "2", "Number of times to retry hosts for creating a volume", null),
|
||||
IntegrationAPIPort("Advanced", ManagementServer.class, Integer.class, "integration.api.port", "8096", "Defaul API port", null),
|
||||
@ -154,7 +156,7 @@ public enum Config {
|
||||
MaxTemplateAndIsoSize("Advanced", ManagementServer.class, Long.class, "max.template.iso.size", "50", "The maximum size for a downloaded template or ISO (in GB).", null),
|
||||
SecStorageAllowedInternalDownloadSites("Advanced", ManagementServer.class, String.class, "secstorage.allowed.internal.sites", null, "Comma separated list of cidrs internal to the datacenter that can host template download servers", null),
|
||||
SecStorageEncryptCopy("Advanced", ManagementServer.class, Boolean.class, "secstorage.encrypt.copy", "false", "Use SSL method used to encrypt copy traffic between zones", "true,false"),
|
||||
SecStorageSecureCopyCert("Advanced", ManagementServer.class, Boolean.class, "secstorage.ssl.cert.domain", "realhostip.com", "SSL certificate used to encrypt copy traffic between zones", "realhostip.com"),
|
||||
SecStorageSecureCopyCert("Advanced", ManagementServer.class, String.class, "secstorage.ssl.cert.domain", "realhostip.com", "SSL certificate used to encrypt copy traffic between zones", null),
|
||||
DirectAttachSecurityGroupsEnabled("Advanced", ManagementServer.class, Boolean.class, "direct.attach.security.groups.enabled", "false", "Ec2-style distributed firewall for direct-attach VMs", "true,false"),
|
||||
DirectAttachNetworkEnabled("Advanced", ManagementServer.class, Boolean.class, "direct.attach.network.externalIpAllocator.enabled", "false", "Direct-attach VMs using external DHCP server", "true,false"),
|
||||
DirectAttachNetworkExternalAPIURL("Advanced", ManagementServer.class, String.class, "direct.attach.network.externalIpAllocator.url", null, "Direct-attach VMs using external DHCP server (API url)", null),
|
||||
@ -212,7 +214,13 @@ public enum Config {
|
||||
SSOKey("Hidden", ManagementServer.class, String.class, "security.singlesignon.key", null, "A Single Sign-On key used for logging into the cloud", null),
|
||||
SSOAuthTolerance("Advanced", ManagementServer.class, Long.class, "security.singlesignon.tolerance.millis", "300000", "The allowable clock difference in milliseconds between when an SSO login request is made and when it is received.", null),
|
||||
//NetworkType("Hidden", ManagementServer.class, String.class, "network.type", "vlan", "The type of network that this deployment will use.", "vlan,direct"),
|
||||
HashKey("Hidden", ManagementServer.class, String.class, "security.hash.key", null, "for generic key-ed hash", null);
|
||||
HashKey("Hidden", ManagementServer.class, String.class, "security.hash.key", null, "for generic key-ed hash", null),
|
||||
|
||||
VmOpWaitInterval("Advanced", ManagementServer.class, Integer.class, "vm.op.wait.interval", "120", "Seconds to wait before checking if a previous operation has succeeded", null),
|
||||
VmOpLockStateRetry("Advanced", ManagementServer.class, Integer.class, "vm.op.lock.state.retry", "5", "Times to retry locking the state of a VM for operations", "-1 means try forever"),
|
||||
VmOpCleanupInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.interval", "86400", "Interval to run the thread that cleans up the vm operations in seconds", "Seconds"),
|
||||
VmOpCleanupWait("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.wait", "3600", "Seconds to wait before cleanuping up any vm work items", "Seconds"),
|
||||
VmOpCancelInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cancel.interval", "3600", "Seconds to wait before cancelling a operation", "Seconds");
|
||||
|
||||
private final String _category;
|
||||
private final Class<?> _componentClass;
|
||||
|
||||
@ -29,10 +29,9 @@ import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.network.Networks.Availability;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
@ -172,15 +171,14 @@ public interface ConfigurationManager extends Manager {
|
||||
* Creates a new network offering
|
||||
* @param name
|
||||
* @param displayText
|
||||
* @param type
|
||||
* @param trafficType
|
||||
* @param tags
|
||||
* @param maxConnections
|
||||
* @param id
|
||||
* @param specifyVlan;
|
||||
* @param specifyVlan;
|
||||
* @return network offering object
|
||||
*/
|
||||
NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, GuestIpType type, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability);
|
||||
NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability);
|
||||
|
||||
Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, Long networkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
|
||||
|
||||
@ -188,4 +186,5 @@ public interface ConfigurationManager extends Manager {
|
||||
|
||||
Long saveConfigurationEvent(long userId, Long accountId, String type, String description, String... paramsList);
|
||||
|
||||
DataCenterVO getZone(long id);
|
||||
}
|
||||
|
||||
@ -91,16 +91,17 @@ import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.Availability;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
@ -285,7 +286,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (type.equals(Boolean.class)) {
|
||||
if (!(value.equals("true") || value.equals("false"))) {
|
||||
s_logger.error("Configuration variable " + name + " is expecting true or false in stead of " + value);
|
||||
return "Please enter either \"true\" or \"false\".";
|
||||
return "Please enter either 'true' or 'false'.";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -523,7 +524,15 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (!(_LinkLocalIpAllocDao.deleteIpAddressByPod(podId))) {
|
||||
throw new CloudRuntimeException("Failed to cleanup private ip addresses for pod " + podId);
|
||||
}
|
||||
|
||||
|
||||
//Delete vlans associated with the pod
|
||||
List<? extends Vlan> vlans = _networkMgr.listPodVlans(podId);
|
||||
if (vlans != null && !vlans.isEmpty()) {
|
||||
for (Vlan vlan: vlans) {
|
||||
_vlanDao.remove(vlan.getId());
|
||||
}
|
||||
}
|
||||
|
||||
//Delete the pod
|
||||
if (!(_podDao.expunge(podId))) {
|
||||
throw new CloudRuntimeException("Failed to delete pod " + podId);
|
||||
@ -1207,36 +1216,29 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
Account systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
|
||||
|
||||
BroadcastDomainType broadcastDomainType = null;
|
||||
if (offering.getGuestIpType() != GuestIpType.DirectPodBased) {
|
||||
if (offering.getTrafficType() == TrafficType.Management) {
|
||||
broadcastDomainType = BroadcastDomainType.Native;
|
||||
} else if (offering.getTrafficType() == TrafficType.Public) {
|
||||
boolean isNetworkDefault = false;
|
||||
if (offering.getTrafficType() == TrafficType.Management) {
|
||||
broadcastDomainType = BroadcastDomainType.Native;
|
||||
} else if (offering.getTrafficType() == TrafficType.Control) {
|
||||
broadcastDomainType = BroadcastDomainType.LinkLocal;
|
||||
} else if (offering.getTrafficType() == TrafficType.Public) {
|
||||
if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||
broadcastDomainType = BroadcastDomainType.Vlan;
|
||||
} else if (offering.getTrafficType() == TrafficType.Control) {
|
||||
broadcastDomainType = BroadcastDomainType.LinkLocal;
|
||||
}
|
||||
userNetwork.setBroadcastDomainType(broadcastDomainType);
|
||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true);
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (offering.getTrafficType() == TrafficType.Guest) {
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
isNetworkDefault = true;
|
||||
broadcastDomainType = BroadcastDomainType.Native;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
userNetwork.setBroadcastDomainType(broadcastDomainType);
|
||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true, isNetworkDefault);
|
||||
}
|
||||
}
|
||||
|
||||
//if zone is basic, create a untagged network
|
||||
if (zone != null && zone.getNetworkType() == NetworkType.Basic) {
|
||||
//Create network
|
||||
DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, null);
|
||||
NetworkVO userNetwork = new NetworkVO();
|
||||
userNetwork.setBroadcastDomainType(BroadcastDomainType.Native);
|
||||
|
||||
Account systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
|
||||
|
||||
List<NetworkOfferingVO> networkOffering = _networkOfferingDao.findByType(GuestIpType.DirectPodBased);
|
||||
if (networkOffering == null || networkOffering.isEmpty()) {
|
||||
throw new CloudRuntimeException("No default DirectPodBased network offering is found");
|
||||
}
|
||||
|
||||
_networkMgr.setupNetwork(systemAccount, networkOffering.get(0), userNetwork, plan, null, null, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1361,7 +1363,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtual : NetworkOffering.GuestIpType.Direct;
|
||||
Network.GuestIpType guestIpType = useVirtualNetwork ? Network.GuestIpType.Virtual : Network.GuestIpType.Direct;
|
||||
tags = cleanupTags(tags);
|
||||
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags, false,domainId);
|
||||
|
||||
@ -1443,7 +1445,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (_serviceOfferingDao.update(id, offering)) {
|
||||
offering = _serviceOfferingDao.findById(id);
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_EDIT, "Successfully updated service offering with name: " + offering.getName() + ".", "soId=" + offering.getId(), "name=" + offering.getName(),
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtual), "tags=" + offering.getTags(), "domainId=" + offering.getDomainId());
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == Network.GuestIpType.Virtual), "tags=" + offering.getTags(), "domainId=" + offering.getDomainId());
|
||||
return offering;
|
||||
} else {
|
||||
return null;
|
||||
@ -1661,14 +1663,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (forVirtualNetwork){
|
||||
if (network == null) {
|
||||
//find default public network in the zone
|
||||
networkId = _networkMgr.getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(zoneId, TrafficType.Public, null);
|
||||
networkId = _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
} else if (network.getGuestType() != null || network.getTrafficType() != TrafficType.Public){
|
||||
throw new InvalidParameterValueException("Can't find Public network by id=" + networkId);
|
||||
}
|
||||
} else {
|
||||
if (network == null) {
|
||||
if (zone.getNetworkType() == DataCenter.NetworkType.Basic) {
|
||||
networkId = _networkMgr.getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(zoneId, TrafficType.Public, GuestIpType.DirectPodBased);
|
||||
networkId = _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Guest).getId();
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Nework id is required for Direct vlan creation ");
|
||||
}
|
||||
@ -1690,11 +1692,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
//check if startIp and endIp belong to network Cidr
|
||||
String networkCidr = network.getCidr();
|
||||
String networkGateway = network.getGateway();
|
||||
|
||||
Long networkZoneId = network.getDataCenterId();
|
||||
String[] splitResult = networkCidr.split("\\/");
|
||||
long size = Long.valueOf(splitResult[1]);
|
||||
String networkNetmask = NetUtils.getCidrNetmask(size);
|
||||
String networkNetmask = NetUtils.getCidrNetmask(networkCidr);
|
||||
|
||||
//Check if ip addresses are in network range
|
||||
if (!NetUtils.sameSubnet(startIP, networkGateway, networkNetmask)) {
|
||||
@ -1732,7 +1731,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
throw new InvalidParameterValueException("Please specify a valid pod.");
|
||||
}
|
||||
|
||||
|
||||
if (podId != null && _podDao.findById(podId).getDataCenterId() != zoneId) {
|
||||
throw new InvalidParameterValueException("Pod id=" + podId + " doesn't belong to zone id=" + zoneId);
|
||||
}
|
||||
@ -1766,7 +1764,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
if(hypervisorType.equalsIgnoreCase("xenserver")) {
|
||||
//check for the vlan being added before going to db, to see if it is untagged
|
||||
if(vlanType.toString().equalsIgnoreCase("VirtualNetwork") && vlanId.equalsIgnoreCase("untagged"))
|
||||
if(vlanType.toString().equalsIgnoreCase("VirtualNetwork") && vlanId.equalsIgnoreCase(Vlan.UNTAGGED))
|
||||
{
|
||||
if(_configDao.getValue("xen.public.network.device") == null || _configDao.getValue("xen.public.network.device").equals(""))
|
||||
{
|
||||
@ -1787,13 +1785,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// //check if the account's domain is a child of the zone's domain, for adding vlan ip ranges
|
||||
// if(domainId != null && !_domainDao.isChildDomain(zone.getDomainId(), domainId)){
|
||||
// //this is for account specific case, as domainId != null
|
||||
// throw new PermissionDeniedException("The account associated with specific domain id:"+domainId+" doesn't have permissions to add vlan ip ranges for the zone:"+zone.getId());
|
||||
// }
|
||||
//ACL check
|
||||
checkAccess(account, zone);
|
||||
|
||||
@ -1922,6 +1913,19 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
throw new InvalidParameterValueException("The VLAN tag " + vlanId + " is already being used for the guest network in zone " + zone.getName());
|
||||
}
|
||||
|
||||
//For untagged vlan check if vlan per pod already exists. If yes, verify that new vlan range has the same netmask and gateway
|
||||
if (zone.getNetworkType() == NetworkType.Basic && vlanId.equalsIgnoreCase(Vlan.UNTAGGED) && podId != null){
|
||||
List<VlanVO> podVlans = _vlanDao.listVlansForPodByType(podId, VlanType.DirectAttached);
|
||||
if (podVlans != null && !podVlans.isEmpty()) {
|
||||
VlanVO podVlan = podVlans.get(0);
|
||||
if (!podVlan.getVlanNetmask().equals(vlanNetmask)) {
|
||||
throw new InvalidParameterValueException("Vlan netmask is different from the netmask of Untagged vlan id=" + podVlan.getId() + " existing in the pod " + podId);
|
||||
} else if (!podVlan.getVlanGateway().equals(vlanGateway)) {
|
||||
throw new InvalidParameterValueException("Vlan gateway is different from the gateway of Untagged vlan id=" + podVlan.getId() + " existing in the pod " + podId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Everything was fine, so persist the VLAN
|
||||
String ipRange = startIP;
|
||||
if (endIP != null) {
|
||||
@ -2678,13 +2682,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
String name = cmd.getNetworkOfferingName();
|
||||
String displayText = cmd.getDisplayText();
|
||||
String tags = cmd.getTags();
|
||||
String typeString = cmd.getType();
|
||||
String trafficTypeString = cmd.getTraffictype();
|
||||
Boolean specifyVlan = cmd.getSpecifyVlan();
|
||||
String availabilityStr = cmd.getAvailability();
|
||||
|
||||
TrafficType trafficType = null;
|
||||
GuestIpType type = null;
|
||||
Availability availability = null;
|
||||
|
||||
|
||||
@ -2698,16 +2700,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
throw new InvalidParameterValueException("Invalid value for traffictype. Supported traffic types: Public, Management, Control, Guest, Vlan or Storage");
|
||||
}
|
||||
|
||||
//Verify type
|
||||
for (GuestIpType gType : GuestIpType.values()) {
|
||||
if (gType.name().equalsIgnoreCase(typeString)) {
|
||||
type = gType;
|
||||
}
|
||||
}
|
||||
if (type == null || type == GuestIpType.DirectPodBased) {
|
||||
throw new InvalidParameterValueException("Invalid value for type. Supported types: Virtual, Direct");
|
||||
}
|
||||
|
||||
//Verify availability
|
||||
for (Availability avlb : Availability.values()) {
|
||||
if (avlb.name().equalsIgnoreCase(availabilityStr)) {
|
||||
@ -2720,17 +2712,17 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
|
||||
Integer maxConnections = cmd.getMaxconnections();
|
||||
return createNetworkOffering(userId, name, displayText, type, trafficType, tags, maxConnections, specifyVlan, availability);
|
||||
return createNetworkOffering(userId, name, displayText, trafficType, tags, maxConnections, specifyVlan, availability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, GuestIpType type, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability) {
|
||||
public NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability) {
|
||||
String networkRateStr = _configDao.getValue("network.throttling.rate");
|
||||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
tags = cleanupTags(tags);
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, type, false, specifyVlan, networkRate, multicastRate, maxConnections, false, availability, false, false, false, false, false, false, false);
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, false, specifyVlan, networkRate, multicastRate, maxConnections, false, availability, false, false, false, false, false, false, false);
|
||||
|
||||
if ((offering = _networkOfferingDao.persist(offering)) != null) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_NETWORK_OFFERING_CREATE, "Successfully created new network offering with name: " + name + ".", "noId=" + offering.getId(), "name=" + name,
|
||||
@ -2749,7 +2741,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
Object id = cmd.getId();
|
||||
Object name = cmd.getNetworkOfferingName();
|
||||
Object displayText = cmd.getDisplayText();
|
||||
Object type = cmd.getType();
|
||||
Object trafficType = cmd.getTrafficType();
|
||||
Object isDefault = cmd.getIsDefault();
|
||||
Object specifyVlan = cmd.getSpecifyVlan();
|
||||
@ -2775,9 +2766,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (displayText != null) {
|
||||
sc.addAnd("displayText", SearchCriteria.Op.LIKE, "%" + displayText + "%");
|
||||
}
|
||||
if (type != null) {
|
||||
sc.addAnd("guestIpType", SearchCriteria.Op.EQ, type);
|
||||
}
|
||||
|
||||
if (trafficType != null) {
|
||||
sc.addAnd("trafficType", SearchCriteria.Op.EQ, trafficType);
|
||||
@ -2896,4 +2884,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataCenterVO getZone(long id){
|
||||
return _zoneDao.findById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,6 +72,12 @@ import com.cloud.network.dao.NetworkRuleConfigDaoImpl;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
|
||||
import com.cloud.network.dao.VpnUserDaoImpl;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManagerImpl;
|
||||
import com.cloud.network.ovs.OvsNetworkManagerImpl;
|
||||
import com.cloud.network.ovs.dao.GreTunnelDaoImpl;
|
||||
import com.cloud.network.ovs.dao.OvsWorkDaoImpl;
|
||||
import com.cloud.network.ovs.dao.VlanMappingDaoImpl;
|
||||
import com.cloud.network.ovs.dao.VlanMappingDirtyDaoImpl;
|
||||
import com.cloud.network.ovs.dao.VmFlowLogDaoImpl;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManagerImpl;
|
||||
import com.cloud.network.rules.RulesManagerImpl;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDaoImpl;
|
||||
@ -240,7 +246,11 @@ public class DefaultComponentLibrary implements ComponentLibrary {
|
||||
addDao("UsageEventDao", UsageEventDaoImpl.class);
|
||||
addDao("ClusterDetailsDao", ClusterDetailsDaoImpl.class);
|
||||
addDao("UserVmDetailsDao", UserVmDetailsDaoImpl.class);
|
||||
|
||||
addDao("VlanMappingDao", VlanMappingDaoImpl.class);
|
||||
addDao("VlanMappingDirtyDao", VlanMappingDirtyDaoImpl.class);
|
||||
addDao("OvsWorkDao", OvsWorkDaoImpl.class);
|
||||
addDao("VmFlowLogDao", VmFlowLogDaoImpl.class);
|
||||
addDao("GreTunnelDao", GreTunnelDaoImpl.class);
|
||||
}
|
||||
|
||||
Map<String, ComponentInfo<Manager>> _managers = new HashMap<String, ComponentInfo<Manager>>();
|
||||
@ -295,6 +305,7 @@ public class DefaultComponentLibrary implements ComponentLibrary {
|
||||
addManager("LoadBalancingRulesManager", LoadBalancingRulesManagerImpl.class);
|
||||
addManager("RulesManager", RulesManagerImpl.class);
|
||||
addManager("RemoteAccessVpnManager", RemoteAccessVpnManagerImpl.class);
|
||||
addManager("OvsNetworkManager", OvsNetworkManagerImpl.class);
|
||||
}
|
||||
|
||||
protected <T> List<ComponentInfo<Adapter>> addAdapterChain(Class<T> interphace, List<Pair<String, Class<? extends T>>> adapters) {
|
||||
@ -339,4 +350,5 @@ public class DefaultComponentLibrary implements ComponentLibrary {
|
||||
factories.put(EntityManager.class, EntityManagerImpl.class);
|
||||
return factories;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.component.AnnotationInterceptor;
|
||||
import com.cloud.utils.component.InterceptorLibrary;
|
||||
import com.cloud.utils.db.DatabaseCallback;
|
||||
|
||||
public class DefaultInterceptorLibrary implements InterceptorLibrary {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(List<AnnotationInterceptor<?>> interceptors) {
|
||||
interceptors.add(new DatabaseCallback());
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
|
||||
return -1;
|
||||
}
|
||||
GetVncPortAnswer answer = (GetVncPortAnswer) _agentMgr.easySend(vm.getHostId(), new GetVncPortCommand(vm.getId(), vm.getName()));
|
||||
return answer == null ? -1 : answer.getPort();
|
||||
return (answer == null || !answer.getResult()) ? -1 : answer.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -72,6 +72,8 @@ import com.cloud.certificate.dao.CertificateDao;
|
||||
import com.cloud.cluster.ClusterManager;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
@ -102,11 +104,11 @@ import com.cloud.info.RunningHostInfoAgregator;
|
||||
import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo;
|
||||
import com.cloud.maid.StackMaid;
|
||||
import com.cloud.network.IpAddrAllocator;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
@ -560,7 +562,10 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
Account systemAcct = _accountMgr.getSystemAccount();
|
||||
User systemUser = _accountMgr.getSystemUser();
|
||||
return _itMgr.start(proxy, null, systemUser, systemAcct, null);
|
||||
if (proxy.getState() == VirtualMachine.State.Running) {
|
||||
return proxy;
|
||||
}
|
||||
return _itMgr.start(proxy, null, systemUser, systemAcct);
|
||||
}
|
||||
|
||||
public ConsoleProxyVO assignProxyFromRunningPool(long dataCenterId) {
|
||||
@ -697,17 +702,21 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
|
||||
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
||||
|
||||
List<NetworkOfferingVO> defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork);
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork, NetworkOfferingVO.SystemVmManagementNetwork);
|
||||
List<NetworkOfferingVO> defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork);
|
||||
if (dc.getNetworkType() == NetworkType.Basic) {
|
||||
defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SysteGuestNetwork);
|
||||
}
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork);
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setDeviceId(2);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, defaultOffering.get(0), plan, null, null, false).get(0), defaultNic));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, defaultOffering.get(0), plan, null, null, false, false).get(0), defaultNic));
|
||||
for (NetworkOfferingVO offering : offerings) {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false, false).get(0), null));
|
||||
}
|
||||
ConsoleProxyVO proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, _template.getId(), _template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), 0);
|
||||
ConsoleProxyVO proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, _template.getId(), _template.getHypervisorType(), _template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), 0);
|
||||
try {
|
||||
proxy = _itMgr.allocate(proxy, _template, _serviceOffering, networks, plan, null, systemAcct);
|
||||
} catch (InsufficientCapacityException e) {
|
||||
@ -1525,7 +1534,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
final RebootCommand cmd = new RebootCommand(proxy.getInstanceName());
|
||||
final Answer answer = _agentMgr.easySend(proxy.getHostId(), cmd);
|
||||
|
||||
if (answer != null) {
|
||||
if (answer != null && answer.getResult()) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Successfully reboot console proxy " + proxy.getName());
|
||||
}
|
||||
@ -1551,64 +1560,13 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean destroyProxy(long vmId) {
|
||||
AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
||||
if (asyncExecutor != null) {
|
||||
AsyncJobVO job = asyncExecutor.getJob();
|
||||
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Destroy console proxy " + vmId + ", update async job-" + job.getId());
|
||||
}
|
||||
_asyncMgr.updateAsyncJobAttachment(job.getId(), "console_proxy", vmId);
|
||||
}
|
||||
|
||||
ConsoleProxyVO vm = _consoleProxyDao.findById(vmId);
|
||||
if (vm == null || vm.getState() == State.Destroyed) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to find vm or vm is destroyed: " + vmId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Destroying console proxy vm " + vmId);
|
||||
}
|
||||
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, null)) {
|
||||
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vmId);
|
||||
return false;
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
List<VolumeVO> vols = null;
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(vmId);
|
||||
try {
|
||||
vols = _volsDao.findByInstance(vmId);
|
||||
if (vols.size() != 0) {
|
||||
_storageMgr.destroy(vm, vols);
|
||||
}
|
||||
|
||||
return true;
|
||||
} finally {
|
||||
try {
|
||||
txn.start();
|
||||
// release critical system resources used by the VM before we
|
||||
// delete them
|
||||
if (vm.getPublicIpAddress() != null) {
|
||||
// freePublicIpAddress(vm.getPublicIpAddress(), vm.getDataCenterId(), vm.getPodId());
|
||||
}
|
||||
vm.setPublicIpAddress(null);
|
||||
|
||||
_consoleProxyDao.remove(vm.getId());
|
||||
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Caught this error: ", e);
|
||||
txn.rollback();
|
||||
return false;
|
||||
} finally {
|
||||
s_logger.debug("console proxy vm is destroyed : " + vm.getName());
|
||||
}
|
||||
return _itMgr.expunge(proxy, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to expunge " + proxy, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1702,7 +1660,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
|
||||
MigrateCommand cmd = new MigrateCommand(proxy.getInstanceName(), host.getPrivateIpAddress(), false);
|
||||
Answer answer = _agentMgr.easySend(fromHost.getId(), cmd);
|
||||
if (answer == null) {
|
||||
if (answer == null || !answer.getResult()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1905,7 +1863,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
_itMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this);
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
|
||||
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, 0, 0, 0, true, null, NetworkOffering.GuestIpType.Virtual,
|
||||
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, 0, 0, 0, true, null, Network.GuestIpType.Virtual,
|
||||
useLocalStorage, true, null, true);
|
||||
_serviceOffering.setUniqueName("Cloud.com-ConsoleProxy");
|
||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||
@ -2020,10 +1978,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
cmds.addCommand("checkSsh", check);
|
||||
|
||||
ConsoleProxyVO proxy = profile.getVirtualMachine();
|
||||
DataCenter dc = dest.getDataCenter();
|
||||
List<NicVO> nics = _nicDao.listBy(proxy.getId());
|
||||
for (NicVO nic : nics) {
|
||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Public) {
|
||||
if ((network.getTrafficType() == TrafficType.Public && dc.getNetworkType() == NetworkType.Advanced) || (network.getTrafficType() == TrafficType.Guest && dc.getNetworkType() == NetworkType.Basic)) {
|
||||
proxy.setPublicIpAddress(nic.getIp4Address());
|
||||
proxy.setPublicNetmask(nic.getNetmask());
|
||||
proxy.setPublicMacAddress(nic.getMacAddress());
|
||||
|
||||
@ -58,10 +58,10 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
protected SearchBuilder<DataCenterVO> PublicZonesSearch;
|
||||
protected SearchBuilder<DataCenterVO> ChildZonesSearch;
|
||||
|
||||
protected static final DataCenterIpAddressDaoImpl _ipAllocDao = ComponentLocator.inject(DataCenterIpAddressDaoImpl.class);
|
||||
protected static final DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao = ComponentLocator.inject(DataCenterLinkLocalIpAddressDaoImpl.class);
|
||||
protected static final DataCenterVnetDaoImpl _vnetAllocDao = ComponentLocator.inject(DataCenterVnetDaoImpl.class);
|
||||
protected static final PodVlanDaoImpl _podVlanAllocDao = ComponentLocator.inject(PodVlanDaoImpl.class);
|
||||
protected final DataCenterIpAddressDaoImpl _ipAllocDao = ComponentLocator.inject(DataCenterIpAddressDaoImpl.class);
|
||||
protected final DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao = ComponentLocator.inject(DataCenterLinkLocalIpAddressDaoImpl.class);
|
||||
protected final DataCenterVnetDaoImpl _vnetAllocDao = ComponentLocator.inject(DataCenterVnetDaoImpl.class);
|
||||
protected final PodVlanDaoImpl _podVlanAllocDao = ComponentLocator.inject(PodVlanDaoImpl.class);
|
||||
protected long _prefix;
|
||||
protected Random _rand = new Random(System.currentTimeMillis());
|
||||
protected TableGenerator _tgMacAddress;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user