mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-15 18:12:35 +01:00
Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss
This commit is contained in:
commit
f2c9ec3765
@ -10,7 +10,7 @@
|
|||||||
<!-- A time/date based rolling appender -->
|
<!-- A time/date based rolling appender -->
|
||||||
<appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
|
<appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
|
||||||
<param name="Append" value="true"/>
|
<param name="Append" value="true"/>
|
||||||
<param name="Threshold" value="DEBUG"/>
|
<param name="Threshold" value="INFO"/>
|
||||||
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
|
||||||
<param name="FileNamePattern" value="@AGENTLOG@.%d{yyyy-MM-dd}.gz"/>
|
<param name="FileNamePattern" value="@AGENTLOG@.%d{yyyy-MM-dd}.gz"/>
|
||||||
<param name="ActiveFileName" value="@AGENTLOG@"/>
|
<param name="ActiveFileName" value="@AGENTLOG@"/>
|
||||||
@ -38,7 +38,7 @@
|
|||||||
<!-- ================ -->
|
<!-- ================ -->
|
||||||
|
|
||||||
<category name="com.cloud">
|
<category name="com.cloud">
|
||||||
<priority value="DEBUG"/>
|
<priority value="INFO"/>
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
<category name="com.cloud.agent.metrics">
|
<category name="com.cloud.agent.metrics">
|
||||||
|
|||||||
@ -1,7 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: cloud agent
|
||||||
|
# Required-Start: $network
|
||||||
|
# Required-Stop: $network
|
||||||
|
# Default-Start: 3 4 5
|
||||||
|
# Default-Stop: 0 1 2 6
|
||||||
|
# X-Interactive: true
|
||||||
|
# Short-Description: Start/stop apache2 web server
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
# 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
|
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
|
||||||
|
|
||||||
@ -23,6 +30,20 @@ unset OPTIONS
|
|||||||
DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
|
DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
|
||||||
PROG=@LIBEXECDIR@/agent-runner
|
PROG=@LIBEXECDIR@/agent-runner
|
||||||
|
|
||||||
|
wait_for_network() {
|
||||||
|
i=1
|
||||||
|
while [ $i -lt 10 ]
|
||||||
|
do
|
||||||
|
if ip addr show cloudbr0 |grep -w inet > /dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
let i=$i+1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
log_daemon_msg $"Starting $PROGNAME" "$SHORTNAME"
|
log_daemon_msg $"Starting $PROGNAME" "$SHORTNAME"
|
||||||
if [ -s "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") >/dev/null 2>&1; then
|
if [ -s "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") >/dev/null 2>&1; then
|
||||||
@ -38,6 +59,9 @@ start() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#FIXME: wait for network
|
||||||
|
wait_for_network
|
||||||
|
|
||||||
if start-stop-daemon --start --quiet \
|
if start-stop-daemon --start --quiet \
|
||||||
--pidfile "$PIDFILE" \
|
--pidfile "$PIDFILE" \
|
||||||
--exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
|
--exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
|
||||||
|
|||||||
@ -1545,7 +1545,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
s_logger.warn("Failed to program network rules for vm " + cmd.getVmName());
|
s_logger.warn("Failed to program network rules for vm " + cmd.getVmName());
|
||||||
return new SecurityIngressRuleAnswer(cmd, false, "programming network rules failed");
|
return new SecurityIngressRuleAnswer(cmd, false, "programming network rules failed");
|
||||||
} else {
|
} else {
|
||||||
s_logger.info("Programmed network rules for vm " + cmd.getVmName() + " guestIp=" + cmd.getGuestIp() + ", numrules=" + cmd.getRuleSet().length);
|
s_logger.debug("Programmed network rules for vm " + cmd.getVmName() + " guestIp=" + cmd.getGuestIp() + ", numrules=" + cmd.getRuleSet().length);
|
||||||
return new SecurityIngressRuleAnswer(cmd);
|
return new SecurityIngressRuleAnswer(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1857,7 +1857,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
|
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
|
||||||
String result = cpuScript.execute(parser);
|
String result = cpuScript.execute(parser);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
s_logger.info("Unable to get the host CPU state: " + result);
|
s_logger.debug("Unable to get the host CPU state: " + result);
|
||||||
return new Answer(cmd, false, result);
|
return new Answer(cmd, false, result);
|
||||||
}
|
}
|
||||||
double cpuUtil = (100.0D - Double.parseDouble(parser.getLine()));
|
double cpuUtil = (100.0D - Double.parseDouble(parser.getLine()));
|
||||||
@ -1869,7 +1869,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
final OutputInterpreter.OneLineParser Memparser = new OutputInterpreter.OneLineParser();
|
final OutputInterpreter.OneLineParser Memparser = new OutputInterpreter.OneLineParser();
|
||||||
result = memScript.execute(Memparser);
|
result = memScript.execute(Memparser);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
s_logger.info("Unable to get the host Mem state: " + result);
|
s_logger.debug("Unable to get the host Mem state: " + result);
|
||||||
return new Answer(cmd, false, result);
|
return new Answer(cmd, false, result);
|
||||||
}
|
}
|
||||||
freeMem = Long.parseLong(Memparser.getLine());
|
freeMem = Long.parseLong(Memparser.getLine());
|
||||||
@ -1880,7 +1880,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
final OutputInterpreter.OneLineParser totMemparser = new OutputInterpreter.OneLineParser();
|
final OutputInterpreter.OneLineParser totMemparser = new OutputInterpreter.OneLineParser();
|
||||||
result = totalMem.execute(totMemparser);
|
result = totalMem.execute(totMemparser);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
s_logger.info("Unable to get the host Mem state: " + result);
|
s_logger.debug("Unable to get the host Mem state: " + result);
|
||||||
return new Answer(cmd, false, result);
|
return new Answer(cmd, false, result);
|
||||||
}
|
}
|
||||||
long totMem = Long.parseLong(totMemparser.getLine());
|
long totMem = Long.parseLong(totMemparser.getLine());
|
||||||
@ -2824,7 +2824,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
long dom0ram = Math.min(ram/10, 768*1024*1024L);//save a maximum of 10% of system ram or 768M
|
long dom0ram = Math.min(ram/10, 768*1024*1024L);//save a maximum of 10% of system ram or 768M
|
||||||
dom0ram = Math.max(dom0ram, _dom0MinMem);
|
dom0ram = Math.max(dom0ram, _dom0MinMem);
|
||||||
info.add(dom0ram);
|
info.add(dom0ram);
|
||||||
s_logger.info("cpus=" + cpus + ", speed=" + speed + ", ram=" + ram + ", dom0ram=" + dom0ram);
|
s_logger.debug("cpus=" + cpus + ", speed=" + speed + ", ram=" + ram + ", dom0ram=" + dom0ram);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package com.cloud.agent.vmdata;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -38,6 +39,7 @@ import javax.servlet.http.HttpServlet;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mortbay.jetty.Connector;
|
import org.mortbay.jetty.Connector;
|
||||||
import org.mortbay.jetty.Handler;
|
import org.mortbay.jetty.Handler;
|
||||||
@ -294,10 +296,18 @@ public class JettyVmDataServer implements VmDataServer {
|
|||||||
try {
|
try {
|
||||||
_fs.create(vmDataDir, item[1]);
|
_fs.create(vmDataDir, item[1]);
|
||||||
String vmDataFile = vmDataDir + File.separator + item[1];
|
String vmDataFile = vmDataDir + File.separator + item[1];
|
||||||
|
byte[] data;
|
||||||
if (item[2] != null) {
|
if (item[2] != null) {
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(vmDataFile));
|
if (item[1].equals("user-data")) {
|
||||||
writer.write(item[2]);
|
data = Base64.decodeBase64(item[2]);
|
||||||
writer.close();
|
} else {
|
||||||
|
data = item[2].getBytes();
|
||||||
|
}
|
||||||
|
if (data != null && data.length > 0) {
|
||||||
|
FileOutputStream writer = new FileOutputStream(vmDataFile);
|
||||||
|
writer.write(data);
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.warn("Failed to write vm data item " + item[1], e);
|
s_logger.warn("Failed to write vm data item " + item[1], e);
|
||||||
|
|||||||
@ -22,8 +22,16 @@ import com.cloud.agent.api.Command;
|
|||||||
|
|
||||||
public class CreateEntityDownloadURLCommand extends AbstractDownloadCommand {
|
public class CreateEntityDownloadURLCommand extends AbstractDownloadCommand {
|
||||||
|
|
||||||
|
public CreateEntityDownloadURLCommand(String parent, String installPath, String uuid) { // this constructor is for creating template download url
|
||||||
|
super();
|
||||||
|
this.parent = parent; // parent is required as not the template can be child of one of many parents
|
||||||
|
this.installPath = installPath;
|
||||||
|
this.extractLinkUUID = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
public CreateEntityDownloadURLCommand(String installPath, String uuid) {
|
public CreateEntityDownloadURLCommand(String installPath, String uuid) {
|
||||||
super();
|
super();
|
||||||
|
this.parent = parent;
|
||||||
this.installPath = installPath;
|
this.installPath = installPath;
|
||||||
this.extractLinkUUID = uuid;
|
this.extractLinkUUID = uuid;
|
||||||
}
|
}
|
||||||
@ -32,6 +40,7 @@ public class CreateEntityDownloadURLCommand extends AbstractDownloadCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String installPath;
|
private String installPath;
|
||||||
|
private String parent;
|
||||||
private String extractLinkUUID;
|
private String extractLinkUUID;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -46,6 +55,14 @@ public class CreateEntityDownloadURLCommand extends AbstractDownloadCommand {
|
|||||||
public void setInstallPath(String installPath) {
|
public void setInstallPath(String installPath) {
|
||||||
this.installPath = installPath;
|
this.installPath = installPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(String parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
public String getExtractLinkUUID() {
|
public String getExtractLinkUUID() {
|
||||||
return extractLinkUUID;
|
return extractLinkUUID;
|
||||||
|
|||||||
@ -27,7 +27,6 @@ public class NicTO extends NetworkTO {
|
|||||||
Integer networkRateMulticastMbps;
|
Integer networkRateMulticastMbps;
|
||||||
boolean defaultNic;
|
boolean defaultNic;
|
||||||
|
|
||||||
|
|
||||||
public NicTO() {
|
public NicTO() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -549,5 +549,8 @@ public abstract class BaseCmd {
|
|||||||
(accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) ||
|
(accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) ||
|
||||||
(accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) ||
|
(accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) ||
|
||||||
(accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
|
(accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
|
||||||
}
|
}
|
||||||
|
public static boolean isRootAdmin(short accountType) {
|
||||||
|
return ((accountType == Account.ACCOUNT_TYPE_ADMIN));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -161,7 +161,7 @@ public interface ResponseGenerator {
|
|||||||
RemoteAccessVpnResponse createRemoteAccessVpnResponse(RemoteAccessVpn vpn);
|
RemoteAccessVpnResponse createRemoteAccessVpnResponse(RemoteAccessVpn vpn);
|
||||||
|
|
||||||
void createTemplateResponse(List<TemplateResponse> responses, Pair<Long, Long> templateZonePair, boolean isAdmin,
|
void createTemplateResponse(List<TemplateResponse> responses, Pair<Long, Long> templateZonePair, boolean isAdmin,
|
||||||
Account account);
|
Account account, boolean readyOnly);
|
||||||
|
|
||||||
ListResponse<TemplateResponse> createTemplateResponse2(VirtualMachineTemplate template, Long zoneId);
|
ListResponse<TemplateResponse> createTemplateResponse2(VirtualMachineTemplate template, Long zoneId);
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ public interface ResponseGenerator {
|
|||||||
|
|
||||||
EventResponse createEventResponse(Event event);
|
EventResponse createEventResponse(Event event);
|
||||||
|
|
||||||
ListResponse<TemplateResponse> createIsoResponse(Set<Pair<Long,Long>> isoZonePairSet, boolean onlyReady, Account account, Boolean isBootable);
|
ListResponse<TemplateResponse> createIsoResponse(Set<Pair<Long,Long>> isoZonePairSet, boolean onlyReady, Account account, Boolean isBootable, boolean readyOnly);
|
||||||
|
|
||||||
TemplateResponse createIsoResponse(VirtualMachineTemplate result);
|
TemplateResponse createIsoResponse(VirtualMachineTemplate result);
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.ApiConstants;
|
import com.cloud.api.ApiConstants;
|
||||||
@ -42,10 +44,10 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||||||
//////////////// API parameters /////////////////////
|
//////////////// API parameters /////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the network")
|
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the network")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network")
|
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network")
|
||||||
private String displayText;
|
private String displayText;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.NETWORK_OFFERING_ID, type=CommandType.LONG, required=true, description="the network offering id")
|
@Parameter(name=ApiConstants.NETWORK_OFFERING_ID, type=CommandType.LONG, required=true, description="the network offering id")
|
||||||
@ -76,13 +78,16 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||||||
private Long domainId;
|
private Long domainId;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network is shared across accounts in the Zone")
|
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network is shared across accounts in the Zone")
|
||||||
private Boolean isShared;
|
private Boolean isShared;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if network is default, false otherwise")
|
@Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if network is default, false otherwise")
|
||||||
private Boolean isDefault;
|
private Boolean isDefault;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain")
|
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain")
|
||||||
private String networkDomain;
|
private String networkDomain;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="Tag the network")
|
||||||
|
private List<String> tags;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////////// Accessors ///////////////////////
|
/////////////////// Accessors ///////////////////////
|
||||||
@ -90,6 +95,10 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||||||
public Long getNetworkOfferingId() {
|
public Long getNetworkOfferingId() {
|
||||||
return networkOfferingId;
|
return networkOfferingId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getZoneId() {
|
public Long getZoneId() {
|
||||||
return zoneId;
|
return zoneId;
|
||||||
|
|||||||
@ -124,6 +124,17 @@ public class ListIsosCmd extends BaseListCmd {
|
|||||||
public Long getZoneId() {
|
public Long getZoneId() {
|
||||||
return zoneId;
|
return zoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean listInReadyState() {
|
||||||
|
Account account = UserContext.current().getCaller();
|
||||||
|
// It is account specific if account is admin type and domainId and accountName are not null
|
||||||
|
boolean isAccountSpecific = (account == null || isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null);
|
||||||
|
// Show only those that are downloaded.
|
||||||
|
TemplateFilter templateFilter = TemplateFilter.valueOf(getIsoFilter());
|
||||||
|
boolean onlyReady = (templateFilter == TemplateFilter.featured) || (templateFilter == TemplateFilter.selfexecutable) || (templateFilter == TemplateFilter.sharedexecutable)
|
||||||
|
|| (templateFilter == TemplateFilter.executable && isAccountSpecific) || (templateFilter == TemplateFilter.community);
|
||||||
|
return onlyReady;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
@ -160,7 +171,7 @@ public class ListIsosCmd extends BaseListCmd {
|
|||||||
isAdmin = true;
|
isAdmin = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListResponse<TemplateResponse> response = _responseGenerator.createIsoResponse(isoZonePairSet, isAdmin, account, bootable);
|
ListResponse<TemplateResponse> response = _responseGenerator.createIsoResponse(isoZonePairSet, isAdmin, account, bootable, listInReadyState());
|
||||||
response.setResponseName(getCommandName());
|
response.setResponseName(getCommandName());
|
||||||
this.setResponseObject(response);
|
this.setResponseObject(response);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,6 @@ import com.cloud.api.ApiConstants;
|
|||||||
import com.cloud.api.BaseListCmd;
|
import com.cloud.api.BaseListCmd;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.BaseCmd.CommandType;
|
|
||||||
import com.cloud.api.response.ListResponse;
|
import com.cloud.api.response.ListResponse;
|
||||||
import com.cloud.api.response.ServiceOfferingResponse;
|
import com.cloud.api.response.ServiceOfferingResponse;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
|
|||||||
@ -105,6 +105,17 @@ public class ListTemplatesCmd extends BaseListCmd {
|
|||||||
public Long getZoneId() {
|
public Long getZoneId() {
|
||||||
return zoneId;
|
return zoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean listInReadyState() {
|
||||||
|
Account account = UserContext.current().getCaller();
|
||||||
|
// It is account specific if account is admin type and domainId and accountName are not null
|
||||||
|
boolean isAccountSpecific = (account == null || isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null);
|
||||||
|
// Show only those that are downloaded.
|
||||||
|
TemplateFilter templateFilter = TemplateFilter.valueOf(getTemplateFilter());
|
||||||
|
boolean onlyReady = (templateFilter == TemplateFilter.featured) || (templateFilter == TemplateFilter.selfexecutable) || (templateFilter == TemplateFilter.sharedexecutable)
|
||||||
|
|| (templateFilter == TemplateFilter.executable && isAccountSpecific) || (templateFilter == TemplateFilter.community);
|
||||||
|
return onlyReady;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
@ -133,7 +144,7 @@ public class ListTemplatesCmd extends BaseListCmd {
|
|||||||
List<TemplateResponse> templateResponses = new ArrayList<TemplateResponse>();
|
List<TemplateResponse> templateResponses = new ArrayList<TemplateResponse>();
|
||||||
|
|
||||||
for (Pair<Long, Long> template : templateZonePairSet) {
|
for (Pair<Long, Long> template : templateZonePairSet) {
|
||||||
_responseGenerator.createTemplateResponse(templateResponses, template, isAdmin, account);
|
_responseGenerator.createTemplateResponse(templateResponses, template, isAdmin, account, listInReadyState());
|
||||||
}
|
}
|
||||||
|
|
||||||
response.setResponses(templateResponses);
|
response.setResponses(templateResponses);
|
||||||
|
|||||||
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.ApiConstants;
|
import com.cloud.api.ApiConstants;
|
||||||
@ -44,12 +46,15 @@ public class UpdateNetworkCmd extends BaseCmd {
|
|||||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network")
|
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the new name for the network")
|
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the new name for the network")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the new display text for the network")
|
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the new display text for the network")
|
||||||
private String displayText;
|
private String displayText;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="tags for the network")
|
||||||
|
private List<String> tags;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////////// Accessors ///////////////////////
|
/////////////////// Accessors ///////////////////////
|
||||||
@ -65,7 +70,11 @@ public class UpdateNetworkCmd extends BaseCmd {
|
|||||||
|
|
||||||
public String getDisplayText() {
|
public String getDisplayText() {
|
||||||
return displayText;
|
return displayText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
@ -90,7 +99,7 @@ public class UpdateNetworkCmd extends BaseCmd {
|
|||||||
@Override
|
@Override
|
||||||
public void execute() throws InsufficientCapacityException, ConcurrentOperationException{
|
public void execute() throws InsufficientCapacityException, ConcurrentOperationException{
|
||||||
|
|
||||||
Network result = _networkService.updateNetwork(getId(), getNetworkName(), getDisplayText(), UserContext.current().getCaller());
|
Network result = _networkService.updateNetwork(getId(), getNetworkName(), getDisplayText(), tags, UserContext.current().getCaller());
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
|
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
|
||||||
response.setResponseName(getCommandName());
|
response.setResponseName(getCommandName());
|
||||||
|
|||||||
@ -113,6 +113,12 @@ public class DomainRouterResponse extends BaseResponse {
|
|||||||
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain associated with the router")
|
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain associated with the router")
|
||||||
private String domainName;
|
private String domainName;
|
||||||
|
|
||||||
|
@SerializedName("serviceofferingid") @Param(description="the ID of the service offering of the virtual machine")
|
||||||
|
private Long serviceOfferingId;
|
||||||
|
|
||||||
|
@SerializedName("serviceofferingname") @Param(description="the name of the service offering of the virtual machine")
|
||||||
|
private String serviceOfferingName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -353,4 +359,19 @@ public class DomainRouterResponse extends BaseResponse {
|
|||||||
this.linkLocalNetworkId = linkLocalNetworkId;
|
this.linkLocalNetworkId = linkLocalNetworkId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getServiceOfferingId() {
|
||||||
|
return serviceOfferingId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServiceOfferingId(Long serviceOfferingId) {
|
||||||
|
this.serviceOfferingId = serviceOfferingId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServiceOfferingName() {
|
||||||
|
return serviceOfferingName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServiceOfferingName(String serviceOfferingName) {
|
||||||
|
this.serviceOfferingName = serviceOfferingName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ package com.cloud.api.response;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiConstants;
|
||||||
import com.cloud.serializer.Param;
|
import com.cloud.serializer.Param;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
@ -113,6 +114,12 @@ public class TemplateResponse extends BaseResponse {
|
|||||||
@SerializedName("sourcetemplateid") @Param(description="the template ID of the parent template if present")
|
@SerializedName("sourcetemplateid") @Param(description="the template ID of the parent template if present")
|
||||||
private Long sourcetemplateId;
|
private Long sourcetemplateId;
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.HOST_ID) @Param(description="the ID of the secondary storage host for the template")
|
||||||
|
private Long hostId;
|
||||||
|
|
||||||
|
@SerializedName("hostname") @Param(description="the name of the secondary storage host for the template")
|
||||||
|
private String hostName;
|
||||||
|
|
||||||
public Long getObjectId() {
|
public Long getObjectId() {
|
||||||
return getId();
|
return getId();
|
||||||
}
|
}
|
||||||
@ -348,4 +355,20 @@ public class TemplateResponse extends BaseResponse {
|
|||||||
public void setSourceTemplateId(Long sourcetemplateId) {
|
public void setSourceTemplateId(Long sourcetemplateId) {
|
||||||
this.sourcetemplateId = sourcetemplateId;
|
this.sourcetemplateId = sourcetemplateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getHostId() {
|
||||||
|
return hostId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHostId(Long hostId) {
|
||||||
|
this.hostId = hostId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHostName() {
|
||||||
|
return hostName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHostName(String hostName) {
|
||||||
|
this.hostName = hostName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public enum Status {
|
|||||||
Maintenance(false, false, false),
|
Maintenance(false, false, false),
|
||||||
Alert(true, true, true),
|
Alert(true, true, true),
|
||||||
Removed(true, false, true),
|
Removed(true, false, true),
|
||||||
Rebalance(false, false, false);
|
Rebalancing(false, false, false);
|
||||||
|
|
||||||
private final boolean updateManagementServer;
|
private final boolean updateManagementServer;
|
||||||
private final boolean checkManagementServer;
|
private final boolean checkManagementServer;
|
||||||
@ -137,7 +137,7 @@ public enum Status {
|
|||||||
s_fsm.addTransition(Status.Up, Event.Ping, Status.Up);
|
s_fsm.addTransition(Status.Up, Event.Ping, Status.Up);
|
||||||
s_fsm.addTransition(Status.Up, Event.AgentConnected, Status.Connecting);
|
s_fsm.addTransition(Status.Up, Event.AgentConnected, Status.Connecting);
|
||||||
s_fsm.addTransition(Status.Up, Event.ManagementServerDown, Status.Disconnected);
|
s_fsm.addTransition(Status.Up, Event.ManagementServerDown, Status.Disconnected);
|
||||||
s_fsm.addTransition(Status.Up, Event.StartAgentRebalance, Status.Rebalance);
|
s_fsm.addTransition(Status.Up, Event.StartAgentRebalance, Status.Rebalancing);
|
||||||
s_fsm.addTransition(Status.Updating, Event.PingTimeout, Status.Alert);
|
s_fsm.addTransition(Status.Updating, Event.PingTimeout, Status.Alert);
|
||||||
s_fsm.addTransition(Status.Updating, Event.Ping, Status.Updating);
|
s_fsm.addTransition(Status.Updating, Event.Ping, Status.Updating);
|
||||||
s_fsm.addTransition(Status.Updating, Event.AgentConnected, Status.Connecting);
|
s_fsm.addTransition(Status.Updating, Event.AgentConnected, Status.Connecting);
|
||||||
@ -183,8 +183,8 @@ public enum Status {
|
|||||||
s_fsm.addTransition(Status.Alert, Event.Ping, Status.Up);
|
s_fsm.addTransition(Status.Alert, Event.Ping, Status.Up);
|
||||||
s_fsm.addTransition(Status.Alert, Event.Remove, Status.Removed);
|
s_fsm.addTransition(Status.Alert, Event.Remove, Status.Removed);
|
||||||
s_fsm.addTransition(Status.Alert, Event.ManagementServerDown, Status.Alert);
|
s_fsm.addTransition(Status.Alert, Event.ManagementServerDown, Status.Alert);
|
||||||
s_fsm.addTransition(Status.Rebalance, Event.RebalanceFailed, Status.Alert);
|
s_fsm.addTransition(Status.Rebalancing, Event.RebalanceFailed, Status.Alert);
|
||||||
s_fsm.addTransition(Status.Rebalance, Event.RebalanceCompleted, Status.Connecting);
|
s_fsm.addTransition(Status.Rebalancing, Event.RebalanceCompleted, Status.Connecting);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@ -81,7 +81,7 @@ public interface NetworkService {
|
|||||||
|
|
||||||
Long getDedicatedNetworkDomain(long networkId);
|
Long getDedicatedNetworkDomain(long networkId);
|
||||||
|
|
||||||
Network updateNetwork(long networkId, String name, String displayText, Account caller);
|
Network updateNetwork(long networkId, String name, String displayText, List<String> tags, Account caller);
|
||||||
|
|
||||||
Integer getNetworkRate(long networkId, Long vmId);
|
Integer getNetworkRate(long networkId, Long vmId);
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import com.cloud.utils.fsm.StateObject;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VirtualMachine describes the properties held by a virtual machine
|
* VirtualMachine describes the properties held by a virtual machine
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject<VirtualMachine.State> {
|
public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject<VirtualMachine.State> {
|
||||||
@ -40,7 +40,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject
|
|||||||
Migrating(true, "VM is being migrated. host id holds to from host"),
|
Migrating(true, "VM is being migrated. host id holds to from host"),
|
||||||
Error(false, "VM is in error"),
|
Error(false, "VM is in error"),
|
||||||
Unknown(false, "VM state is unknown."),
|
Unknown(false, "VM state is unknown."),
|
||||||
Shutdowned(false, "VM is shutdowned from inside");
|
Shutdowned(false, "VM is shutdowned from inside");
|
||||||
|
|
||||||
|
|
||||||
private final boolean _transitional;
|
private final boolean _transitional;
|
||||||
@ -71,20 +71,20 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject
|
|||||||
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.AgentReportStopped, State.Stopped);
|
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.AgentReportStopped, State.Stopped);
|
||||||
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.OperationFailed, State.Error);
|
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.OperationFailed, State.Error);
|
||||||
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.ExpungeOperation, State.Expunging);
|
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.ExpungeOperation, State.Expunging);
|
||||||
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.AgentReportShutdowned, State.Stopped);
|
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.AgentReportShutdowned, State.Stopped);
|
||||||
s_fsm.addTransition(State.Starting, VirtualMachine.Event.OperationRetry, State.Starting);
|
s_fsm.addTransition(State.Starting, VirtualMachine.Event.OperationRetry, State.Starting);
|
||||||
s_fsm.addTransition(State.Starting, VirtualMachine.Event.OperationSucceeded, State.Running);
|
s_fsm.addTransition(State.Starting, VirtualMachine.Event.OperationSucceeded, State.Running);
|
||||||
s_fsm.addTransition(State.Starting, VirtualMachine.Event.OperationFailed, State.Stopped);
|
s_fsm.addTransition(State.Starting, VirtualMachine.Event.OperationFailed, State.Stopped);
|
||||||
s_fsm.addTransition(State.Starting, VirtualMachine.Event.AgentReportRunning, State.Running);
|
s_fsm.addTransition(State.Starting, VirtualMachine.Event.AgentReportRunning, State.Running);
|
||||||
s_fsm.addTransition(State.Starting, VirtualMachine.Event.AgentReportStopped, State.Stopped);
|
s_fsm.addTransition(State.Starting, VirtualMachine.Event.AgentReportStopped, State.Stopped);
|
||||||
s_fsm.addTransition(State.Starting, VirtualMachine.Event.AgentReportShutdowned, State.Stopped);
|
s_fsm.addTransition(State.Starting, VirtualMachine.Event.AgentReportShutdowned, State.Stopped);
|
||||||
s_fsm.addTransition(State.Destroyed, VirtualMachine.Event.RecoveryRequested, State.Stopped);
|
s_fsm.addTransition(State.Destroyed, VirtualMachine.Event.RecoveryRequested, State.Stopped);
|
||||||
s_fsm.addTransition(State.Destroyed, VirtualMachine.Event.ExpungeOperation, State.Expunging);
|
s_fsm.addTransition(State.Destroyed, VirtualMachine.Event.ExpungeOperation, State.Expunging);
|
||||||
s_fsm.addTransition(State.Running, VirtualMachine.Event.MigrationRequested, State.Migrating);
|
s_fsm.addTransition(State.Running, VirtualMachine.Event.MigrationRequested, State.Migrating);
|
||||||
s_fsm.addTransition(State.Running, VirtualMachine.Event.AgentReportRunning, State.Running);
|
s_fsm.addTransition(State.Running, VirtualMachine.Event.AgentReportRunning, State.Running);
|
||||||
s_fsm.addTransition(State.Running, VirtualMachine.Event.AgentReportStopped, State.Stopped);
|
s_fsm.addTransition(State.Running, VirtualMachine.Event.AgentReportStopped, State.Stopped);
|
||||||
s_fsm.addTransition(State.Running, VirtualMachine.Event.StopRequested, State.Stopping);
|
s_fsm.addTransition(State.Running, VirtualMachine.Event.StopRequested, State.Stopping);
|
||||||
s_fsm.addTransition(State.Running, VirtualMachine.Event.AgentReportShutdowned, State.Stopped);
|
s_fsm.addTransition(State.Running, VirtualMachine.Event.AgentReportShutdowned, State.Stopped);
|
||||||
s_fsm.addTransition(State.Migrating, VirtualMachine.Event.MigrationRequested, State.Migrating);
|
s_fsm.addTransition(State.Migrating, VirtualMachine.Event.MigrationRequested, State.Migrating);
|
||||||
s_fsm.addTransition(State.Migrating, VirtualMachine.Event.OperationSucceeded, State.Running);
|
s_fsm.addTransition(State.Migrating, VirtualMachine.Event.OperationSucceeded, State.Running);
|
||||||
s_fsm.addTransition(State.Migrating, VirtualMachine.Event.OperationFailed, State.Running);
|
s_fsm.addTransition(State.Migrating, VirtualMachine.Event.OperationFailed, State.Running);
|
||||||
@ -96,7 +96,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject
|
|||||||
s_fsm.addTransition(State.Stopping, VirtualMachine.Event.AgentReportRunning, State.Running);
|
s_fsm.addTransition(State.Stopping, VirtualMachine.Event.AgentReportRunning, State.Running);
|
||||||
s_fsm.addTransition(State.Stopping, VirtualMachine.Event.AgentReportStopped, State.Stopped);
|
s_fsm.addTransition(State.Stopping, VirtualMachine.Event.AgentReportStopped, State.Stopped);
|
||||||
s_fsm.addTransition(State.Stopping, VirtualMachine.Event.StopRequested, State.Stopping);
|
s_fsm.addTransition(State.Stopping, VirtualMachine.Event.StopRequested, State.Stopping);
|
||||||
s_fsm.addTransition(State.Stopping, VirtualMachine.Event.AgentReportShutdowned, State.Stopped);
|
s_fsm.addTransition(State.Stopping, VirtualMachine.Event.AgentReportShutdowned, State.Stopped);
|
||||||
s_fsm.addTransition(State.Expunging, VirtualMachine.Event.OperationFailed, State.Expunging);
|
s_fsm.addTransition(State.Expunging, VirtualMachine.Event.OperationFailed, State.Expunging);
|
||||||
s_fsm.addTransition(State.Expunging, VirtualMachine.Event.ExpungeOperation, State.Expunging);
|
s_fsm.addTransition(State.Expunging, VirtualMachine.Event.ExpungeOperation, State.Expunging);
|
||||||
s_fsm.addTransition(State.Error, VirtualMachine.Event.DestroyRequested, State.Expunging);
|
s_fsm.addTransition(State.Error, VirtualMachine.Event.DestroyRequested, State.Expunging);
|
||||||
@ -166,7 +166,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject
|
|||||||
/**
|
/**
|
||||||
* @return The name of the vm instance used by the cloud stack to uniquely
|
* @return The name of the vm instance used by the cloud stack to uniquely
|
||||||
* reference this VM. You can build names that starts with this name and it
|
* reference this VM. You can build names that starts with this name and it
|
||||||
* guarantees uniqueness for things related to the VM.
|
* guarantees uniqueness for things related to the VM.
|
||||||
*/
|
*/
|
||||||
public String getInstanceName();
|
public String getInstanceName();
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject
|
|||||||
public long getId();
|
public long getId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the host name of the virtual machine. If the user did not
|
* @return the host name of the virtual machine. If the user did not
|
||||||
* specify the host name when creating the virtual machine then it is
|
* specify the host name when creating the virtual machine then it is
|
||||||
* defaults to the instance name.
|
* defaults to the instance name.
|
||||||
*/
|
*/
|
||||||
@ -216,12 +216,12 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject
|
|||||||
/**
|
/**
|
||||||
* @return pod id.
|
* @return pod id.
|
||||||
*/
|
*/
|
||||||
public Long getPodId();
|
public Long getPodIdToDeployIn();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return data center id.
|
* @return data center id.
|
||||||
*/
|
*/
|
||||||
public long getDataCenterId();
|
public long getDataCenterIdToDeployIn();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return id of the host it was assigned last time.
|
* @return id of the host it was assigned last time.
|
||||||
@ -230,8 +230,6 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject
|
|||||||
@Override
|
@Override
|
||||||
public Long getHostId();
|
public Long getHostId();
|
||||||
|
|
||||||
public void setLastHostId(Long lastHostId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return should HA be enabled for this machine?
|
* @return should HA be enabled for this machine?
|
||||||
*/
|
*/
|
||||||
@ -239,8 +237,8 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return should limit CPU usage to the service offering?
|
* @return should limit CPU usage to the service offering?
|
||||||
*/
|
*/
|
||||||
public boolean limitCpuUse();
|
public boolean limitCpuUse();
|
||||||
/**
|
/**
|
||||||
* @return date when machine was created
|
* @return date when machine was created
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -210,6 +210,7 @@ label.add.primary.storage=Add Primary Storage
|
|||||||
label.add.secondary.storage=Add Secondary Storage
|
label.add.secondary.storage=Add Secondary Storage
|
||||||
label.add.security.group=Add Security Group
|
label.add.security.group=Add Security Group
|
||||||
label.add.service.offering=Add Service Offering
|
label.add.service.offering=Add Service Offering
|
||||||
|
label.add.system.service.offering=Add System Service Offering
|
||||||
label.add.template=Add Template
|
label.add.template=Add Template
|
||||||
label.add.user=Add User
|
label.add.user=Add User
|
||||||
label.add.vlan=Add VLAN
|
label.add.vlan=Add VLAN
|
||||||
@ -429,6 +430,7 @@ label.menu.physical.resources=Physical Resources
|
|||||||
label.menu.running.instances=Running Instances
|
label.menu.running.instances=Running Instances
|
||||||
label.menu.security.groups=Security Groups
|
label.menu.security.groups=Security Groups
|
||||||
label.menu.service.offerings=Service Offerings
|
label.menu.service.offerings=Service Offerings
|
||||||
|
label.menu.system.service.offerings=System Service Offerings
|
||||||
label.menu.snapshots=Snapshots
|
label.menu.snapshots=Snapshots
|
||||||
label.menu.stopped.instances=Stopped Instances
|
label.menu.stopped.instances=Stopped Instances
|
||||||
label.menu.storage=Storage
|
label.menu.storage=Storage
|
||||||
@ -541,6 +543,7 @@ label.security.groups=Security Groups
|
|||||||
label.sent=Sent
|
label.sent=Sent
|
||||||
label.server=Server
|
label.server=Server
|
||||||
label.service.offering=Service Offering
|
label.service.offering=Service Offering
|
||||||
|
label.system.service.offering=System Service Offering
|
||||||
label.session.expired=Session Expired
|
label.session.expired=Session Expired
|
||||||
label.shared=Shared
|
label.shared=Shared
|
||||||
label.size=Size
|
label.size=Size
|
||||||
@ -774,7 +777,8 @@ message.zone.step.2.desc=Please enter the following info to add a new zone
|
|||||||
message.zone.step.3.desc=Please enter the following info to add a new pod
|
message.zone.step.3.desc=Please enter the following info to add a new pod
|
||||||
message.apply.snapshot.policy=You have successfully updated your current snapshot policy.
|
message.apply.snapshot.policy=You have successfully updated your current snapshot policy.
|
||||||
message.disable.snapshot.policy=You have successfully disabled your current snapshot policy.
|
message.disable.snapshot.policy=You have successfully disabled your current snapshot policy.
|
||||||
message.action.change.service.warning=Your instance must be stopped before attempting to change its current service offering.
|
message.action.change.service.warning.for.instance=Your instance must be stopped before attempting to change its current service offering.
|
||||||
|
message.action.change.service.warning.for.router=Your router must be stopped before attempting to change its current service offering.
|
||||||
message.action.reset.password.warning=Your instance must be stopped before attempting to change its current password.
|
message.action.reset.password.warning=Your instance must be stopped before attempting to change its current password.
|
||||||
message.action.reset.password.off=Your instance currently does not support this feature.
|
message.action.reset.password.off=Your instance currently does not support this feature.
|
||||||
|
|
||||||
|
|||||||
@ -93,7 +93,7 @@
|
|||||||
<adapters key="com.cloud.acl.SecurityChecker">
|
<adapters key="com.cloud.acl.SecurityChecker">
|
||||||
<adapter name="DomainChecker" class="com.cloud.acl.DomainChecker"/>
|
<adapter name="DomainChecker" class="com.cloud.acl.DomainChecker"/>
|
||||||
</adapters>
|
</adapters>
|
||||||
<adapters key="com.cloud.cluster.agentlb">
|
<adapters key="com.cloud.cluster.agentlb.AgentLoadBalancerPlanner">
|
||||||
<adapter name="ClusterBasedAgentLbPlanner" class="com.cloud.cluster.agentlb.ClusterBasedAgentLoadBalancerPlanner"/>
|
<adapter name="ClusterBasedAgentLbPlanner" class="com.cloud.cluster.agentlb.ClusterBasedAgentLoadBalancerPlanner"/>
|
||||||
</adapters>
|
</adapters>
|
||||||
|
|
||||||
|
|||||||
@ -221,7 +221,6 @@ Requires: jpackage-utils
|
|||||||
Requires: %{name}-daemonize
|
Requires: %{name}-daemonize
|
||||||
Requires: /sbin/service
|
Requires: /sbin/service
|
||||||
Requires: /sbin/chkconfig
|
Requires: /sbin/chkconfig
|
||||||
Requires: jnetpcap
|
|
||||||
Group: System Environment/Libraries
|
Group: System Environment/Libraries
|
||||||
|
|
||||||
%package baremetal-agent
|
%package baremetal-agent
|
||||||
@ -304,6 +303,7 @@ The Cloud.com command line tools contain a few Python modules that can call clou
|
|||||||
%package premium-agent
|
%package premium-agent
|
||||||
Summary: Cloud.com premium agent
|
Summary: Cloud.com premium agent
|
||||||
Requires: cloud-agent
|
Requires: cloud-agent
|
||||||
|
Requires: jnetpcap
|
||||||
Group: System Environment/Libraries
|
Group: System Environment/Libraries
|
||||||
%description premium-agent
|
%description premium-agent
|
||||||
The Cloud.com premium agent
|
The Cloud.com premium agent
|
||||||
|
|||||||
@ -198,8 +198,8 @@ public class Request {
|
|||||||
_agentId = agentId;
|
_agentId = agentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVia(long agentId) {
|
public void setVia(long viaId) {
|
||||||
_via = agentId;
|
_via = viaId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean executeInSequence() {
|
public boolean executeInSequence() {
|
||||||
@ -238,8 +238,8 @@ public class Request {
|
|||||||
buffer.putLong(_seq);
|
buffer.putLong(_seq);
|
||||||
buffer.putInt(contentSize);
|
buffer.putInt(contentSize);
|
||||||
buffer.putLong(_mgmtId);
|
buffer.putLong(_mgmtId);
|
||||||
buffer.putLong(_via);
|
|
||||||
buffer.putLong(_agentId);
|
buffer.putLong(_agentId);
|
||||||
|
buffer.putLong(_via);
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
@ -301,6 +301,11 @@ public class Request {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return log("", true, Level.DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
protected String log(String msg, boolean logContent, Level level) {
|
protected String log(String msg, boolean logContent, Level level) {
|
||||||
StringBuilder content = new StringBuilder();
|
StringBuilder content = new StringBuilder();
|
||||||
@ -373,8 +378,8 @@ public class Request {
|
|||||||
final long seq = buff.getLong();
|
final long seq = buff.getLong();
|
||||||
final int size = buff.getInt();
|
final int size = buff.getInt();
|
||||||
final long mgmtId = buff.getLong();
|
final long mgmtId = buff.getLong();
|
||||||
final long via = buff.getLong();
|
|
||||||
final long agentId = buff.getLong();
|
final long agentId = buff.getLong();
|
||||||
|
final long via = buff.getLong();
|
||||||
|
|
||||||
byte[] command = null;
|
byte[] command = null;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@ -421,9 +426,13 @@ public class Request {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long getAgentId(final byte[] bytes) {
|
public static long getAgentId(final byte[] bytes) {
|
||||||
return NumbersUtil.bytesToLong(bytes, 24);
|
return NumbersUtil.bytesToLong(bytes, 28);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long getViaAgentId(final byte[] bytes) {
|
||||||
|
return NumbersUtil.bytesToLong(bytes, 24);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean fromServer(final byte[] bytes) {
|
public static boolean fromServer(final byte[] bytes) {
|
||||||
return (bytes[3] & FLAG_FROM_SERVER) > 0;
|
return (bytes[3] & FLAG_FROM_SERVER) > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -416,7 +416,7 @@ public class XenServer56Resource extends CitrixResourceBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StartupCommand[] initialize() {
|
public StartupCommand[] initialize() {
|
||||||
pingxenserver();
|
pingXenServer();
|
||||||
StartupCommand[] cmds = super.initialize();
|
StartupCommand[] cmds = super.initialize();
|
||||||
Connection conn = getConnection();
|
Connection conn = getConnection();
|
||||||
if (!setIptables(conn)) {
|
if (!setIptables(conn)) {
|
||||||
|
|||||||
@ -539,8 +539,8 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
_params.put(StorageLayer.InstanceConfigKey, _storage);
|
_params.put(StorageLayer.InstanceConfigKey, _storage);
|
||||||
_dlMgr = new DownloadManagerImpl();
|
_dlMgr = new DownloadManagerImpl();
|
||||||
_dlMgr.configure("DownloadManager", _params);
|
_dlMgr.configure("DownloadManager", _params);
|
||||||
//_upldMgr = new UploadManagerImpl();
|
_upldMgr = new UploadManagerImpl();
|
||||||
//_upldMgr.configure("UploadManager", params);
|
_upldMgr.configure("UploadManager", params);
|
||||||
} catch (ConfigurationException e) {
|
} catch (ConfigurationException e) {
|
||||||
s_logger.warn("Caught problem while configuring DownloadManager", e);
|
s_logger.warn("Caught problem while configuring DownloadManager", e);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -608,6 +608,7 @@ public class DownloadManagerImpl implements DownloadManager {
|
|||||||
|
|
||||||
private List<String> listTemplates(String rootdir) {
|
private List<String> listTemplates(String rootdir) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Script script = new Script(listTmpltScr, s_logger);
|
Script script = new Script(listTmpltScr, s_logger);
|
||||||
script.add("-r", rootdir);
|
script.add("-r", rootdir);
|
||||||
ZfsPathParser zpp = new ZfsPathParser(rootdir);
|
ZfsPathParser zpp = new ZfsPathParser(rootdir);
|
||||||
@ -621,6 +622,11 @@ public class DownloadManagerImpl implements DownloadManager {
|
|||||||
public Map<String, TemplateInfo> gatherTemplateInfo(String rootDir) {
|
public Map<String, TemplateInfo> gatherTemplateInfo(String rootDir) {
|
||||||
Map<String, TemplateInfo> result = new HashMap<String, TemplateInfo>();
|
Map<String, TemplateInfo> result = new HashMap<String, TemplateInfo>();
|
||||||
String templateDir = rootDir + File.separator + _templateDir;
|
String templateDir = rootDir + File.separator + _templateDir;
|
||||||
|
|
||||||
|
if (! _storage.exists(templateDir)) {
|
||||||
|
_storage.mkdirs(templateDir);
|
||||||
|
}
|
||||||
|
|
||||||
List<String> publicTmplts = listTemplates(templateDir);
|
List<String> publicTmplts = listTemplates(templateDir);
|
||||||
for (String tmplt : publicTmplts) {
|
for (String tmplt : publicTmplts) {
|
||||||
String path = tmplt.substring(0, tmplt.lastIndexOf(File.separator));
|
String path = tmplt.substring(0, tmplt.lastIndexOf(File.separator));
|
||||||
|
|||||||
@ -373,11 +373,10 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create a symbolic link from the actual directory to the template location. The entity would be directly visible under /var/www/html/userdata
|
// 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();
|
||||||
cmd.getInstallPath();
|
|
||||||
command = new Script("/bin/bash", s_logger);
|
command = new Script("/bin/bash", s_logger);
|
||||||
command.add("-c");
|
command.add("-c");
|
||||||
command.add("ln -sf " + extractMountPoint + File.separator + cmd.getInstallPath() + " " + extractDir + uuid);
|
command.add("ln -sf /mnt/SecStorage/" + cmd.getParent() + File.separator + cmd.getInstallPath() + " " + extractDir + uuid);
|
||||||
result = command.execute();
|
result = command.execute();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
String errorString = "Error in linking err=" + result;
|
String errorString = "Error in linking err=" + result;
|
||||||
|
|||||||
@ -90,8 +90,8 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getDataCenterId() {
|
public long getDataCenterIdToDeployIn() {
|
||||||
return dataCenterId;
|
return dataCenterIdToDeployIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPublicNetmask() {
|
public String getPublicNetmask() {
|
||||||
@ -123,6 +123,10 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||||||
this.role = role;
|
this.role = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getServiceOfferingId() {
|
||||||
|
return serviceOfferingId;
|
||||||
|
}
|
||||||
public void setServiceOfferingId(long serviceOfferingId) {
|
public void setServiceOfferingId(long serviceOfferingId) {
|
||||||
this.serviceOfferingId = serviceOfferingId;
|
this.serviceOfferingId = serviceOfferingId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,15 +93,15 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||||||
protected Long lastHostId;
|
protected Long lastHostId;
|
||||||
|
|
||||||
@Column(name="pod_id", updatable=true, nullable=false)
|
@Column(name="pod_id", updatable=true, nullable=false)
|
||||||
protected Long podId;
|
protected Long podIdToDeployIn;
|
||||||
|
|
||||||
@Column(name="private_mac_address", updatable=true, nullable=true)
|
@Column(name="private_mac_address", updatable=true, nullable=true)
|
||||||
protected String privateMacAddress;
|
protected String privateMacAddress;
|
||||||
|
|
||||||
@Column(name="data_center_id", updatable=true, nullable=false)
|
@Column(name="data_center_id", updatable=true, nullable=false)
|
||||||
protected long dataCenterId;
|
protected long dataCenterIdToDeployIn;
|
||||||
|
|
||||||
@Column(name="type", updatable=false, nullable=false, length=32)
|
@Column(name="vm_type", updatable=false, nullable=false, length=32)
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
protected Type type;
|
protected Type type;
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||||||
protected String reservationId;
|
protected String reservationId;
|
||||||
|
|
||||||
@Column(name="hypervisor_type")
|
@Column(name="hypervisor_type")
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
protected HypervisorType hypervisorType;
|
protected HypervisorType hypervisorType;
|
||||||
|
|
||||||
public VMInstanceVO(long id,
|
public VMInstanceVO(long id,
|
||||||
@ -166,7 +166,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||||||
this.domainId = domainId;
|
this.domainId = domainId;
|
||||||
this.serviceOfferingId = serviceOfferingId;
|
this.serviceOfferingId = serviceOfferingId;
|
||||||
this.hypervisorType = hypervisorType;
|
this.hypervisorType = hypervisorType;
|
||||||
this.limitCpuUse = false;
|
this.limitCpuUse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VMInstanceVO(long id,
|
public VMInstanceVO(long id,
|
||||||
@ -231,8 +231,8 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getDataCenterId() {
|
public long getDataCenterIdToDeployIn() {
|
||||||
return dataCenterId;
|
return dataCenterIdToDeployIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -335,7 +335,6 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||||||
return lastHostId;
|
return lastHostId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLastHostId(Long lastHostId) {
|
public void setLastHostId(Long lastHostId) {
|
||||||
this.lastHostId = lastHostId;
|
this.lastHostId = lastHostId;
|
||||||
}
|
}
|
||||||
@ -352,7 +351,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||||||
@Override
|
@Override
|
||||||
public boolean limitCpuUse() {
|
public boolean limitCpuUse() {
|
||||||
return limitCpuUse;
|
return limitCpuUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrivateMacAddress() {
|
public String getPrivateMacAddress() {
|
||||||
@ -360,12 +359,12 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getPodId() {
|
public Long getPodIdToDeployIn() {
|
||||||
return podId;
|
return podIdToDeployIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPodId(long podId) {
|
public void setPodId(long podId) {
|
||||||
this.podId = podId;
|
this.podIdToDeployIn = podId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrivateMacAddress(String privateMacAddress) {
|
public void setPrivateMacAddress(String privateMacAddress) {
|
||||||
@ -373,7 +372,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDataCenterId(long dataCenterId) {
|
public void setDataCenterId(long dataCenterId) {
|
||||||
this.dataCenterId = dataCenterId;
|
this.dataCenterIdToDeployIn = dataCenterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRemoved() {
|
public boolean isRemoved() {
|
||||||
|
|||||||
@ -42,8 +42,13 @@ public class RequestTest extends TestCase {
|
|||||||
private static final Logger s_logger = Logger.getLogger(RequestTest.class);
|
private static final Logger s_logger = Logger.getLogger(RequestTest.class);
|
||||||
|
|
||||||
public void testSerDeser() {
|
public void testSerDeser() {
|
||||||
|
s_logger.info("Testing serializing and deserializing works as expected");
|
||||||
|
|
||||||
|
s_logger.info("UpdateHostPasswordCommand should have two parameters that doesn't show in logging");
|
||||||
UpdateHostPasswordCommand cmd1 = new UpdateHostPasswordCommand("abc", "def");
|
UpdateHostPasswordCommand cmd1 = new UpdateHostPasswordCommand("abc", "def");
|
||||||
|
s_logger.info("SecStorageFirewallCfgCommand has a context map that shouldn't show up in debug level");
|
||||||
SecStorageFirewallCfgCommand cmd2 = new SecStorageFirewallCfgCommand();
|
SecStorageFirewallCfgCommand cmd2 = new SecStorageFirewallCfgCommand();
|
||||||
|
s_logger.info("GetHostStatsCommand should not show up at all in debug level");
|
||||||
GetHostStatsCommand cmd3 = new GetHostStatsCommand("hostguid", "hostname", 101);
|
GetHostStatsCommand cmd3 = new GetHostStatsCommand("hostguid", "hostname", 101);
|
||||||
cmd2.addPortConfig("abc", "24", true, "eth0");
|
cmd2.addPortConfig("abc", "24", true, "eth0");
|
||||||
cmd2.addPortConfig("127.0.0.1", "44", false, "eth1");
|
cmd2.addPortConfig("127.0.0.1", "44", false, "eth1");
|
||||||
@ -113,6 +118,7 @@ public class RequestTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testDownload() {
|
public void testDownload() {
|
||||||
|
s_logger.info("Testing Download answer");
|
||||||
VMTemplateVO template = new VMTemplateVO(1, "templatename", ImageFormat.QCOW2, true, true, true, TemplateType.USER, "url", true, 32, 1, "chksum", "displayText", true, 30, true,
|
VMTemplateVO template = new VMTemplateVO(1, "templatename", ImageFormat.QCOW2, true, true, true, TemplateType.USER, "url", true, 32, 1, "chksum", "displayText", true, 30, true,
|
||||||
HypervisorType.KVM);
|
HypervisorType.KVM);
|
||||||
DownloadCommand cmd = new DownloadCommand("secUrl", template, 30000000l);
|
DownloadCommand cmd = new DownloadCommand("secUrl", template, 30000000l);
|
||||||
@ -128,6 +134,7 @@ public class RequestTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testLogging() {
|
public void testLogging() {
|
||||||
|
s_logger.info("Testing Logging");
|
||||||
GetHostStatsCommand cmd3 = new GetHostStatsCommand("hostguid", "hostname", 101);
|
GetHostStatsCommand cmd3 = new GetHostStatsCommand("hostguid", "hostname", 101);
|
||||||
Request sreq = new Request(2, 3, new Command[] { cmd3 }, true, true);
|
Request sreq = new Request(2, 3, new Command[] { cmd3 }, true, true);
|
||||||
sreq.setSequence(1);
|
sreq.setSequence(1);
|
||||||
|
|||||||
2
deps/.classpath
vendored
2
deps/.classpath
vendored
@ -51,6 +51,6 @@
|
|||||||
<classpathentry exported="true" kind="lib" path="vmware-vim25.jar"/>
|
<classpathentry exported="true" kind="lib" path="vmware-vim25.jar"/>
|
||||||
<classpathentry exported="true" kind="lib" path="jetty-6.1.26.jar"/>
|
<classpathentry exported="true" kind="lib" path="jetty-6.1.26.jar"/>
|
||||||
<classpathentry exported="true" kind="lib" path="jetty-util-6.1.26.jar"/>
|
<classpathentry exported="true" kind="lib" path="jetty-util-6.1.26.jar"/>
|
||||||
|
<classpathentry exported="true" kind="lib" path="cloud-manageontap.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@ -9,7 +9,7 @@ class globalEnv:
|
|||||||
#debug
|
#debug
|
||||||
self.debug = False
|
self.debug = False
|
||||||
#management server IP
|
#management server IP
|
||||||
self.mgtSvr = None
|
self.mgtSvr = "myagent.cloud.com"
|
||||||
#zone id or zone name
|
#zone id or zone name
|
||||||
self.zone = None
|
self.zone = None
|
||||||
#pod id or pod name
|
#pod id or pod name
|
||||||
@ -21,4 +21,4 @@ class globalEnv:
|
|||||||
#uuid
|
#uuid
|
||||||
self.uuid = None
|
self.uuid = None
|
||||||
#default private network
|
#default private network
|
||||||
self.privateNet = "cloudbr0"
|
self.privateNet = "cloudbr0"
|
||||||
|
|||||||
@ -72,8 +72,12 @@ class sysConfigAgent(sysConfig):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
raise CloudInternalException("Need to execute with root permission")
|
raise CloudInternalException("Need to execute with root permission\n")
|
||||||
|
|
||||||
|
hostname = bash("hostname -f")
|
||||||
|
if not hostname.isSuccess():
|
||||||
|
raise CloudInternalException("Checking hostname ... [Failed]\nPlease edit /etc/hosts, add a Fully Qualified Domain Name as your hostname\n")
|
||||||
|
|
||||||
kvmEnabled = self.svo.isKVMEnabled()
|
kvmEnabled = self.svo.isKVMEnabled()
|
||||||
if not kvmEnabled:
|
if not kvmEnabled:
|
||||||
raise CloudInternalException("Checking KVM...[Failed]\nPlease enable KVM on this machine\n")
|
raise CloudInternalException("Checking KVM...[Failed]\nPlease enable KVM on this machine\n")
|
||||||
@ -125,7 +129,7 @@ class sysConfigServer(sysConfig):
|
|||||||
raise CloudInternalException("Need to execute with root permission")
|
raise CloudInternalException("Need to execute with root permission")
|
||||||
hostname = bash("hostname -f")
|
hostname = bash("hostname -f")
|
||||||
if not hostname.isSuccess():
|
if not hostname.isSuccess():
|
||||||
raise CloudInternalException("Checking hostname ... [Failed]\nNeed to have a Fully Qualified Domain Name as your hostname")
|
raise CloudInternalException("Checking hostname ... [Failed]\nPlease edit /etc/hosts, add a Fully Qualified Domain Name as your hostname\n")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class sysConfigServerRedhat(sysConfigServer):
|
class sysConfigServerRedhat(sysConfigServer):
|
||||||
|
|||||||
@ -111,6 +111,12 @@ if [ $type == "nfs" ]; then
|
|||||||
uuid=$(uuidgen -r)
|
uuid=$(uuidgen -r)
|
||||||
desvhd=/var/run/sr-mount/$sruuid/$uuid
|
desvhd=/var/run/sr-mount/$sruuid/$uuid
|
||||||
copyvhd $desvhd $vhdfile 0 $type
|
copyvhd $desvhd $vhdfile 0 $type
|
||||||
|
$VHDUTIL set -n $desvhd -f "hidden" -v "0" > /dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "21#failed to set hidden to 0 $desvhd"
|
||||||
|
cleanup
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
mv /var/run/sr-mount/$sruuid/$uuid /var/run/sr-mount/$sruuid/${uuid}.vhd
|
mv /var/run/sr-mount/$sruuid/$uuid /var/run/sr-mount/$sruuid/${uuid}.vhd
|
||||||
xe sr-scan uuid=$sruuid
|
xe sr-scan uuid=$sruuid
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
@ -140,6 +146,12 @@ elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
copyvhd $desvhd $vhdfile $lvsize $type
|
copyvhd $desvhd $vhdfile $lvsize $type
|
||||||
|
$VHDUTIL set -n $desvhd -f "hidden" -v "0" > /dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "22#failed to set hidden to 0 $desvhd"
|
||||||
|
cleanup
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
xe sr-scan uuid=$sruuid
|
xe sr-scan uuid=$sruuid
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "14#failed to scan sr $sruuid"
|
echo "14#failed to scan sr $sruuid"
|
||||||
|
|||||||
@ -4,8 +4,7 @@
|
|||||||
# [Name of file]=[source path],[file permission],[destination path]
|
# [Name of file]=[source path],[file permission],[destination path]
|
||||||
# [destination path] is required.
|
# [destination path] is required.
|
||||||
# If [file permission] is missing, 755 is assumed.
|
# If [file permission] is missing, 755 is assumed.
|
||||||
# If [source path] is missing, it looks in the same
|
# If [source path] is missing, it looks in the same directory as the patch file.
|
||||||
# directory as the patch file.
|
|
||||||
# If [source path] starts with '/', then it is absolute path.
|
# If [source path] starts with '/', then it is absolute path.
|
||||||
# If [source path] starts with '~', then it is path relative to management server home directory.
|
# If [source path] starts with '~', then it is path relative to management server home directory.
|
||||||
# If [source path] does not start with '/' or '~', then it is relative path to the location of the patch file.
|
# If [source path] does not start with '/' or '~', then it is relative path to the location of the patch file.
|
||||||
|
|||||||
@ -82,7 +82,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
|
|||||||
// validate that the template is usable by the account
|
// validate that the template is usable by the account
|
||||||
if (!template.isPublicTemplate()) {
|
if (!template.isPublicTemplate()) {
|
||||||
Account owner = _accountDao.findById(template.getAccountId());
|
Account owner = _accountDao.findById(template.getAccountId());
|
||||||
if (BaseCmd.isAdmin(owner.getType()) || (owner.getId() == caller.getId())) {
|
if (BaseCmd.isRootAdmin(caller.getType()) || (owner.getId() == caller.getId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,11 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.cloud.agent.manager;
|
package com.cloud.agent.manager;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -238,8 +240,25 @@ public abstract class AgentAttache {
|
|||||||
return _requests.size();
|
return _requests.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getListenersSize() {
|
public int getNonRecurringListenersSize() {
|
||||||
return _waitForList.size();
|
List<Listener> nonRecurringListenersList = new ArrayList<Listener>();
|
||||||
|
if (_waitForList.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
final Set<Map.Entry<Long, Listener>> entries = _waitForList.entrySet();
|
||||||
|
final Iterator<Map.Entry<Long, Listener>> it = entries.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
final Map.Entry<Long, Listener> entry = it.next();
|
||||||
|
final Listener monitor = entry.getValue();
|
||||||
|
if (!monitor.isRecurring()) {
|
||||||
|
//TODO - remove this debug statement later
|
||||||
|
s_logger.debug("Listener is " + entry.getValue() + " waiting on " + entry.getKey());
|
||||||
|
nonRecurringListenersList.add(monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nonRecurringListenersList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean processAnswers(final long seq, final Response resp) {
|
public boolean processAnswers(final long seq, final Response resp) {
|
||||||
|
|||||||
@ -82,6 +82,7 @@ import com.cloud.capacity.CapacityVO;
|
|||||||
import com.cloud.capacity.dao.CapacityDao;
|
import com.cloud.capacity.dao.CapacityDao;
|
||||||
import com.cloud.cluster.ManagementServerNode;
|
import com.cloud.cluster.ManagementServerNode;
|
||||||
import com.cloud.cluster.StackMaid;
|
import com.cloud.cluster.StackMaid;
|
||||||
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.dc.ClusterDetailsDao;
|
import com.cloud.dc.ClusterDetailsDao;
|
||||||
import com.cloud.dc.ClusterDetailsVO;
|
import com.cloud.dc.ClusterDetailsVO;
|
||||||
@ -274,6 +275,9 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||||||
_pingTimeout = (long) (multiplier * _pingInterval);
|
_pingTimeout = (long) (multiplier * _pingInterval);
|
||||||
|
|
||||||
s_logger.info("Ping Timeout is " + _pingTimeout);
|
s_logger.info("Ping Timeout is " + _pingTimeout);
|
||||||
|
|
||||||
|
value = configs.get(Config.DirectAgentLoadSize.key());
|
||||||
|
int threads = NumbersUtil.parseInt(value, 16);
|
||||||
|
|
||||||
_instance = configs.get("instance.name");
|
_instance = configs.get("instance.name");
|
||||||
if (_instance == null) {
|
if (_instance == null) {
|
||||||
@ -287,7 +291,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||||||
_monitor = new AgentMonitor(_nodeId, _hostDao, _vmDao, _dcDao, _podDao, this, _alertMgr, _pingTimeout);
|
_monitor = new AgentMonitor(_nodeId, _hostDao, _vmDao, _dcDao, _podDao, this, _alertMgr, _pingTimeout);
|
||||||
registerForHostEvents(_monitor, true, true, false);
|
registerForHostEvents(_monitor, true, true, false);
|
||||||
|
|
||||||
_executor = new ThreadPoolExecutor(16, 100, 60l, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("AgentTaskPool"));
|
_executor = new ThreadPoolExecutor(threads, threads, 60l, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("AgentTaskPool"));
|
||||||
|
|
||||||
_connection = new NioServer("AgentManager", _port, workers + 10, this);
|
_connection = new NioServer("AgentManager", _port, workers + 10, this);
|
||||||
|
|
||||||
@ -489,9 +493,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||||||
@Override
|
@Override
|
||||||
public HostVO getSSAgent(HostVO ssHost) {
|
public HostVO getSSAgent(HostVO ssHost) {
|
||||||
if( ssHost.getType() == Host.Type.LocalSecondaryStorage ) {
|
if( ssHost.getType() == Host.Type.LocalSecondaryStorage ) {
|
||||||
if( ssHost.getStatus() == Status.Up ) {
|
return ssHost;
|
||||||
return ssHost;
|
|
||||||
}
|
|
||||||
} else if ( ssHost.getType() == Host.Type.SecondaryStorage) {
|
} else if ( ssHost.getType() == Host.Type.SecondaryStorage) {
|
||||||
Long dcId = ssHost.getDataCenterId();
|
Long dcId = ssHost.getDataCenterId();
|
||||||
List<HostVO> ssAHosts = _hostDao.listBy(Host.Type.SecondaryStorageVM, dcId);
|
List<HostVO> ssAHosts = _hostDao.listBy(Host.Type.SecondaryStorageVM, dcId);
|
||||||
@ -2155,7 +2157,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||||||
|
|
||||||
Response response = null;
|
Response response = null;
|
||||||
if (attache == null) {
|
if (attache == null) {
|
||||||
s_logger.debug("Processing sequence " + request.getSequence() + ": Processing " + request.toString());
|
request.logD("Processing the first command ");
|
||||||
if (!(cmd instanceof StartupCommand)) {
|
if (!(cmd instanceof StartupCommand)) {
|
||||||
s_logger.warn("Throwing away a request because it came through as the first command on a connect: " + request.toString());
|
s_logger.warn("Throwing away a request because it came through as the first command on a connect: " + request.toString());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -129,7 +129,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
|
|
||||||
// schedule transfer scan executor - if agent LB is enabled
|
// schedule transfer scan executor - if agent LB is enabled
|
||||||
if (_clusterMgr.isAgentRebalanceEnabled()) {
|
if (_clusterMgr.isAgentRebalanceEnabled()) {
|
||||||
s_transferExecutor.scheduleAtFixedRate(getTransferScanTask(), ClusteredAgentRebalanceService.DEFAULT_TRANSFER_CHECK_INTERVAL, ClusteredAgentRebalanceService.DEFAULT_TRANSFER_CHECK_INTERVAL,
|
s_transferExecutor.scheduleAtFixedRate(getTransferScanTask(), 60000, ClusteredAgentRebalanceService.DEFAULT_TRANSFER_CHECK_INTERVAL,
|
||||||
TimeUnit.MILLISECONDS);
|
TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +524,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (agent == null) {
|
if (agent == null) {
|
||||||
throw new AgentUnavailableException("Host is not in the right state", hostId);
|
throw new AgentUnavailableException("Host is not in the right state: " + host.getStatus() , hostId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return agent;
|
return agent;
|
||||||
@ -698,23 +698,26 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
@Override
|
@Override
|
||||||
public void startRebalanceAgents() {
|
public void startRebalanceAgents() {
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Management server " + _nodeId + " was asked to do agent rebalancing; checking how many hosts can be taken from this server");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ManagementServerHostVO> allMS = _mshostDao.listBy(ManagementServerHost.State.Up, ManagementServerHost.State.Starting);
|
List<ManagementServerHostVO> allMS = _mshostDao.listBy(ManagementServerHost.State.Up, ManagementServerHost.State.Starting);
|
||||||
List<HostVO> allManagedAgents = _hostDao.listManagedAgents();
|
List<HostVO> allManagedAgents = _hostDao.listManagedRoutingAgents();
|
||||||
|
|
||||||
long avLoad = 0L;
|
int avLoad = 0;
|
||||||
|
|
||||||
if (!allManagedAgents.isEmpty() && !allMS.isEmpty()) {
|
if (!allManagedAgents.isEmpty() && !allMS.isEmpty()) {
|
||||||
avLoad = allManagedAgents.size() / allMS.size();
|
avLoad = allManagedAgents.size() / allMS.size();
|
||||||
} else {
|
} else {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Management server " + _nodeId + " found no hosts to rebalance. Current number of active management server nodes in the system is " + allMS.size() + "; number of managed agents is " + allMS.size());
|
s_logger.debug("There are no hosts to rebalance in the system. Current number of active management server nodes in the system is " + allMS.size() + "; number of managed agents is " + allManagedAgents.size());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (avLoad == 0L) {
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug("As calculated average load is less than 1, rounding it to 1");
|
||||||
|
}
|
||||||
|
avLoad = 1;
|
||||||
|
}
|
||||||
|
|
||||||
for (ManagementServerHostVO node : allMS) {
|
for (ManagementServerHostVO node : allMS) {
|
||||||
if (node.getMsid() != _nodeId) {
|
if (node.getMsid() != _nodeId) {
|
||||||
@ -722,21 +725,21 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
List<HostVO> hostsToRebalance = new ArrayList<HostVO>();
|
List<HostVO> hostsToRebalance = new ArrayList<HostVO>();
|
||||||
for (AgentLoadBalancerPlanner lbPlanner : _lbPlanners) {
|
for (AgentLoadBalancerPlanner lbPlanner : _lbPlanners) {
|
||||||
hostsToRebalance = lbPlanner.getHostsToRebalance(node.getMsid(), avLoad);
|
hostsToRebalance = lbPlanner.getHostsToRebalance(node.getMsid(), avLoad);
|
||||||
if (!hostsToRebalance.isEmpty()) {
|
if (hostsToRebalance != null && !hostsToRebalance.isEmpty()) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Agent load balancer planner " + lbPlanner.getName() + " found no hosts to be rebalanced from management server " + _nodeId);
|
s_logger.debug("Agent load balancer planner " + lbPlanner.getName() + " found no hosts to be rebalanced from management server " + node.getMsid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hostsToRebalance.isEmpty()) {
|
if (hostsToRebalance != null && !hostsToRebalance.isEmpty()) {
|
||||||
for (HostVO host : hostsToRebalance) {
|
for (HostVO host : hostsToRebalance) {
|
||||||
long hostId = host.getId();
|
long hostId = host.getId();
|
||||||
s_logger.debug("Asking management server " + node.getMsid() + " to give away host id=" + hostId);
|
s_logger.debug("Asking management server " + node.getMsid() + " to give away host id=" + hostId);
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
HostTransferMapVO transfer = _hostTransferDao.startAgentTransfering(hostId, _nodeId, node.getMsid());
|
HostTransferMapVO transfer = _hostTransferDao.startAgentTransfering(hostId, node.getMsid(), _nodeId);
|
||||||
try {
|
try {
|
||||||
Answer[] answer = sendRebalanceCommand(hostId, _nodeId, Event.RequestAgentRebalance);
|
Answer[] answer = sendRebalanceCommand(hostId, node.getMsid(), Event.RequestAgentRebalance);
|
||||||
if (answer == null) {
|
if (answer == null) {
|
||||||
s_logger.warn("Failed to get host id=" + hostId + " from management server " + node.getMsid());
|
s_logger.warn("Failed to get host id=" + hostId + " from management server " + node.getMsid());
|
||||||
result = false;
|
result = false;
|
||||||
@ -756,7 +759,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Management server " + _nodeId + " found no hosts to rebalance.");
|
s_logger.debug("Found no hosts to rebalance from the management server " + node.getMsid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -797,10 +800,11 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
s_logger.debug("Found " + _agentToTransferIds.size() + " agents to transfer");
|
s_logger.debug("Found " + _agentToTransferIds.size() + " agents to transfer");
|
||||||
for (Long hostId : _agentToTransferIds) {
|
for (Long hostId : _agentToTransferIds) {
|
||||||
AgentAttache attache = findAttache(hostId);
|
AgentAttache attache = findAttache(hostId);
|
||||||
if (attache.getQueueSize() == 0 && attache.getListenersSize() == 0) {
|
if (attache.getQueueSize() == 0 && attache.getNonRecurringListenersSize() == 0) {
|
||||||
boolean result = true;
|
boolean result = false;
|
||||||
_agentToTransferIds.remove(hostId);
|
_agentToTransferIds.remove(hostId);
|
||||||
try {
|
try {
|
||||||
|
_hostTransferDao.startAgentTransfer(hostId);
|
||||||
result = rebalanceHost(hostId);
|
result = rebalanceHost(hostId);
|
||||||
} finally {
|
} finally {
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -810,16 +814,16 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if we timed out waiting for the host to reconnect, remove host from rebalance list and mark it as failed to rebalance
|
// if we timed out waiting for the host to reconnect, remove host from rebalance list and delete from op_host_transfer DB
|
||||||
// no need to do anything with the real attache
|
// no need to do anything with the real attache
|
||||||
Date cutTime = DateUtil.currentGMTTime();
|
Date cutTime = DateUtil.currentGMTTime();
|
||||||
if (!(_hostTransferDao.isActive(hostId, new Date(cutTime.getTime() - rebalanceTimeOut)))) {
|
if (_hostTransferDao.isNotActive(hostId, new Date(cutTime.getTime() - rebalanceTimeOut))) {
|
||||||
s_logger.debug("Timed out waiting for the host id=" + hostId + " to be ready to transfer, failing rebalance for this host");
|
s_logger.debug("Timed out waiting for the host id=" + hostId + " to be ready to transfer, failing rebalance for this host");
|
||||||
_agentToTransferIds.remove(hostId);
|
_agentToTransferIds.remove(hostId);
|
||||||
HostTransferMapVO transferMap = _hostTransferDao.findById(hostId);
|
_hostTransferDao.completeAgentTransfer(hostId);
|
||||||
transferMap.setState(HostTransferState.TransferFailed);
|
} else {
|
||||||
_hostTransferDao.update(hostId, transferMap);
|
s_logger.debug("Agent " + hostId + " can't be transfered yet as its request queue size is " + attache.getQueueSize() + " and listener queue size is " + attache.getNonRecurringListenersSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -859,7 +863,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
_agents.put(hostId, attache);
|
_agents.put(hostId, attache);
|
||||||
if (host != null && host.getRemoved() == null) {
|
if (host != null && host.getRemoved() == null) {
|
||||||
host.setManagementServerId(null);
|
host.setManagementServerId(null);
|
||||||
s_logger.debug("Updating host id=" + hostId + " with the status " + Status.Rebalance);
|
s_logger.debug("Updating host id=" + hostId + " with the status " + Status.Rebalancing);
|
||||||
_hostDao.updateStatus(host, Event.StartAgentRebalance, _nodeId);
|
_hostDao.updateStatus(host, Event.StartAgentRebalance, _nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,7 +881,10 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
s_logger.debug("Got host id=" + hostId + " from management server " + map.getFutureOwner());
|
s_logger.debug("Got host id=" + hostId + " from management server " + map.getFutureOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
|
s_logger.warn("Unable to find agent " + hostId + " on management server " + _nodeId);
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
} else if (map.getFutureOwner() == _nodeId) {
|
} else if (map.getFutureOwner() == _nodeId) {
|
||||||
try {
|
try {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
@ -887,61 +894,57 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
loadDirectlyConnectedHost(host);
|
loadDirectlyConnectedHost(host);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
s_logger.warn("Unable to load directly connected host " + host.getId() + " as a part of rebalance due to exception: ", ex);
|
s_logger.warn("Unable to load directly connected host " + host.getId() + " as a part of rebalance due to exception: ", ex);
|
||||||
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean finishRebalance(final long hostId, Event event) {
|
private boolean finishRebalance(final long hostId, Event event) {
|
||||||
HostTransferMapVO map = _hostTransferDao.findById(hostId);
|
HostTransferMapVO map = _hostTransferDao.findById(hostId);
|
||||||
AgentAttache attache = findAttache(hostId);
|
|
||||||
|
|
||||||
if (attache == null) {
|
|
||||||
s_logger.debug("Unable to find attache for the host id=" + hostId + ", assuming that the agent disconnected already");
|
|
||||||
HostTransferState state = (event == Event.RebalanceCompleted) ? HostTransferState.TransferCompleted : HostTransferState.TransferFailed;
|
|
||||||
map.setState(state);
|
|
||||||
_hostTransferDao.update(hostId, map);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map.getInitialOwner() != _nodeId) {
|
if (map.getInitialOwner() != _nodeId) {
|
||||||
s_logger.warn("Why finish rebalance called not by initial host owner???");
|
s_logger.warn("Why finish rebalance called not by initial host owner???");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
boolean success = (event == Event.RebalanceCompleted) ? true : false;
|
||||||
s_logger.debug("Finishing rebalancing for the host id=" + hostId);
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug("Finishing rebalancing for the agent " + hostId + " with result " + success);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event == Event.RebalanceFailed) {
|
AgentAttache attache = findAttache(hostId);
|
||||||
((ClusteredDirectAgentAttache) attache).setTransferMode(false);
|
if (attache == null) {
|
||||||
s_logger.debug("Rebalance failed for the host id=" + hostId);
|
s_logger.debug("Unable to find attache for the host id=" + hostId + ", assuming that the agent disconnected already");
|
||||||
map.setState(HostTransferState.TransferFailed);
|
return true;
|
||||||
_hostTransferDao.update(hostId, map);
|
} else if (success) {
|
||||||
} else if (event == Event.RebalanceCompleted) {
|
s_logger.debug("Management server " + _nodeId + " is completing agent " + hostId + " rebalance");
|
||||||
|
//1) Get all the requests before removing transfer attache
|
||||||
//1) Get all the requests remove transfer attache
|
|
||||||
LinkedList<Request> requests = ((ClusteredDirectAgentAttache) attache).getRequests();
|
LinkedList<Request> requests = ((ClusteredDirectAgentAttache) attache).getRequests();
|
||||||
removeAgent(attache, Status.Rebalance);
|
removeAgent(attache, Status.Rebalancing);
|
||||||
|
|
||||||
//2) Create forward attache
|
//2) Create forward attache
|
||||||
createAttache(hostId);
|
try {
|
||||||
|
getAttache(hostId);
|
||||||
//3) forward all the requests to the management server which owns the host now
|
//3) forward all the requests to the management server which owns the host now
|
||||||
if (!requests.isEmpty()) {
|
if (!requests.isEmpty()) {
|
||||||
for (Request request : requests) {
|
s_logger.debug("Forwarding requests held in transfer attache " + hostId + " from the management server " + _nodeId + " to " + map.getFutureOwner());
|
||||||
routeToPeer(Long.toString(map.getFutureOwner()), request.getBytes());
|
for (Request request : requests) {
|
||||||
|
routeToPeer(Long.toString(map.getFutureOwner()), request.getBytes());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (AgentUnavailableException ex) {
|
||||||
|
s_logger.warn("Not creating forward attache as agent is not available", ex);
|
||||||
|
//TODO - - have to handle the case when requests can't be forwarded due to lack of forward attache
|
||||||
}
|
}
|
||||||
|
|
||||||
map.setState(HostTransferState.TransferCompleted);
|
} else {
|
||||||
_hostTransferDao.update(hostId, map);
|
((ClusteredDirectAgentAttache) attache).setTransferMode(false);
|
||||||
|
//TODO - have to handle the case when agent fails to rebalance 1) Either connect it back 2) Or disconnect it
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_hostTransferDao.completeAgentTransfer(hostId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public class ConsoleProxyAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
proxy.getPodId(),
|
proxy.getPodIdToDeployIn(),
|
||||||
"Console proxy up in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress()
|
"Console proxy up in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress()
|
||||||
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
|
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
|
||||||
"Console proxy up (zone " + dc.getName() + ")"
|
"Console proxy up (zone " + dc.getName() + ")"
|
||||||
@ -89,7 +89,7 @@ public class ConsoleProxyAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
proxy.getPodId(),
|
proxy.getPodIdToDeployIn(),
|
||||||
"Console proxy down in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress()
|
"Console proxy down in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress()
|
||||||
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
|
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
|
||||||
"Console proxy down (zone " + dc.getName() + ")"
|
"Console proxy down (zone " + dc.getName() + ")"
|
||||||
@ -105,7 +105,7 @@ public class ConsoleProxyAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
proxy.getPodId(),
|
proxy.getPodIdToDeployIn(),
|
||||||
"Console proxy rebooted in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress()
|
"Console proxy rebooted in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress()
|
||||||
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
|
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
|
||||||
"Console proxy rebooted (zone " + dc.getName() + ")"
|
"Console proxy rebooted (zone " + dc.getName() + ")"
|
||||||
@ -121,7 +121,7 @@ public class ConsoleProxyAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
proxy.getPodId(),
|
proxy.getPodIdToDeployIn(),
|
||||||
"Console proxy creation failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress()
|
"Console proxy creation failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress()
|
||||||
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress())
|
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress())
|
||||||
+ ", error details: " + args.getMessage(),
|
+ ", error details: " + args.getMessage(),
|
||||||
@ -138,7 +138,7 @@ public class ConsoleProxyAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
proxy.getPodId(),
|
proxy.getPodIdToDeployIn(),
|
||||||
"Console proxy startup failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress()
|
"Console proxy startup failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress()
|
||||||
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress())
|
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress())
|
||||||
+ ", error details: " + args.getMessage(),
|
+ ", error details: " + args.getMessage(),
|
||||||
@ -155,7 +155,7 @@ public class ConsoleProxyAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
AlertManager.ALERT_TYPE_CONSOLE_PROXY,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
proxy.getPodId(),
|
proxy.getPodIdToDeployIn(),
|
||||||
"Failed to open console proxy firewall port. zone: " + dc.getName() + ", proxy: " + proxy.getHostName()
|
"Failed to open console proxy firewall port. zone: " + dc.getName() + ", proxy: " + proxy.getHostName()
|
||||||
+ ", public IP: " + proxy.getPublicIpAddress()
|
+ ", public IP: " + proxy.getPublicIpAddress()
|
||||||
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
|
+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
|
||||||
@ -172,7 +172,7 @@ public class ConsoleProxyAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_STORAGE_MISC,
|
AlertManager.ALERT_TYPE_STORAGE_MISC,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
proxy.getPodId(),
|
proxy.getPodIdToDeployIn(),
|
||||||
"Console proxy storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(),
|
"Console proxy storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(),
|
||||||
"Console proxy alert (zone " + dc.getName() + ")"
|
"Console proxy alert (zone " + dc.getName() + ")"
|
||||||
);
|
);
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public class SecondaryStorageVmAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_SSVM,
|
AlertManager.ALERT_TYPE_SSVM,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
secStorageVm.getPodId(),
|
secStorageVm.getPodIdToDeployIn(),
|
||||||
"Secondary Storage Vm up in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
|
"Secondary Storage Vm up in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
|
||||||
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
|
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
|
||||||
"Secondary Storage Vm up (zone " + dc.getName() + ")"
|
"Secondary Storage Vm up (zone " + dc.getName() + ")"
|
||||||
@ -89,7 +89,7 @@ public class SecondaryStorageVmAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_SSVM,
|
AlertManager.ALERT_TYPE_SSVM,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
secStorageVm.getPodId(),
|
secStorageVm.getPodIdToDeployIn(),
|
||||||
"Secondary Storage Vm down in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
|
"Secondary Storage Vm down in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
|
||||||
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
|
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
|
||||||
"Secondary Storage Vm down (zone " + dc.getName() + ")"
|
"Secondary Storage Vm down (zone " + dc.getName() + ")"
|
||||||
@ -105,7 +105,7 @@ public class SecondaryStorageVmAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_SSVM,
|
AlertManager.ALERT_TYPE_SSVM,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
secStorageVm.getPodId(),
|
secStorageVm.getPodIdToDeployIn(),
|
||||||
"Secondary Storage Vm rebooted in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
|
"Secondary Storage Vm rebooted in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
|
||||||
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
|
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
|
||||||
"Secondary Storage Vm rebooted (zone " + dc.getName() + ")"
|
"Secondary Storage Vm rebooted (zone " + dc.getName() + ")"
|
||||||
@ -121,7 +121,7 @@ public class SecondaryStorageVmAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_SSVM,
|
AlertManager.ALERT_TYPE_SSVM,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
secStorageVm.getPodId(),
|
secStorageVm.getPodIdToDeployIn(),
|
||||||
"Secondary Storage Vm creation failure. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
|
"Secondary Storage Vm creation failure. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
|
||||||
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())
|
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())
|
||||||
+ ", error details: " + args.getMessage(),
|
+ ", error details: " + args.getMessage(),
|
||||||
@ -138,7 +138,7 @@ public class SecondaryStorageVmAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_SSVM,
|
AlertManager.ALERT_TYPE_SSVM,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
secStorageVm.getPodId(),
|
secStorageVm.getPodIdToDeployIn(),
|
||||||
"Secondary Storage Vm startup failure. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
|
"Secondary Storage Vm startup failure. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
|
||||||
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())
|
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())
|
||||||
+ ", error details: " + args.getMessage(),
|
+ ", error details: " + args.getMessage(),
|
||||||
@ -155,7 +155,7 @@ public class SecondaryStorageVmAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_SSVM,
|
AlertManager.ALERT_TYPE_SSVM,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
secStorageVm.getPodId(),
|
secStorageVm.getPodIdToDeployIn(),
|
||||||
"Failed to open secondary storage vm firewall port. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName()
|
"Failed to open secondary storage vm firewall port. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName()
|
||||||
+ ", public IP: " + secStorageVm.getPublicIpAddress()
|
+ ", public IP: " + secStorageVm.getPublicIpAddress()
|
||||||
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
|
+ ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
|
||||||
@ -172,7 +172,7 @@ public class SecondaryStorageVmAlertAdapter implements AlertAdapter {
|
|||||||
_alertMgr.sendAlert(
|
_alertMgr.sendAlert(
|
||||||
AlertManager.ALERT_TYPE_STORAGE_MISC,
|
AlertManager.ALERT_TYPE_STORAGE_MISC,
|
||||||
args.getZoneId(),
|
args.getZoneId(),
|
||||||
secStorageVm.getPodId(),
|
secStorageVm.getPodIdToDeployIn(),
|
||||||
"Secondary Storage Vm storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(),
|
"Secondary Storage Vm storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(),
|
||||||
"Secondary Storage Vm alert (zone " + dc.getName() + ")"
|
"Secondary Storage Vm alert (zone " + dc.getName() + ")"
|
||||||
);
|
);
|
||||||
|
|||||||
@ -478,18 +478,13 @@ public class ApiDBUtils {
|
|||||||
return _volumeDao.getHypervisorType(volumeId);
|
return _volumeDao.getHypervisorType(volumeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<VMTemplateHostVO> listTemplateHostBy(long templateId, Long zoneId) {
|
public static List<VMTemplateHostVO> listTemplateHostBy(long templateId, Long zoneId, boolean readyOnly) {
|
||||||
if (zoneId != null) {
|
if (zoneId != null) {
|
||||||
VMTemplateVO vmTemplate = findTemplateById(templateId);
|
VMTemplateVO vmTemplate = findTemplateById(templateId);
|
||||||
if (vmTemplate.getHypervisorType() == HypervisorType.BareMetal) {
|
if (vmTemplate.getHypervisorType() == HypervisorType.BareMetal) {
|
||||||
return _templateHostDao.listByTemplateId(templateId);
|
return _templateHostDao.listByTemplateId(templateId);
|
||||||
} else {
|
} else {
|
||||||
HostVO secondaryStorageHost = _storageMgr.getSecondaryStorageHost(zoneId);
|
return _templateHostDao.listByZoneTemplate(zoneId, templateId, readyOnly);
|
||||||
if (secondaryStorageHost == null) {
|
|
||||||
return new ArrayList<VMTemplateHostVO>();
|
|
||||||
} else {
|
|
||||||
return _templateHostDao.listByHostTemplate(secondaryStorageHost.getId(), templateId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return _templateHostDao.listByOnlyTemplateId(templateId);
|
return _templateHostDao.listByOnlyTemplateId(templateId);
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.cloud.api;
|
package com.cloud.api;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -219,7 +220,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
boolean accountIsAdmin = (account.getType() == Account.ACCOUNT_TYPE_ADMIN);
|
boolean accountIsAdmin = (account.getType() == Account.ACCOUNT_TYPE_ADMIN);
|
||||||
AccountResponse accountResponse = new AccountResponse();
|
AccountResponse accountResponse = new AccountResponse();
|
||||||
accountResponse.setId(account.getId());
|
accountResponse.setId(account.getId());
|
||||||
accountResponse.setName(account.getAccountName());
|
accountResponse.setName(encodeParam(account.getAccountName()));
|
||||||
accountResponse.setAccountType(account.getType());
|
accountResponse.setAccountType(account.getType());
|
||||||
accountResponse.setDomainId(account.getDomainId());
|
accountResponse.setDomainId(account.getDomainId());
|
||||||
accountResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
|
accountResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
|
||||||
@ -316,20 +317,20 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
List<UserResponse> userResponseList = new ArrayList<UserResponse>();
|
List<UserResponse> userResponseList = new ArrayList<UserResponse>();
|
||||||
for (UserVO user : usersForAccount) {
|
for (UserVO user : usersForAccount) {
|
||||||
UserResponse userResponse = new UserResponse();
|
UserResponse userResponse = new UserResponse();
|
||||||
userResponse.setAccountName(account.getAccountName());
|
userResponse.setAccountName(encodeParam(account.getAccountName()));
|
||||||
userResponse.setAccountType(account.getType());
|
userResponse.setAccountType(account.getType());
|
||||||
userResponse.setApiKey(user.getApiKey());
|
userResponse.setApiKey(user.getApiKey());
|
||||||
userResponse.setCreated(user.getCreated());
|
userResponse.setCreated(user.getCreated());
|
||||||
userResponse.setDomainId(account.getDomainId());
|
userResponse.setDomainId(account.getDomainId());
|
||||||
userResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
|
userResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
|
||||||
userResponse.setEmail(user.getEmail());
|
userResponse.setEmail(encodeParam(user.getEmail()));
|
||||||
userResponse.setFirstname(user.getFirstname());
|
userResponse.setFirstname(user.getFirstname());
|
||||||
userResponse.setId(user.getId());
|
userResponse.setId(user.getId());
|
||||||
userResponse.setSecretKey(user.getSecretKey());
|
userResponse.setSecretKey(user.getSecretKey());
|
||||||
userResponse.setLastname(user.getLastname());
|
userResponse.setLastname(user.getLastname());
|
||||||
userResponse.setState(user.getState().toString());
|
userResponse.setState(user.getState().toString());
|
||||||
userResponse.setTimezone(user.getTimezone());
|
userResponse.setTimezone(user.getTimezone());
|
||||||
userResponse.setUsername(user.getUsername());
|
userResponse.setUsername(encodeParam(user.getUsername()));
|
||||||
|
|
||||||
userResponseList.add(userResponse);
|
userResponseList.add(userResponse);
|
||||||
}
|
}
|
||||||
@ -1058,9 +1059,9 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Data Center Info
|
// Data Center Info
|
||||||
DataCenter zone = dataCenters.get(userVm.getDataCenterId());
|
DataCenter zone = dataCenters.get(userVm.getDataCenterIdToDeployIn());
|
||||||
if (zone == null) {
|
if (zone == null) {
|
||||||
zone = ApiDBUtils.findZoneById(userVm.getDataCenterId());
|
zone = ApiDBUtils.findZoneById(userVm.getDataCenterIdToDeployIn());
|
||||||
dataCenters.put(zone.getId(), zone);
|
dataCenters.put(zone.getId(), zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1223,11 +1224,13 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DomainRouterResponse createDomainRouterResponse(VirtualRouter router) {
|
public DomainRouterResponse createDomainRouterResponse(VirtualRouter router) {
|
||||||
|
Map<Long, ServiceOffering> serviceOfferings = new HashMap<Long, ServiceOffering>();
|
||||||
|
|
||||||
DomainRouterResponse routerResponse = new DomainRouterResponse();
|
DomainRouterResponse routerResponse = new DomainRouterResponse();
|
||||||
routerResponse.setId(router.getId());
|
routerResponse.setId(router.getId());
|
||||||
routerResponse.setZoneId(router.getDataCenterId());
|
routerResponse.setZoneId(router.getDataCenterIdToDeployIn());
|
||||||
routerResponse.setName(router.getHostName());
|
routerResponse.setName(router.getHostName());
|
||||||
routerResponse.setPodId(router.getPodId());
|
routerResponse.setPodId(router.getPodIdToDeployIn());
|
||||||
routerResponse.setTemplateId(router.getTemplateId());
|
routerResponse.setTemplateId(router.getTemplateId());
|
||||||
routerResponse.setCreated(router.getCreated());
|
routerResponse.setCreated(router.getCreated());
|
||||||
routerResponse.setState(router.getState());
|
routerResponse.setState(router.getState());
|
||||||
@ -1236,7 +1239,17 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
routerResponse.setHostId(router.getHostId());
|
routerResponse.setHostId(router.getHostId());
|
||||||
routerResponse.setHostName(ApiDBUtils.findHostById(router.getHostId()).getName());
|
routerResponse.setHostName(ApiDBUtils.findHostById(router.getHostId()).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Service Offering Info
|
||||||
|
ServiceOffering offering = serviceOfferings.get(router.getServiceOfferingId());
|
||||||
|
|
||||||
|
if (offering == null) {
|
||||||
|
offering = ApiDBUtils.findServiceOfferingById(router.getServiceOfferingId());
|
||||||
|
serviceOfferings.put(offering.getId(), offering);
|
||||||
|
}
|
||||||
|
routerResponse.setServiceOfferingId(offering.getId());
|
||||||
|
routerResponse.setServiceOfferingName(offering.getName());
|
||||||
|
|
||||||
Account accountTemp = ApiDBUtils.findAccountById(router.getAccountId());
|
Account accountTemp = ApiDBUtils.findAccountById(router.getAccountId());
|
||||||
if (accountTemp != null) {
|
if (accountTemp != null) {
|
||||||
routerResponse.setAccountName(accountTemp.getAccountName());
|
routerResponse.setAccountName(accountTemp.getAccountName());
|
||||||
@ -1268,7 +1281,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DataCenter zone = ApiDBUtils.findZoneById(router.getDataCenterId());
|
DataCenter zone = ApiDBUtils.findZoneById(router.getDataCenterIdToDeployIn());
|
||||||
if (zone != null) {
|
if (zone != null) {
|
||||||
routerResponse.setZoneName(zone.getName());
|
routerResponse.setZoneName(zone.getName());
|
||||||
routerResponse.setDns1(zone.getDns1());
|
routerResponse.setDns1(zone.getDns1());
|
||||||
@ -1287,10 +1300,10 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
|
|
||||||
vmResponse.setId(vm.getId());
|
vmResponse.setId(vm.getId());
|
||||||
vmResponse.setSystemVmType(vm.getType().toString().toLowerCase());
|
vmResponse.setSystemVmType(vm.getType().toString().toLowerCase());
|
||||||
vmResponse.setZoneId(vm.getDataCenterId());
|
vmResponse.setZoneId(vm.getDataCenterIdToDeployIn());
|
||||||
|
|
||||||
vmResponse.setName(vm.getHostName());
|
vmResponse.setName(vm.getHostName());
|
||||||
vmResponse.setPodId(vm.getPodId());
|
vmResponse.setPodId(vm.getPodIdToDeployIn());
|
||||||
vmResponse.setTemplateId(vm.getTemplateId());
|
vmResponse.setTemplateId(vm.getTemplateId());
|
||||||
vmResponse.setCreated(vm.getCreated());
|
vmResponse.setCreated(vm.getCreated());
|
||||||
|
|
||||||
@ -1309,7 +1322,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
vmResponse.setActiveViewerSessions(proxy.getActiveSession());
|
vmResponse.setActiveViewerSessions(proxy.getActiveSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
DataCenter zone = ApiDBUtils.findZoneById(vm.getDataCenterId());
|
DataCenter zone = ApiDBUtils.findZoneById(vm.getDataCenterIdToDeployIn());
|
||||||
if (zone != null) {
|
if (zone != null) {
|
||||||
vmResponse.setZoneName(zone.getName());
|
vmResponse.setZoneName(zone.getName());
|
||||||
vmResponse.setDns1(zone.getDns1());
|
vmResponse.setDns1(zone.getDns1());
|
||||||
@ -1328,6 +1341,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
vmResponse.setPublicIp(singleNicProfile.getIp4Address());
|
vmResponse.setPublicIp(singleNicProfile.getIp4Address());
|
||||||
vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
|
vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
|
||||||
vmResponse.setPublicNetmask(singleNicProfile.getNetmask());
|
vmResponse.setPublicNetmask(singleNicProfile.getNetmask());
|
||||||
|
vmResponse.setGateway(singleNicProfile.getGateway());
|
||||||
} else if (network.getTrafficType() == TrafficType.Management) {
|
} else if (network.getTrafficType() == TrafficType.Management) {
|
||||||
vmResponse.setPrivateIp(singleNicProfile.getIp4Address());
|
vmResponse.setPrivateIp(singleNicProfile.getIp4Address());
|
||||||
vmResponse.setPrivateMacAddress(singleNicProfile.getMacAddress());
|
vmResponse.setPrivateMacAddress(singleNicProfile.getMacAddress());
|
||||||
@ -1437,12 +1451,21 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTemplateResponse(List<TemplateResponse> responses, Pair<Long, Long> templateZonePair, boolean isAdmin, Account account) {
|
public void createTemplateResponse(List<TemplateResponse> responses, Pair<Long, Long> templateZonePair, boolean isAdmin, Account account, boolean readyOnly) {
|
||||||
List<VMTemplateHostVO> templateHostRefsForTemplate = ApiDBUtils.listTemplateHostBy(templateZonePair.first(), templateZonePair.second());
|
List<VMTemplateHostVO> templateHostRefsForTemplate = ApiDBUtils.listTemplateHostBy(templateZonePair.first(), templateZonePair.second(), readyOnly);
|
||||||
VMTemplateVO template = ApiDBUtils.findTemplateById(templateZonePair.first());
|
VMTemplateVO template = ApiDBUtils.findTemplateById(templateZonePair.first());
|
||||||
|
|
||||||
for (VMTemplateHostVO templateHostRef : templateHostRefsForTemplate) {
|
for (VMTemplateHostVO templateHostRef : templateHostRefsForTemplate) {
|
||||||
|
if (readyOnly) {
|
||||||
|
if (templateHostRef.getDownloadState() != Status.DOWNLOADED) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (TemplateResponse res : responses) {
|
||||||
|
if (res.getId() == templateHostRef.getTemplateId()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
TemplateResponse templateResponse = new TemplateResponse();
|
TemplateResponse templateResponse = new TemplateResponse();
|
||||||
templateResponse.setId(template.getId());
|
templateResponse.setId(template.getId());
|
||||||
templateResponse.setName(template.getName());
|
templateResponse.setName(template.getName());
|
||||||
@ -1479,8 +1502,11 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HostVO host = ApiDBUtils.findHostById(templateHostRef.getHostId());
|
HostVO host = ApiDBUtils.findHostById(templateHostRef.getHostId());
|
||||||
|
templateResponse.setHostId(host.getId());
|
||||||
|
templateResponse.setHostName(host.getName());
|
||||||
|
|
||||||
DataCenterVO datacenter = ApiDBUtils.findZoneById(host.getDataCenterId());
|
DataCenterVO datacenter = ApiDBUtils.findZoneById(host.getDataCenterId());
|
||||||
|
|
||||||
// Add the zone ID
|
// Add the zone ID
|
||||||
templateResponse.setZoneId(host.getDataCenterId());
|
templateResponse.setZoneId(host.getDataCenterId());
|
||||||
templateResponse.setZoneName(datacenter.getName());
|
templateResponse.setZoneName(datacenter.getName());
|
||||||
@ -1974,7 +2000,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListResponse<TemplateResponse> createIsoResponse(Set<Pair<Long, Long>> isoZonePairSet, boolean isAdmin, Account account, Boolean isBootable) {
|
public ListResponse<TemplateResponse> createIsoResponse(Set<Pair<Long, Long>> isoZonePairSet, boolean isAdmin, Account account, Boolean isBootable, boolean readyOnly) {
|
||||||
|
|
||||||
ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
|
ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
|
||||||
List<TemplateResponse> isoResponses = new ArrayList<TemplateResponse>();
|
List<TemplateResponse> isoResponses = new ArrayList<TemplateResponse>();
|
||||||
@ -2010,7 +2036,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<VMTemplateHostVO> isoHosts = ApiDBUtils.listTemplateHostBy(iso.getId(), isoZonePair.second());
|
List<VMTemplateHostVO> isoHosts = ApiDBUtils.listTemplateHostBy(iso.getId(), isoZonePair.second(), readyOnly);
|
||||||
for (VMTemplateHostVO isoHost : isoHosts) {
|
for (VMTemplateHostVO isoHost : isoHosts) {
|
||||||
TemplateResponse isoResponse = new TemplateResponse();
|
TemplateResponse isoResponse = new TemplateResponse();
|
||||||
isoResponse.setId(iso.getId());
|
isoResponse.setId(iso.getId());
|
||||||
@ -2501,4 +2527,13 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
return sg.getId();
|
return sg.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String encodeParam(String value) {
|
||||||
|
try {
|
||||||
|
return URLEncoder.encode(value, "UTF-8").replaceAll("\\+", "%20");
|
||||||
|
} catch (Exception e) {
|
||||||
|
s_logger.warn("Unable to encode: " + value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -136,7 +136,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
s_logger.debug("submit async job-" + job.getId() + ", details: " + job.toString());
|
s_logger.debug("submit async job-" + job.getId() + ", details: " + job.toString());
|
||||||
}
|
}
|
||||||
return job.getId();
|
return job.getId();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
String errMsg = "Unable to schedule async job for command " + job.getCmd() + ", unexpected exception.";
|
String errMsg = "Unable to schedule async job for command " + job.getCmd() + ", unexpected exception.";
|
||||||
s_logger.warn(errMsg, e);
|
s_logger.warn(errMsg, e);
|
||||||
@ -146,18 +146,20 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public void completeAsyncJob(long jobId, int jobStatus, int resultCode, Object resultObject) {
|
public void completeAsyncJob(long jobId, int jobStatus, int resultCode, Object resultObject) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Complete async job-" + jobId + ", jobStatus: " + jobStatus +
|
s_logger.debug("Complete async job-" + jobId + ", jobStatus: " + jobStatus +
|
||||||
", resultCode: " + resultCode + ", result: " + resultObject);
|
", resultCode: " + resultCode + ", result: " + resultObject);
|
||||||
|
}
|
||||||
|
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
AsyncJobVO job = _jobDao.findById(jobId);
|
AsyncJobVO job = _jobDao.findById(jobId);
|
||||||
if(job == null) {
|
if(job == null) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("job-" + jobId + " no longer exists, we just log completion info here. " + jobStatus +
|
s_logger.debug("job-" + jobId + " no longer exists, we just log completion info here. " + jobStatus +
|
||||||
", resultCode: " + resultCode + ", result: " + resultObject);
|
", resultCode: " + resultCode + ", result: " + resultObject);
|
||||||
|
}
|
||||||
|
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
return;
|
return;
|
||||||
@ -186,25 +188,28 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public void updateAsyncJobStatus(long jobId, int processStatus, Object resultObject) {
|
public void updateAsyncJobStatus(long jobId, int processStatus, Object resultObject) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Update async-job progress, job-" + jobId + ", processStatus: " + processStatus +
|
s_logger.debug("Update async-job progress, job-" + jobId + ", processStatus: " + processStatus +
|
||||||
", result: " + resultObject);
|
", result: " + resultObject);
|
||||||
|
}
|
||||||
|
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
AsyncJobVO job = _jobDao.findById(jobId);
|
AsyncJobVO job = _jobDao.findById(jobId);
|
||||||
if(job == null) {
|
if(job == null) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("job-" + jobId + " no longer exists, we just log progress info here. progress status: " + processStatus);
|
s_logger.debug("job-" + jobId + " no longer exists, we just log progress info here. progress status: " + processStatus);
|
||||||
|
}
|
||||||
|
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
job.setProcessStatus(processStatus);
|
job.setProcessStatus(processStatus);
|
||||||
if(resultObject != null)
|
if(resultObject != null) {
|
||||||
job.setResult(ApiSerializerHelper.toSerializedStringOld(resultObject));
|
job.setResult(ApiSerializerHelper.toSerializedStringOld(resultObject));
|
||||||
|
}
|
||||||
job.setLastUpdated(DateUtil.currentGMTTime());
|
job.setLastUpdated(DateUtil.currentGMTTime());
|
||||||
_jobDao.update(jobId, job);
|
_jobDao.update(jobId, job);
|
||||||
txt.commit();
|
txt.commit();
|
||||||
@ -216,9 +221,10 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public void updateAsyncJobAttachment(long jobId, String instanceType, Long instanceId) {
|
public void updateAsyncJobAttachment(long jobId, String instanceType, Long instanceId) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Update async-job attachment, job-" + jobId + ", instanceType: " + instanceType +
|
s_logger.debug("Update async-job attachment, job-" + jobId + ", instanceType: " + instanceType +
|
||||||
", instanceId: " + instanceId);
|
", instanceId: " + instanceId);
|
||||||
|
}
|
||||||
|
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
@ -248,19 +254,21 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Sync job-" + job.getId() + " execution on object " + syncObjType + "." + syncObjId);
|
s_logger.debug("Sync job-" + job.getId() + " execution on object " + syncObjType + "." + syncObjId);
|
||||||
|
}
|
||||||
|
|
||||||
SyncQueueVO queue = null;
|
SyncQueueVO queue = null;
|
||||||
|
|
||||||
// to deal with temporary DB exceptions like DB deadlock/Lock-wait time out cased rollbacks
|
// to deal with temporary DB exceptions like DB deadlock/Lock-wait time out cased rollbacks
|
||||||
// we retry five times until we throw an exception
|
// we retry five times until we throw an exception
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
for(int i = 0; i < 5; i++) {
|
for(int i = 0; i < 5; i++) {
|
||||||
queue = _queueMgr.queue(syncObjType, syncObjId, "AsyncJob", job.getId());
|
queue = _queueMgr.queue(syncObjType, syncObjId, "AsyncJob", job.getId());
|
||||||
if(queue != null)
|
if(queue != null) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000 + random.nextInt(5000));
|
Thread.sleep(1000 + random.nextInt(5000));
|
||||||
@ -302,8 +310,9 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public AsyncJobResult queryAsyncJobResult(long jobId) {
|
public AsyncJobResult queryAsyncJobResult(long jobId) {
|
||||||
if(s_logger.isTraceEnabled())
|
if(s_logger.isTraceEnabled()) {
|
||||||
s_logger.trace("Query async-job status, job-" + jobId);
|
s_logger.trace("Query async-job status, job-" + jobId);
|
||||||
|
}
|
||||||
|
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
AsyncJobResult jobResult = new AsyncJobResult(jobId);
|
AsyncJobResult jobResult = new AsyncJobResult(jobId);
|
||||||
@ -321,15 +330,17 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
if(job.getStatus() == AsyncJobResult.STATUS_SUCCEEDED ||
|
if(job.getStatus() == AsyncJobResult.STATUS_SUCCEEDED ||
|
||||||
job.getStatus() == AsyncJobResult.STATUS_FAILED) {
|
job.getStatus() == AsyncJobResult.STATUS_FAILED) {
|
||||||
|
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Async job-" + jobId + " completed");
|
s_logger.debug("Async job-" + jobId + " completed");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
job.setLastPolled(DateUtil.currentGMTTime());
|
job.setLastPolled(DateUtil.currentGMTTime());
|
||||||
_jobDao.update(jobId, job);
|
_jobDao.update(jobId, job);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Async job-" + jobId + " does not exist, invalid job id?");
|
s_logger.debug("Async job-" + jobId + " does not exist, invalid job id?");
|
||||||
|
}
|
||||||
|
|
||||||
jobResult.setJobStatus(AsyncJobResult.STATUS_FAILED);
|
jobResult.setJobStatus(AsyncJobResult.STATUS_FAILED);
|
||||||
jobResult.setResult("job-" + jobId + " does not exist");
|
jobResult.setResult("job-" + jobId + " does not exist");
|
||||||
@ -343,8 +354,9 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
txt.rollback();
|
txt.rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s_logger.isTraceEnabled())
|
if(s_logger.isTraceEnabled()) {
|
||||||
s_logger.trace("Job status: " + jobResult.toString());
|
s_logger.trace("Job status: " + jobResult.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return jobResult;
|
return jobResult;
|
||||||
}
|
}
|
||||||
@ -366,114 +378,122 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
return new Runnable() {
|
return new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long jobId = 0;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JmxUtil.registerMBean("AsyncJobManager", "Active Job " + job.getId(), new AsyncJobMBeanImpl(job));
|
long jobId = 0;
|
||||||
} catch(Exception e) {
|
|
||||||
s_logger.warn("Unable to register active job " + job.getId() + " to JMX minotoring due to exception " + ExceptionUtil.toString(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseAsyncCmd cmdObj = null;
|
|
||||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
|
||||||
try {
|
|
||||||
jobId = job.getId();
|
|
||||||
NDC.push("job-" + jobId);
|
|
||||||
|
|
||||||
if(s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Executing " + job.getCmd() + " for job-" + jobId);
|
|
||||||
}
|
|
||||||
|
|
||||||
Class<?> cmdClass = Class.forName(job.getCmd());
|
|
||||||
cmdObj = (BaseAsyncCmd)cmdClass.newInstance();
|
|
||||||
cmdObj.setJob(job);
|
|
||||||
|
|
||||||
Type mapType = new TypeToken<Map<String, String>>() {}.getType();
|
|
||||||
Gson gson = ApiGsonHelper.getBuilder().create();
|
|
||||||
Map<String, String> params = gson.fromJson(job.getCmdInfo(), mapType);
|
|
||||||
|
|
||||||
// whenever we deserialize, the UserContext needs to be updated
|
|
||||||
String userIdStr = params.get("ctxUserId");
|
|
||||||
String acctIdStr = params.get("ctxAccountId");
|
|
||||||
Long userId = null;
|
|
||||||
Account accountObject = null;
|
|
||||||
|
|
||||||
if (userIdStr != null) {
|
|
||||||
userId = Long.parseLong(userIdStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acctIdStr != null) {
|
|
||||||
accountObject = _accountDao.findById(Long.parseLong(acctIdStr));
|
|
||||||
}
|
|
||||||
|
|
||||||
UserContext.registerContext(userId, accountObject, null, false);
|
|
||||||
try {
|
|
||||||
// dispatch could ultimately queue the job
|
|
||||||
_dispatcher.dispatch(cmdObj, params);
|
|
||||||
|
|
||||||
// serialize this to the async job table
|
|
||||||
completeAsyncJob(jobId, AsyncJobResult.STATUS_SUCCEEDED, 0, cmdObj.getResponseObject());
|
|
||||||
} finally {
|
|
||||||
UserContext.unregisterContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
// commands might need to be queued as part of synchronization here, so they just have to be re-dispatched from the queue mechanism...
|
|
||||||
if (job.getSyncSource() != null) {
|
|
||||||
_queueMgr.purgeItem(job.getSyncSource().getId());
|
|
||||||
checkQueue(job.getSyncSource().getQueueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled())
|
|
||||||
s_logger.debug("Done executing " + job.getCmd() + " for job-" + jobId);
|
|
||||||
|
|
||||||
} catch(Throwable e) {
|
|
||||||
if (e instanceof AsyncCommandQueued) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("job " + job.getCmd() + " for job-" + jobId + " was queued, processing the queue.");
|
|
||||||
}
|
|
||||||
checkQueue(((AsyncCommandQueued)e).getQueue().getId());
|
|
||||||
} else {
|
|
||||||
String errorMsg = null;
|
|
||||||
int errorCode = BaseCmd.INTERNAL_ERROR;
|
|
||||||
if (!(e instanceof ServerApiException)) {
|
|
||||||
s_logger.error("Unexpected exception while executing " + job.getCmd(), e);
|
|
||||||
errorMsg = e.getMessage();
|
|
||||||
} else {
|
|
||||||
ServerApiException sApiEx = (ServerApiException)e;
|
|
||||||
errorMsg = sApiEx.getDescription();
|
|
||||||
errorCode = sApiEx.getErrorCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
ExceptionResponse response = new ExceptionResponse();
|
|
||||||
response.setErrorCode(errorCode);
|
|
||||||
response.setErrorText(errorMsg);
|
|
||||||
response.setResponseName((cmdObj == null) ? "unknowncommandresponse" : cmdObj.getCommandName());
|
|
||||||
|
|
||||||
// FIXME: setting resultCode to BaseCmd.INTERNAL_ERROR is not right, usually executors have their exception handling
|
|
||||||
// and we need to preserve that as much as possible here
|
|
||||||
completeAsyncJob(jobId, AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, response);
|
|
||||||
|
|
||||||
// need to clean up any queue that happened as part of the dispatching and move on to the next item in the queue
|
|
||||||
try {
|
|
||||||
if (job.getSyncSource() != null) {
|
|
||||||
_queueMgr.purgeItem(job.getSyncSource().getId());
|
|
||||||
checkQueue(job.getSyncSource().getQueueId());
|
|
||||||
}
|
|
||||||
} catch(Throwable ex) {
|
|
||||||
s_logger.fatal("Exception on exception, log it for record", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JmxUtil.unregisterMBean("AsyncJobManager", "Active Job " + job.getId());
|
JmxUtil.registerMBean("AsyncJobManager", "Active Job " + job.getId(), new AsyncJobMBeanImpl(job));
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.warn("Unable to unregister active job " + job.getId() + " from JMX minotoring");
|
s_logger.warn("Unable to register active job " + job.getId() + " to JMX minotoring due to exception " + ExceptionUtil.toString(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseAsyncCmd cmdObj = null;
|
||||||
|
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||||
|
try {
|
||||||
|
jobId = job.getId();
|
||||||
|
NDC.push("job-" + jobId);
|
||||||
|
|
||||||
|
if(s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug("Executing " + job.getCmd() + " for job-" + jobId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Class<?> cmdClass = Class.forName(job.getCmd());
|
||||||
|
cmdObj = (BaseAsyncCmd)cmdClass.newInstance();
|
||||||
|
cmdObj.setJob(job);
|
||||||
|
|
||||||
|
Type mapType = new TypeToken<Map<String, String>>() {}.getType();
|
||||||
|
Gson gson = ApiGsonHelper.getBuilder().create();
|
||||||
|
Map<String, String> params = gson.fromJson(job.getCmdInfo(), mapType);
|
||||||
|
|
||||||
|
// whenever we deserialize, the UserContext needs to be updated
|
||||||
|
String userIdStr = params.get("ctxUserId");
|
||||||
|
String acctIdStr = params.get("ctxAccountId");
|
||||||
|
Long userId = null;
|
||||||
|
Account accountObject = null;
|
||||||
|
|
||||||
|
if (userIdStr != null) {
|
||||||
|
userId = Long.parseLong(userIdStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (acctIdStr != null) {
|
||||||
|
accountObject = _accountDao.findById(Long.parseLong(acctIdStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
UserContext.registerContext(userId, accountObject, null, false);
|
||||||
|
try {
|
||||||
|
// dispatch could ultimately queue the job
|
||||||
|
_dispatcher.dispatch(cmdObj, params);
|
||||||
|
|
||||||
|
// serialize this to the async job table
|
||||||
|
completeAsyncJob(jobId, AsyncJobResult.STATUS_SUCCEEDED, 0, cmdObj.getResponseObject());
|
||||||
|
} finally {
|
||||||
|
UserContext.unregisterContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
// commands might need to be queued as part of synchronization here, so they just have to be re-dispatched from the queue mechanism...
|
||||||
|
if (job.getSyncSource() != null) {
|
||||||
|
_queueMgr.purgeItem(job.getSyncSource().getId());
|
||||||
|
checkQueue(job.getSyncSource().getQueueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug("Done executing " + job.getCmd() + " for job-" + jobId);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Throwable e) {
|
||||||
|
if (e instanceof AsyncCommandQueued) {
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug("job " + job.getCmd() + " for job-" + jobId + " was queued, processing the queue.");
|
||||||
|
}
|
||||||
|
checkQueue(((AsyncCommandQueued)e).getQueue().getId());
|
||||||
|
} else {
|
||||||
|
String errorMsg = null;
|
||||||
|
int errorCode = BaseCmd.INTERNAL_ERROR;
|
||||||
|
if (!(e instanceof ServerApiException)) {
|
||||||
|
s_logger.error("Unexpected exception while executing " + job.getCmd(), e);
|
||||||
|
errorMsg = e.getMessage();
|
||||||
|
} else {
|
||||||
|
ServerApiException sApiEx = (ServerApiException)e;
|
||||||
|
errorMsg = sApiEx.getDescription();
|
||||||
|
errorCode = sApiEx.getErrorCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
ExceptionResponse response = new ExceptionResponse();
|
||||||
|
response.setErrorCode(errorCode);
|
||||||
|
response.setErrorText(errorMsg);
|
||||||
|
response.setResponseName((cmdObj == null) ? "unknowncommandresponse" : cmdObj.getCommandName());
|
||||||
|
|
||||||
|
// FIXME: setting resultCode to BaseCmd.INTERNAL_ERROR is not right, usually executors have their exception handling
|
||||||
|
// and we need to preserve that as much as possible here
|
||||||
|
completeAsyncJob(jobId, AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, response);
|
||||||
|
|
||||||
|
// need to clean up any queue that happened as part of the dispatching and move on to the next item in the queue
|
||||||
|
try {
|
||||||
|
if (job.getSyncSource() != null) {
|
||||||
|
_queueMgr.purgeItem(job.getSyncSource().getId());
|
||||||
|
checkQueue(job.getSyncSource().getQueueId());
|
||||||
|
}
|
||||||
|
} catch(Throwable ex) {
|
||||||
|
s_logger.fatal("Exception on exception, log it for record", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
try {
|
||||||
|
JmxUtil.unregisterMBean("AsyncJobManager", "Active Job " + job.getId());
|
||||||
|
} catch(Exception e) {
|
||||||
|
s_logger.warn("Unable to unregister active job " + job.getId() + " from JMX minotoring");
|
||||||
|
}
|
||||||
|
|
||||||
|
StackMaid.current().exitCleanup();
|
||||||
|
txn.close();
|
||||||
|
NDC.pop();
|
||||||
|
}
|
||||||
|
} catch (Throwable th) {
|
||||||
|
try {
|
||||||
|
s_logger.error("Caught: " + th);
|
||||||
|
} catch (Throwable th2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
txn.close();
|
|
||||||
NDC.pop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -493,8 +513,9 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
_jobDao.update(job.getId(), job);
|
_jobDao.update(job.getId(), job);
|
||||||
scheduleExecution(job);
|
scheduleExecution(job);
|
||||||
} else {
|
} else {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Unable to find related job for queue item: " + item.toString());
|
s_logger.debug("Unable to find related job for queue item: " + item.toString());
|
||||||
|
}
|
||||||
|
|
||||||
_queueMgr.purgeItem(item.getId());
|
_queueMgr.purgeItem(item.getId());
|
||||||
}
|
}
|
||||||
@ -503,10 +524,11 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
@Override
|
@Override
|
||||||
public void releaseSyncSource(AsyncJobExecutor executor) {
|
public void releaseSyncSource(AsyncJobExecutor executor) {
|
||||||
if(executor.getSyncSource() != null) {
|
if(executor.getSyncSource() != null) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Release sync source for job-" + executor.getJob().getId() + " sync source: "
|
s_logger.debug("Release sync source for job-" + executor.getJob().getId() + " sync source: "
|
||||||
+ executor.getSyncSource().getContentType() + "-"
|
+ executor.getSyncSource().getContentType() + "-"
|
||||||
+ executor.getSyncSource().getContentId());
|
+ executor.getSyncSource().getContentId());
|
||||||
|
}
|
||||||
|
|
||||||
_queueMgr.purgeItem(executor.getSyncSource().getId());
|
_queueMgr.purgeItem(executor.getSyncSource().getId());
|
||||||
checkQueue(executor.getSyncSource().getQueueId());
|
checkQueue(executor.getSyncSource().getQueueId());
|
||||||
@ -518,8 +540,9 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
try {
|
try {
|
||||||
SyncQueueItemVO item = _queueMgr.dequeueFromOne(queueId, getMsid());
|
SyncQueueItemVO item = _queueMgr.dequeueFromOne(queueId, getMsid());
|
||||||
if(item != null) {
|
if(item != null) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Executing sync queue item: " + item.toString());
|
s_logger.debug("Executing sync queue item: " + item.toString());
|
||||||
|
}
|
||||||
|
|
||||||
executeQueueItem(item, false);
|
executeQueueItem(item, false);
|
||||||
} else {
|
} else {
|
||||||
@ -540,8 +563,9 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
List<SyncQueueItemVO> l = _queueMgr.dequeueFromAny(getMsid(), MAX_ONETIME_SCHEDULE_SIZE);
|
List<SyncQueueItemVO> l = _queueMgr.dequeueFromAny(getMsid(), MAX_ONETIME_SCHEDULE_SIZE);
|
||||||
if(l != null && l.size() > 0) {
|
if(l != null && l.size() > 0) {
|
||||||
for(SyncQueueItemVO item: l) {
|
for(SyncQueueItemVO item: l) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Execute sync-queue item: " + item.toString());
|
s_logger.debug("Execute sync-queue item: " + item.toString());
|
||||||
|
}
|
||||||
executeQueueItem(item, false);
|
executeQueueItem(item, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -592,8 +616,9 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
List<SyncQueueItemVO> blockItems = _queueMgr.getBlockedQueueItems(_jobCancelThresholdSeconds*1000, false);
|
List<SyncQueueItemVO> blockItems = _queueMgr.getBlockedQueueItems(_jobCancelThresholdSeconds*1000, false);
|
||||||
if(blockItems != null && blockItems.size() > 0) {
|
if(blockItems != null && blockItems.size() > 0) {
|
||||||
for(SyncQueueItemVO item : blockItems) {
|
for(SyncQueueItemVO item : blockItems) {
|
||||||
if(item.getContentType().equalsIgnoreCase("AsyncJob"))
|
if(item.getContentType().equalsIgnoreCase("AsyncJob")) {
|
||||||
completeAsyncJob(item.getContentId(), 2, 0, getResetResultMessage("Job is cancelled as it has been blocking others for too long"));
|
completeAsyncJob(item.getContentId(), 2, 0, getResetResultMessage("Job is cancelled as it has been blocking others for too long"));
|
||||||
|
}
|
||||||
|
|
||||||
// purge the item and resume queue processing
|
// purge the item and resume queue processing
|
||||||
_queueMgr.purgeItem(item.getId());
|
_queueMgr.purgeItem(item.getId());
|
||||||
@ -611,8 +636,9 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private long getMsid() {
|
private long getMsid() {
|
||||||
if(_clusterMgr != null)
|
if(_clusterMgr != null) {
|
||||||
return _clusterMgr.getManagementNodeId();
|
return _clusterMgr.getManagementNodeId();
|
||||||
|
}
|
||||||
|
|
||||||
return MacAddress.getMacAddress().toLong();
|
return MacAddress.getMacAddress().toLong();
|
||||||
}
|
}
|
||||||
@ -620,14 +646,15 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
private void cleanupPendingJobs(List<SyncQueueItemVO> l) {
|
private void cleanupPendingJobs(List<SyncQueueItemVO> l) {
|
||||||
if(l != null && l.size() > 0) {
|
if(l != null && l.size() > 0) {
|
||||||
for(SyncQueueItemVO item: l) {
|
for(SyncQueueItemVO item: l) {
|
||||||
if(s_logger.isInfoEnabled())
|
if(s_logger.isInfoEnabled()) {
|
||||||
s_logger.info("Discard left-over queue item: " + item.toString());
|
s_logger.info("Discard left-over queue item: " + item.toString());
|
||||||
|
}
|
||||||
|
|
||||||
String contentType = item.getContentType();
|
String contentType = item.getContentType();
|
||||||
if(contentType != null && contentType.equals("AsyncJob")) {
|
if(contentType != null && contentType.equals("AsyncJob")) {
|
||||||
Long jobId = item.getContentId();
|
Long jobId = item.getContentId();
|
||||||
if(jobId != null) {
|
if(jobId != null) {
|
||||||
s_logger.warn("Mark job as failed as its correspoding queue-item has been discarded. job id: " + jobId);
|
s_logger.warn("Mark job as failed as its correspoding queue-item has been discarded. job id: " + jobId);
|
||||||
completeAsyncJob(jobId, AsyncJobResult.STATUS_FAILED, 0, getResetResultMessage("Execution was cancelled because of server shutdown"));
|
completeAsyncJob(jobId, AsyncJobResult.STATUS_FAILED, 0, getResetResultMessage("Execution was cancelled because of server shutdown"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -574,14 +574,11 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
Connection conn = getHeartbeatConnection();
|
Connection conn = getHeartbeatConnection();
|
||||||
_mshostDao.update(conn, _mshostId, getCurrentRunId(), DateUtil.currentGMTTime());
|
_mshostDao.update(conn, _mshostId, getCurrentRunId(), DateUtil.currentGMTTime());
|
||||||
|
|
||||||
// for cluster in Starting state check if there are any agents being transfered
|
|
||||||
if (_state == State.Starting) {
|
if (_state == State.Starting) {
|
||||||
synchronized (stateLock) {
|
synchronized (stateLock) {
|
||||||
if (isClusterReadyToStart()) {
|
_mshostDao.update(conn, _mshostId, getCurrentRunId(), State.Up, DateUtil.currentGMTTime());
|
||||||
_mshostDao.update(conn, _mshostId, getCurrentRunId(), State.Up, DateUtil.currentGMTTime());
|
_state = State.Up;
|
||||||
_state = State.Up;
|
stateLock.notifyAll();
|
||||||
stateLock.notifyAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,45 +615,6 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
s_logger.error("Problem with the cluster heartbeat!", e);
|
s_logger.error("Problem with the cluster heartbeat!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isClusterReadyToStart() {
|
|
||||||
if (!_agentLBEnabled) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
boolean isReady = false;
|
|
||||||
int transferCount = _hostTransferDao.listHostsJoiningCluster(_msId).size();
|
|
||||||
if (transferCount == 0) {
|
|
||||||
//Check how many servers got transfered successfully
|
|
||||||
List<HostTransferMapVO> rebalancedHosts = _hostTransferDao.listBy(_msId, HostTransferState.TransferCompleted);
|
|
||||||
|
|
||||||
if (!rebalancedHosts.isEmpty() && s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug(rebalancedHosts.size() + " hosts joined the cluster " + _msId + " as a result of rebalance process");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for (HostTransferMapVO host : rebalancedHosts) {
|
|
||||||
_hostTransferDao.remove(host.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check how many servers failed to transfer
|
|
||||||
List<HostTransferMapVO> failedToRebalanceHosts = _hostTransferDao.listBy(_msId, HostTransferState.TransferFailed);
|
|
||||||
if (!failedToRebalanceHosts.isEmpty() && s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug(failedToRebalanceHosts.size() + " hosts failed to join the cluster " + _msId + " as a result of rebalance process");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (HostTransferMapVO host : failedToRebalanceHosts) {
|
|
||||||
_hostTransferDao.remove(host.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
s_logger.debug("There are no hosts currently joining cluser msid=" + _msId + ", so management server is ready to start");
|
|
||||||
isReady = true;
|
|
||||||
} else if (s_logger.isDebugEnabled()) {
|
|
||||||
//TODO : change to trace mode later
|
|
||||||
s_logger.debug("There are " + transferCount + " agents currently joinging the cluster " + _msId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return isReady;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,15 +910,15 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
s_logger.info("Management server (host id : " + _mshostId + ") is being started at " + _clusterNodeIP + ":" + _currentServiceAdapter.getServicePort());
|
s_logger.info("Management server (host id : " + _mshostId + ") is being started at " + _clusterNodeIP + ":" + _currentServiceAdapter.getServicePort());
|
||||||
}
|
}
|
||||||
|
|
||||||
// use seperate thread for heartbeat updates
|
// Initiate agent rebalancing
|
||||||
_heartbeatScheduler.scheduleAtFixedRate(getHeartbeatTask(), heartbeatInterval, heartbeatInterval, TimeUnit.MILLISECONDS);
|
|
||||||
_notificationExecutor.submit(getNotificationTask());
|
|
||||||
|
|
||||||
// Do agent rebalancing
|
|
||||||
if (_agentLBEnabled) {
|
if (_agentLBEnabled) {
|
||||||
s_logger.debug("Management server " + _msId + " is asking other peers to rebalance their agents");
|
s_logger.debug("Management server " + _msId + " is asking other peers to rebalance their agents");
|
||||||
_rebalanceService.startRebalanceAgents();
|
_rebalanceService.startRebalanceAgents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// use seperate thread for heartbeat updates
|
||||||
|
_heartbeatScheduler.scheduleAtFixedRate(getHeartbeatTask(), heartbeatInterval, heartbeatInterval, TimeUnit.MILLISECONDS);
|
||||||
|
_notificationExecutor.submit(getNotificationTask());
|
||||||
|
|
||||||
//wait here for heartbeat task to update the host state
|
//wait here for heartbeat task to update the host state
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -26,6 +26,6 @@ import com.cloud.utils.component.Adapter;
|
|||||||
|
|
||||||
public interface AgentLoadBalancerPlanner extends Adapter{
|
public interface AgentLoadBalancerPlanner extends Adapter{
|
||||||
|
|
||||||
List<HostVO> getHostsToRebalance(long msId, long avLoad);
|
List<HostVO> getHostsToRebalance(long msId, int avLoad);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,11 +65,11 @@ public class ClusterBasedAgentLoadBalancerPlanner implements AgentLoadBalancerPl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostVO> getHostsToRebalance(long msId, long avLoad) {
|
public List<HostVO> getHostsToRebalance(long msId, int avLoad) {
|
||||||
List<HostVO> allHosts = _hostDao.listByManagementServer(msId);
|
List<HostVO> allHosts = _hostDao.listByManagementServer(msId);
|
||||||
|
|
||||||
if (allHosts.size() <= avLoad) {
|
if (allHosts.size() <= avLoad) {
|
||||||
s_logger.debug("Agent load for management server " + msId + " doesn't exceed av load " + avLoad + "; so it doesn't participate in agent rebalancing process");
|
s_logger.debug("Agent load = " + allHosts.size() + " for management server " + msId + " doesn't exceed average system agent load = " + avLoad + "; so it doesn't participate in agent rebalancing process");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,9 +96,9 @@ public class ClusterBasedAgentLoadBalancerPlanner implements AgentLoadBalancerPl
|
|||||||
|
|
||||||
hostToClusterMap = sortByClusterSize(hostToClusterMap);
|
hostToClusterMap = sortByClusterSize(hostToClusterMap);
|
||||||
|
|
||||||
long hostsToGive = allHosts.size() - avLoad;
|
int hostsToGive = allHosts.size() - avLoad;
|
||||||
long hostsLeftToGive = hostsToGive;
|
int hostsLeftToGive = hostsToGive;
|
||||||
long hostsLeft = directHosts.size();
|
int hostsLeft = directHosts.size();
|
||||||
List<HostVO> hostsToReturn = new ArrayList<HostVO>();
|
List<HostVO> hostsToReturn = new ArrayList<HostVO>();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ import com.cloud.utils.db.GenericDao;
|
|||||||
public class HostTransferMapVO {
|
public class HostTransferMapVO {
|
||||||
|
|
||||||
public enum HostTransferState {
|
public enum HostTransferState {
|
||||||
TransferRequested, TransferStarted, TransferCompleted, TransferFailed;
|
TransferRequested, TransferStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
|||||||
@ -29,13 +29,15 @@ public interface HostTransferMapDao extends GenericDao<HostTransferMapVO, Long>
|
|||||||
|
|
||||||
List<HostTransferMapVO> listHostsLeavingCluster(long clusterId);
|
List<HostTransferMapVO> listHostsLeavingCluster(long clusterId);
|
||||||
|
|
||||||
List<HostTransferMapVO> listHostsJoiningCluster(long clusterId);
|
List<HostTransferMapVO> listHostsJoiningCluster(long futureOwnerId);
|
||||||
|
|
||||||
HostTransferMapVO startAgentTransfering(long hostId, long currentOwner, long futureOwner);
|
HostTransferMapVO startAgentTransfering(long hostId, long currentOwner, long futureOwner);
|
||||||
|
|
||||||
boolean completeAgentTransfering(long hostId, boolean success);
|
boolean completeAgentTransfer(long hostId);
|
||||||
|
|
||||||
List<HostTransferMapVO> listBy(long futureOwnerId, HostTransferState state);
|
List<HostTransferMapVO> listBy(long futureOwnerId, HostTransferState state);
|
||||||
|
|
||||||
boolean isActive(long hostId, Date cutTime);
|
boolean isNotActive(long hostId, Date cutTime);
|
||||||
|
|
||||||
|
boolean startAgentTransfer(long hostId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ public class HostTransferMapDaoImpl extends GenericDaoBase<HostTransferMapVO, Lo
|
|||||||
|
|
||||||
IntermediateStateSearch = createSearchBuilder();
|
IntermediateStateSearch = createSearchBuilder();
|
||||||
IntermediateStateSearch.and("futureOwner", IntermediateStateSearch.entity().getFutureOwner(), SearchCriteria.Op.EQ);
|
IntermediateStateSearch.and("futureOwner", IntermediateStateSearch.entity().getFutureOwner(), SearchCriteria.Op.EQ);
|
||||||
IntermediateStateSearch.and("state", IntermediateStateSearch.entity().getState(), SearchCriteria.Op.NOTIN);
|
IntermediateStateSearch.and("state", IntermediateStateSearch.entity().getState(), SearchCriteria.Op.IN);
|
||||||
IntermediateStateSearch.done();
|
IntermediateStateSearch.done();
|
||||||
|
|
||||||
InactiveSearch = createSearchBuilder();
|
InactiveSearch = createSearchBuilder();
|
||||||
@ -72,10 +72,10 @@ public class HostTransferMapDaoImpl extends GenericDaoBase<HostTransferMapVO, Lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostTransferMapVO> listHostsJoiningCluster(long clusterId) {
|
public List<HostTransferMapVO> listHostsJoiningCluster(long futureOwnerId) {
|
||||||
SearchCriteria<HostTransferMapVO> sc = IntermediateStateSearch.create();
|
SearchCriteria<HostTransferMapVO> sc = IntermediateStateSearch.create();
|
||||||
sc.setParameters("futureOwner", clusterId);
|
sc.setParameters("futureOwner", futureOwnerId);
|
||||||
sc.setParameters("state", HostTransferState.TransferRequested, HostTransferState.TransferStarted);
|
sc.setParameters("state", HostTransferState.TransferRequested);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,14 +88,8 @@ public class HostTransferMapDaoImpl extends GenericDaoBase<HostTransferMapVO, Lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean completeAgentTransfering(long hostId, boolean success) {
|
public boolean completeAgentTransfer(long hostId) {
|
||||||
HostTransferMapVO transfer = findById(hostId);
|
return remove(hostId);
|
||||||
if (success) {
|
|
||||||
transfer.setState(HostTransferState.TransferCompleted);
|
|
||||||
} else {
|
|
||||||
transfer.setState(HostTransferState.TransferFailed);
|
|
||||||
}
|
|
||||||
return update(hostId, transfer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -108,18 +102,24 @@ public class HostTransferMapDaoImpl extends GenericDaoBase<HostTransferMapVO, Lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActive(long hostId, Date cutTime) {
|
public boolean isNotActive(long hostId, Date cutTime) {
|
||||||
SearchCriteria<HostTransferMapVO> sc = InactiveSearch.create();
|
SearchCriteria<HostTransferMapVO> sc = InactiveSearch.create();
|
||||||
sc.setParameters("id", hostId);
|
sc.setParameters("id", hostId);
|
||||||
sc.setParameters("state", HostTransferState.TransferRequested);
|
sc.setParameters("state", HostTransferState.TransferRequested);
|
||||||
sc.setParameters("created", cutTime);
|
sc.setParameters("created", cutTime);
|
||||||
|
|
||||||
|
|
||||||
if (listBy(sc).isEmpty()) {
|
if (listBy(sc).isEmpty()) {
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean startAgentTransfer(long hostId) {
|
||||||
|
HostTransferMapVO transfer = findById(hostId);
|
||||||
|
transfer.setState(HostTransferState.TransferStarted);
|
||||||
|
return update(hostId, transfer);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -328,7 +328,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer
|
|||||||
public List<ManagementServerHostVO> listBy(ManagementServerHost.State...states) {
|
public List<ManagementServerHostVO> listBy(ManagementServerHost.State...states) {
|
||||||
SearchCriteria<ManagementServerHostVO> sc = StateSearch.create();
|
SearchCriteria<ManagementServerHostVO> sc = StateSearch.create();
|
||||||
|
|
||||||
sc.setParameters("status", (Object[]) states);
|
sc.setParameters("state", (Object[]) states);
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -130,6 +130,7 @@ import com.cloud.utils.db.Transaction;
|
|||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.net.NetUtils;
|
import com.cloud.utils.net.NetUtils;
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||||
import com.cloud.vm.dao.DomainRouterDao;
|
import com.cloud.vm.dao.DomainRouterDao;
|
||||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||||
@ -937,9 +938,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
selectSql += " AND taken IS NOT NULL";
|
selectSql += " AND taken IS NOT NULL";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tableName.equals("host_pod_ref")) {
|
if (tableName.equals("host_pod_ref") || tableName.equals("host") || tableName.equals("volumes")) {
|
||||||
selectSql += " AND removed is NULL";
|
selectSql += " AND removed is NULL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tableName.equals("vm_instance")) {
|
||||||
|
selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "'";
|
||||||
|
}
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
@ -1060,11 +1065,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
List<NetworkVO> networks = _networkDao.listByZoneIncludingRemoved(zoneId);
|
List<NetworkVO> networks = _networkDao.listByZoneIncludingRemoved(zoneId);
|
||||||
if (networks != null && !networks.isEmpty()) {
|
if (networks != null && !networks.isEmpty()) {
|
||||||
for (NetworkVO network : networks) {
|
for (NetworkVO network : networks) {
|
||||||
_networkDao.expunge(network.getId());
|
_networkDao.remove(network.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
success = _zoneDao.remove(zoneId);
|
||||||
success = _zoneDao.expunge(zoneId);
|
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
@ -1367,7 +1371,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
userNetwork.setBroadcastDomainType(broadcastDomainType);
|
userNetwork.setBroadcastDomainType(broadcastDomainType);
|
||||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true, isNetworkDefault, false, null);
|
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true, isNetworkDefault, false, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -571,7 +571,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
|
|
||||||
Map<String, Object> context = new HashMap<String, Object>();
|
Map<String, Object> context = new HashMap<String, Object>();
|
||||||
context.put("dc", dc);
|
context.put("dc", dc);
|
||||||
HostPodVO pod = _podDao.findById(proxy.getPodId());
|
HostPodVO pod = _podDao.findById(proxy.getPodIdToDeployIn());
|
||||||
context.put("pod", pod);
|
context.put("pod", pod);
|
||||||
context.put("proxyVmId", proxy.getId());
|
context.put("proxyVmId", proxy.getId());
|
||||||
|
|
||||||
@ -1116,7 +1116,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
}
|
}
|
||||||
|
|
||||||
SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this,
|
SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this,
|
||||||
new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_REBOOTED, proxy.getDataCenterId(), proxy.getId(), proxy, null));
|
new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_REBOOTED, proxy.getDataCenterIdToDeployIn(), proxy.getId(), proxy, null));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -1325,7 +1325,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
if (externalDhcp) {
|
if (externalDhcp) {
|
||||||
buf.append(" bootproto=dhcp");
|
buf.append(" bootproto=dhcp");
|
||||||
}
|
}
|
||||||
DataCenterVO dc = _dcDao.findById(profile.getVirtualMachine().getDataCenterId());
|
DataCenterVO dc = _dcDao.findById(profile.getVirtualMachine().getDataCenterIdToDeployIn());
|
||||||
buf.append(" internaldns1=").append(dc.getInternalDns1());
|
buf.append(" internaldns1=").append(dc.getInternalDns1());
|
||||||
if (dc.getInternalDns2() != null) {
|
if (dc.getInternalDns2() != null) {
|
||||||
buf.append(" internaldns2=").append(dc.getInternalDns2());
|
buf.append(" internaldns2=").append(dc.getInternalDns2());
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public class StaticConsoleProxyManager extends AgentBasedConsoleProxyManager imp
|
|||||||
@Override
|
@Override
|
||||||
protected HostVO findHost(VMInstanceVO vm) {
|
protected HostVO findHost(VMInstanceVO vm) {
|
||||||
|
|
||||||
List<HostVO> hosts = _hostDao.listBy(Type.ConsoleProxy, vm.getDataCenterId());
|
List<HostVO> hosts = _hostDao.listBy(Type.ConsoleProxy, vm.getDataCenterIdToDeployIn());
|
||||||
|
|
||||||
return hosts.isEmpty() ? null : hosts.get(0);
|
return hosts.isEmpty() ? null : hosts.get(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.cloud.dc;
|
package com.cloud.dc;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@ -34,6 +35,7 @@ import javax.persistence.Transient;
|
|||||||
import com.cloud.network.Network.Provider;
|
import com.cloud.network.Network.Provider;
|
||||||
import com.cloud.org.Grouping;
|
import com.cloud.org.Grouping;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="data_center")
|
@Table(name="data_center")
|
||||||
@ -111,6 +113,9 @@ public class DataCenterVO implements DataCenter {
|
|||||||
|
|
||||||
@Column(name="zone_token")
|
@Column(name="zone_token")
|
||||||
private String zoneToken;
|
private String zoneToken;
|
||||||
|
|
||||||
|
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||||
|
private Date removed;
|
||||||
|
|
||||||
// This is a delayed load value. If the value is null,
|
// This is a delayed load value. If the value is null,
|
||||||
// then this field has not been loaded yet.
|
// then this field has not been loaded yet.
|
||||||
@ -397,5 +402,9 @@ public class DataCenterVO implements DataCenter {
|
|||||||
|
|
||||||
public void setZoneToken(String zoneToken) {
|
public void setZoneToken(String zoneToken) {
|
||||||
this.zoneToken = zoneToken;
|
this.zoneToken = zoneToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getRemoved() {
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import com.cloud.dc.DataCenterIpAddressVO;
|
|||||||
import com.cloud.dc.DataCenterLinkLocalIpAddressVO;
|
import com.cloud.dc.DataCenterLinkLocalIpAddressVO;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.DataCenterVnetVO;
|
import com.cloud.dc.DataCenterVnetVO;
|
||||||
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.dc.PodVlanVO;
|
import com.cloud.dc.PodVlanVO;
|
||||||
import com.cloud.org.Grouping;
|
import com.cloud.org.Grouping;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
@ -355,4 +356,18 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(Long id) {
|
||||||
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
txn.start();
|
||||||
|
DataCenterVO zone = createForUpdate();
|
||||||
|
zone.setName(null);
|
||||||
|
|
||||||
|
update(id, zone);
|
||||||
|
|
||||||
|
boolean result = super.remove(id);
|
||||||
|
txn.commit();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,7 @@ public class BareMetalPlanner implements DeploymentPlanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ClusterVO> clusters = _clusterDao.listByDcHyType(vm.getDataCenterId(), HypervisorType.BareMetal.toString());
|
List<ClusterVO> clusters = _clusterDao.listByDcHyType(vm.getDataCenterIdToDeployIn(), HypervisorType.BareMetal.toString());
|
||||||
if (clusters.size() != 1) {
|
if (clusters.size() != 1) {
|
||||||
throw new CloudRuntimeException("Invaild baremetal cluster number " + clusters.size());
|
throw new CloudRuntimeException("Invaild baremetal cluster number " + clusters.size());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,7 +110,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||||||
String _allocationAlgorithm = _configDao.getValue(Config.VmAllocationAlgorithm.key());
|
String _allocationAlgorithm = _configDao.getValue(Config.VmAllocationAlgorithm.key());
|
||||||
VirtualMachine vm = vmProfile.getVirtualMachine();
|
VirtualMachine vm = vmProfile.getVirtualMachine();
|
||||||
ServiceOffering offering = vmProfile.getServiceOffering();
|
ServiceOffering offering = vmProfile.getServiceOffering();
|
||||||
DataCenter dc = _dcDao.findById(vm.getDataCenterId());
|
DataCenter dc = _dcDao.findById(vm.getDataCenterIdToDeployIn());
|
||||||
int cpu_requested = offering.getCpu() * offering.getSpeed();
|
int cpu_requested = offering.getCpu() * offering.getSpeed();
|
||||||
long ram_requested = offering.getRamSize() * 1024L * 1024L;
|
long ram_requested = offering.getRamSize() * 1024L * 1024L;
|
||||||
|
|
||||||
|
|||||||
@ -273,8 +273,8 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(_forceHA || vm.isHaEnabled())) {
|
if (!(_forceHA || vm.isHaEnabled())) {
|
||||||
String hostDesc = "id:" + vm.getHostId() + ", availability zone id:" + vm.getDataCenterId() + ", pod id:" + vm.getPodId();
|
String hostDesc = "id:" + vm.getHostId() + ", availability zone id:" + vm.getDataCenterIdToDeployIn() + ", pod id:" + vm.getPodIdToDeployIn();
|
||||||
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "VM (name: " + vm.getHostName() + ", id: " + vm.getId() + ") stopped unexpectedly on host " + hostDesc,
|
_alertMgr.sendAlert(alertType, vm.getDataCenterIdToDeployIn(), vm.getPodIdToDeployIn(), "VM (name: " + vm.getHostName() + ", id: " + vm.getId() + ") stopped unexpectedly on host " + hostDesc,
|
||||||
"Virtual Machine " + vm.getHostName() + " (id: " + vm.getId() + ") running on host [" + vm.getHostId() + "] stopped unexpectedly.");
|
"Virtual Machine " + vm.getHostName() + " (id: " + vm.getId() + ") running on host [" + vm.getHostId() + "] stopped unexpectedly.");
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
@ -404,7 +404,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
|
|
||||||
if (!fenced) {
|
if (!fenced) {
|
||||||
s_logger.debug("We were unable to fence off the VM " + vm);
|
s_logger.debug("We were unable to fence off the VM " + vm);
|
||||||
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
_alertMgr.sendAlert(alertType, vm.getDataCenterIdToDeployIn(), vm.getPodIdToDeployIn(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
||||||
"Insufficient capacity to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
"Insufficient capacity to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
||||||
return (System.currentTimeMillis() >> 10) + _restartRetryInterval;
|
return (System.currentTimeMillis() >> 10) + _restartRetryInterval;
|
||||||
}
|
}
|
||||||
@ -462,19 +462,19 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
}
|
}
|
||||||
} catch (final InsufficientCapacityException e) {
|
} catch (final InsufficientCapacityException e) {
|
||||||
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
|
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
|
||||||
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
_alertMgr.sendAlert(alertType, vm.getDataCenterIdToDeployIn(), vm.getPodIdToDeployIn(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
||||||
"Insufficient capacity to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
"Insufficient capacity to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
||||||
} catch (final ResourceUnavailableException e) {
|
} catch (final ResourceUnavailableException e) {
|
||||||
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
|
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
|
||||||
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
_alertMgr.sendAlert(alertType, vm.getDataCenterIdToDeployIn(), vm.getPodIdToDeployIn(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
||||||
"The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
"The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
||||||
} catch (ConcurrentOperationException e) {
|
} catch (ConcurrentOperationException e) {
|
||||||
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
|
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
|
||||||
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
_alertMgr.sendAlert(alertType, vm.getDataCenterIdToDeployIn(), vm.getPodIdToDeployIn(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
||||||
"The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
"The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
||||||
} catch (OperationTimedoutException e) {
|
} catch (OperationTimedoutException e) {
|
||||||
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
|
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage());
|
||||||
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
_alertMgr.sendAlert(alertType, vm.getDataCenterIdToDeployIn(), vm.getPodIdToDeployIn(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
||||||
"The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
"The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
||||||
}
|
}
|
||||||
vm = _itMgr.findById(vm.getType(), vm.getId());
|
vm = _itMgr.findById(vm.getType(), vm.getId());
|
||||||
|
|||||||
@ -172,7 +172,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
|
|||||||
|| vm.getHypervisorType() == HypervisorType.KVM){
|
|| vm.getHypervisorType() == HypervisorType.KVM){
|
||||||
otherHosts.add(router.getHostId());
|
otherHosts.add(router.getHostId());
|
||||||
}else{
|
}else{
|
||||||
otherHosts = findHostByPod(router.getPodId(), null);
|
otherHosts = findHostByPod(router.getPodIdToDeployIn(), null);
|
||||||
}
|
}
|
||||||
for (Long hostId : otherHosts) {
|
for (Long hostId : otherHosts) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -171,7 +171,7 @@ public interface HostDao extends GenericDao<HostVO, Long> {
|
|||||||
|
|
||||||
List<HostVO> listManagedDirectAgents();
|
List<HostVO> listManagedDirectAgents();
|
||||||
|
|
||||||
List<HostVO> listManagedAgents();
|
List<HostVO> listManagedRoutingAgents();
|
||||||
|
|
||||||
HostVO findTrafficMonitorHost();
|
HostVO findTrafficMonitorHost();
|
||||||
|
|
||||||
|
|||||||
@ -91,7 +91,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
protected final SearchBuilder<HostVO> DirectConnectSearch;
|
protected final SearchBuilder<HostVO> DirectConnectSearch;
|
||||||
protected final SearchBuilder<HostVO> ManagedDirectConnectSearch;
|
protected final SearchBuilder<HostVO> ManagedDirectConnectSearch;
|
||||||
protected final SearchBuilder<HostVO> ManagedConnectSearch;
|
protected final SearchBuilder<HostVO> ManagedRoutingServersSearch;
|
||||||
|
|
||||||
protected final GenericSearchBuilder<HostVO, Long> HostsInStatusSearch;
|
protected final GenericSearchBuilder<HostVO, Long> HostsInStatusSearch;
|
||||||
protected final GenericSearchBuilder<HostVO, Long> CountRoutingByDc;
|
protected final GenericSearchBuilder<HostVO, Long> CountRoutingByDc;
|
||||||
@ -264,9 +264,10 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
ManagedDirectConnectSearch.and("server", ManagedDirectConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.NULL);
|
ManagedDirectConnectSearch.and("server", ManagedDirectConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.NULL);
|
||||||
ManagedDirectConnectSearch.done();
|
ManagedDirectConnectSearch.done();
|
||||||
|
|
||||||
ManagedConnectSearch = createSearchBuilder();
|
ManagedRoutingServersSearch = createSearchBuilder();
|
||||||
ManagedConnectSearch.and("server", ManagedConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.NNULL);
|
ManagedRoutingServersSearch.and("server", ManagedRoutingServersSearch.entity().getManagementServerId(), SearchCriteria.Op.NNULL);
|
||||||
ManagedConnectSearch.done();
|
ManagedRoutingServersSearch.and("type", ManagedRoutingServersSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||||
|
ManagedRoutingServersSearch.done();
|
||||||
|
|
||||||
_statusAttr = _allAttributes.get("status");
|
_statusAttr = _allAttributes.get("status");
|
||||||
_msIdAttr = _allAttributes.get("managementServerId");
|
_msIdAttr = _allAttributes.get("managementServerId");
|
||||||
@ -868,8 +869,9 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostVO> listManagedAgents() {
|
public List<HostVO> listManagedRoutingAgents() {
|
||||||
SearchCriteria<HostVO> sc = ManagedConnectSearch.create();
|
SearchCriteria<HostVO> sc = ManagedRoutingServersSearch.create();
|
||||||
|
sc.setParameters("type", Type.Routing);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -570,7 +570,7 @@ public class Db20to21MigrationUtil {
|
|||||||
private void migrateSystemVmGuestMacAndState(long zoneId) {
|
private void migrateSystemVmGuestMacAndState(long zoneId) {
|
||||||
// for console proxy VMs
|
// for console proxy VMs
|
||||||
SearchBuilder<ConsoleProxyVO> sb = _consoleProxyDao.createSearchBuilder();
|
SearchBuilder<ConsoleProxyVO> sb = _consoleProxyDao.createSearchBuilder();
|
||||||
sb.and("zoneId", sb.entity().getDataCenterId(), Op.EQ);
|
sb.and("zoneId", sb.entity().getDataCenterIdToDeployIn(), Op.EQ);
|
||||||
sb.done();
|
sb.done();
|
||||||
|
|
||||||
SearchCriteria<ConsoleProxyVO> sc = sb.create();
|
SearchCriteria<ConsoleProxyVO> sc = sb.create();
|
||||||
@ -586,7 +586,7 @@ public class Db20to21MigrationUtil {
|
|||||||
proxy.setState(State.Stopping);
|
proxy.setState(State.Stopping);
|
||||||
}
|
}
|
||||||
|
|
||||||
String guestIpAddress = _dcDao.allocateLinkLocalIpAddress(proxy.getDataCenterId(), proxy.getPodId(), proxy.getId(), null);
|
String guestIpAddress = _dcDao.allocateLinkLocalIpAddress(proxy.getDataCenterIdToDeployIn(), proxy.getPodIdToDeployIn(), proxy.getId(), null);
|
||||||
|
|
||||||
System.out.println("Assign link loal address to proxy " + proxy.getHostName() + ", link local address: " + guestIpAddress);
|
System.out.println("Assign link loal address to proxy " + proxy.getHostName() + ", link local address: " + guestIpAddress);
|
||||||
_consoleProxyDao.update(proxy.getId(), proxy);
|
_consoleProxyDao.update(proxy.getId(), proxy);
|
||||||
@ -594,7 +594,7 @@ public class Db20to21MigrationUtil {
|
|||||||
|
|
||||||
// for secondary storage VMs
|
// for secondary storage VMs
|
||||||
SearchBuilder<SecondaryStorageVmVO> sb2 = _secStorageVmDao.createSearchBuilder();
|
SearchBuilder<SecondaryStorageVmVO> sb2 = _secStorageVmDao.createSearchBuilder();
|
||||||
sb2.and("zoneId", sb2.entity().getDataCenterId(), Op.EQ);
|
sb2.and("zoneId", sb2.entity().getDataCenterIdToDeployIn(), Op.EQ);
|
||||||
sb2.done();
|
sb2.done();
|
||||||
|
|
||||||
SearchCriteria<SecondaryStorageVmVO> sc2 = sb2.create();
|
SearchCriteria<SecondaryStorageVmVO> sc2 = sb2.create();
|
||||||
@ -610,7 +610,7 @@ public class Db20to21MigrationUtil {
|
|||||||
secStorageVm.setState(State.Stopping);
|
secStorageVm.setState(State.Stopping);
|
||||||
}
|
}
|
||||||
|
|
||||||
String guestIpAddress = _dcDao.allocateLinkLocalIpAddress(secStorageVm.getDataCenterId(), secStorageVm.getPodId(), secStorageVm.getId(), null);
|
String guestIpAddress = _dcDao.allocateLinkLocalIpAddress(secStorageVm.getDataCenterIdToDeployIn(), secStorageVm.getPodIdToDeployIn(), secStorageVm.getId(), null);
|
||||||
|
|
||||||
System.out.println("Assign link loal address to secondary storage VM " + secStorageVm.getHostName() + ", link local address: " + guestIpAddress);
|
System.out.println("Assign link loal address to secondary storage VM " + secStorageVm.getHostName() + ", link local address: " + guestIpAddress);
|
||||||
_secStorageVmDao.update(secStorageVm.getId(), secStorageVm);
|
_secStorageVmDao.update(secStorageVm.getId(), secStorageVm);
|
||||||
@ -619,7 +619,7 @@ public class Db20to21MigrationUtil {
|
|||||||
// for Domain Router VMs
|
// for Domain Router VMs
|
||||||
// Although we can list those we are interested, but just too lazy, list all of them and check their states.
|
// Although we can list those we are interested, but just too lazy, list all of them and check their states.
|
||||||
SearchBuilder<DomainRouterVO> sb3 = _routerDao.createSearchBuilder();
|
SearchBuilder<DomainRouterVO> sb3 = _routerDao.createSearchBuilder();
|
||||||
sb3.and("zoneId", sb3.entity().getDataCenterId(), Op.EQ);
|
sb3.and("zoneId", sb3.entity().getDataCenterIdToDeployIn(), Op.EQ);
|
||||||
sb3.done();
|
sb3.done();
|
||||||
|
|
||||||
SearchCriteria<DomainRouterVO> sc3 = sb3.create();
|
SearchCriteria<DomainRouterVO> sc3 = sb3.create();
|
||||||
@ -637,8 +637,8 @@ public class Db20to21MigrationUtil {
|
|||||||
|
|
||||||
private void migrateVmInstanceLastHostId(long zoneId, long podId) {
|
private void migrateVmInstanceLastHostId(long zoneId, long podId) {
|
||||||
SearchBuilder<VMInstanceVO> sb = _vmInstanceDao.createSearchBuilder();
|
SearchBuilder<VMInstanceVO> sb = _vmInstanceDao.createSearchBuilder();
|
||||||
sb.and("zoneId", sb.entity().getDataCenterId(), Op.EQ);
|
sb.and("zoneId", sb.entity().getDataCenterIdToDeployIn(), Op.EQ);
|
||||||
sb.and("podId", sb.entity().getPodId(), Op.EQ);
|
sb.and("podId", sb.entity().getPodIdToDeployIn(), Op.EQ);
|
||||||
sb.done();
|
sb.done();
|
||||||
|
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
|
|||||||
@ -109,7 +109,7 @@ public interface NetworkManager extends NetworkService {
|
|||||||
throws ConcurrentOperationException;
|
throws ConcurrentOperationException;
|
||||||
|
|
||||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault,
|
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault,
|
||||||
boolean errorIfAlreadySetup, Long domainId) throws ConcurrentOperationException;
|
boolean errorIfAlreadySetup, Long domainId, List<String> tags) throws ConcurrentOperationException;
|
||||||
|
|
||||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ public interface NetworkManager extends NetworkService {
|
|||||||
boolean destroyNetwork(long networkId, ReservationContext context);
|
boolean destroyNetwork(long networkId, ReservationContext context);
|
||||||
|
|
||||||
Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isShared, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId, String networkDomain,
|
Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isShared, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId, String networkDomain,
|
||||||
Account owner, boolean isSecurityGroupEnabled, Long domainId) throws ConcurrentOperationException, InsufficientCapacityException;
|
Account owner, boolean isSecurityGroupEnabled, Long domainId, List<String> tags) throws ConcurrentOperationException, InsufficientCapacityException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws InsufficientCapacityException
|
* @throws InsufficientCapacityException
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
package com.cloud.network;
|
package com.cloud.network;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.security.InvalidParameterException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -264,7 +265,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
if (addrs.size() == 0) {
|
if (addrs.size() == 0) {
|
||||||
if (podId != null) {
|
if (podId != null) {
|
||||||
throw new InsufficientAddressCapacityException("Insufficient address capacity", HostPodDao.class, podId);
|
throw new InsufficientAddressCapacityException("Insufficient address capacity", HostPodDao.class, podId);
|
||||||
}
|
}
|
||||||
throw new InsufficientAddressCapacityException("Insufficient address capacity", DataCenter.class, dcId);
|
throw new InsufficientAddressCapacityException("Insufficient address capacity", DataCenter.class, dcId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +316,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
NetworkVO network = _networksDao.findByIdIncludingRemoved(networkId);
|
NetworkVO network = _networksDao.findByIdIncludingRemoved(networkId);
|
||||||
String guestType = "";
|
String guestType = "";
|
||||||
if( (network != null) && (network.getGuestType() != null) ){
|
if( (network != null) && (network.getGuestType() != null) ){
|
||||||
guestType = network.getGuestType().toString();
|
guestType = network.getGuestType().toString();
|
||||||
}
|
}
|
||||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_ASSIGN, owner.getId(), addr.getDataCenterId(), addr.getId(), addr.getAddress().toString(), isSourceNat, guestType);
|
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_ASSIGN, owner.getId(), addr.getDataCenterId(), addr.getId(), addr.getAddress().toString(), isSourceNat, guestType);
|
||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
@ -829,13 +830,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
@Override
|
@Override
|
||||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault)
|
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault)
|
||||||
throws ConcurrentOperationException {
|
throws ConcurrentOperationException {
|
||||||
return setupNetwork(owner, offering, null, plan, name, displayText, isShared, isDefault, false, null);
|
return setupNetwork(owner, offering, null, plan, name, displayText, isShared, isDefault, false, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault,
|
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault,
|
||||||
boolean errorIfAlreadySetup, Long domainId) throws ConcurrentOperationException {
|
boolean errorIfAlreadySetup, Long domainId, List<String> tags) throws ConcurrentOperationException {
|
||||||
Account locked = _accountDao.acquireInLockTable(owner.getId());
|
Account locked = _accountDao.acquireInLockTable(owner.getId());
|
||||||
if (locked == null) {
|
if (locked == null) {
|
||||||
throw new ConcurrentOperationException("Unable to acquire lock on " + owner);
|
throw new ConcurrentOperationException("Unable to acquire lock on " + owner);
|
||||||
@ -870,21 +871,21 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NetworkVO> configs = new ArrayList<NetworkVO>();
|
List<NetworkVO> networks = new ArrayList<NetworkVO>();
|
||||||
|
|
||||||
long related = -1;
|
long related = -1;
|
||||||
|
|
||||||
for (NetworkGuru guru : _networkGurus) {
|
for (NetworkGuru guru : _networkGurus) {
|
||||||
Network config = guru.design(offering, plan, predefined, owner);
|
Network network = guru.design(offering, plan, predefined, owner);
|
||||||
if (config == null) {
|
if (network == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getId() != -1) {
|
if (network.getId() != -1) {
|
||||||
if (config instanceof NetworkVO) {
|
if (network instanceof NetworkVO) {
|
||||||
configs.add((NetworkVO) config);
|
networks.add((NetworkVO) network);
|
||||||
} else {
|
} else {
|
||||||
configs.add(_networksDao.findById(config.getId()));
|
networks.add(_networksDao.findById(network.getId()));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -894,20 +895,21 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
related = id;
|
related = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkVO vo = new NetworkVO(id, config, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isShared, isDefault,
|
NetworkVO vo = new NetworkVO(id, network, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isShared, isDefault,
|
||||||
predefined.isSecurityGroupEnabled());
|
predefined.isSecurityGroupEnabled());
|
||||||
configs.add(_networksDao.persist(vo, vo.getGuestType() != null));
|
vo.setTags(tags);
|
||||||
|
networks.add(_networksDao.persist(vo, vo.getGuestType() != null));
|
||||||
|
|
||||||
if (domainId != null) {
|
if (domainId != null) {
|
||||||
_networksDao.addDomainToNetwork(id, domainId);
|
_networksDao.addDomainToNetwork(id, domainId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configs.size() < 1) {
|
if (networks.size() < 1) {
|
||||||
throw new CloudRuntimeException("Unable to convert network offering to network profile: " + offering.getId());
|
throw new CloudRuntimeException("Unable to convert network offering to network profile: " + offering.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return configs;
|
return networks;
|
||||||
} finally {
|
} finally {
|
||||||
s_logger.debug("Releasing lock for " + locked);
|
s_logger.debug("Releasing lock for " + locked);
|
||||||
_accountDao.releaseFromLockTable(locked.getId());
|
_accountDao.releaseFromLockTable(locked.getId());
|
||||||
@ -1133,7 +1135,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
network.setMode(result.getMode());
|
network.setMode(result.getMode());
|
||||||
_networksDao.update(networkId, network);
|
_networksDao.update(networkId, network);
|
||||||
|
|
||||||
// If this is a guest virtual network and the network offering does not support a shared source NAT rule,
|
// If this is a guest virtual network and the network offering does not support a shared source NAT rule,
|
||||||
// associate a source NAT IP (if one isn't already associated with the network)
|
// associate a source NAT IP (if one isn't already associated with the network)
|
||||||
if (network.getGuestType() == GuestIpType.Virtual && !offering.isSharedSourceNatService()) {
|
if (network.getGuestType() == GuestIpType.Virtual && !offering.isSharedSourceNatService()) {
|
||||||
List<IPAddressVO> ips = _ipAddressDao.listByAssociatedNetwork(networkId, true);
|
List<IPAddressVO> ips = _ipAddressDao.listByAssociatedNetwork(networkId, true);
|
||||||
@ -1247,6 +1249,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
updateNic(nic, network.getId(), 1);
|
updateNic(nic, network.getId(), 1);
|
||||||
} else {
|
} else {
|
||||||
profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate);
|
profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate);
|
||||||
|
guru.updateNicProfile(profile, network);
|
||||||
nic.setState(Nic.State.Reserved);
|
nic.setState(Nic.State.Reserved);
|
||||||
updateNic(nic, network.getId(), 1);
|
updateNic(nic, network.getId(), 1);
|
||||||
}
|
}
|
||||||
@ -1470,7 +1473,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
Boolean isDefault = cmd.isDefault();
|
Boolean isDefault = cmd.isDefault();
|
||||||
Long userId = UserContext.current().getCallerUserId();
|
Long userId = UserContext.current().getCallerUserId();
|
||||||
Account caller = UserContext.current().getCaller();
|
Account caller = UserContext.current().getCaller();
|
||||||
|
List<String> tags = cmd.getTags();
|
||||||
boolean isDomainSpecific = false;
|
boolean isDomainSpecific = false;
|
||||||
|
|
||||||
|
if (tags != null && tags.size() > 1) {
|
||||||
|
throw new InvalidParameterException("Only one tag can be specified for a network at this time");
|
||||||
|
}
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
|
||||||
@ -1584,7 +1592,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
domainId = cmd.getDomainId();
|
domainId = cmd.getDomainId();
|
||||||
}
|
}
|
||||||
|
|
||||||
Network network = createNetwork(networkOfferingId, name, displayText, isShared, isDefault, zoneId, gateway, cidr, vlanId, networkDomain, owner, false, domainId);
|
Network network = createNetwork(networkOfferingId, name, displayText, isShared, isDefault, zoneId, gateway, cidr, vlanId, networkDomain, owner, false, domainId, null);
|
||||||
|
|
||||||
// Don't pass owner to create vlan when network offering is of type Direct - done to prevent accountVlanMap entry
|
// Don't pass owner to create vlan when network offering is of type Direct - done to prevent accountVlanMap entry
|
||||||
// creation when vlan is mapped to network
|
// creation when vlan is mapped to network
|
||||||
@ -1605,7 +1613,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isShared, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId,
|
public Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isShared, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId,
|
||||||
String networkDomain, Account owner, boolean isSecurityGroupEnabled, Long domainId) throws ConcurrentOperationException, InsufficientCapacityException {
|
String networkDomain, Account owner, boolean isSecurityGroupEnabled, Long domainId, List<String> tags) throws ConcurrentOperationException, InsufficientCapacityException {
|
||||||
|
|
||||||
NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId);
|
NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId);
|
||||||
DataCenterVO zone = _dcDao.findById(zoneId);
|
DataCenterVO zone = _dcDao.findById(zoneId);
|
||||||
@ -1706,7 +1714,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NetworkVO> networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isShared, isDefault, true, domainId);
|
List<NetworkVO> networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isShared, isDefault, true, domainId, tags);
|
||||||
|
|
||||||
Network network = null;
|
Network network = null;
|
||||||
if (networks == null || networks.isEmpty()) {
|
if (networks == null || networks.isEmpty()) {
|
||||||
@ -2520,7 +2528,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
// create new Virtual network for the user if it doesn't exist
|
// create new Virtual network for the user if it doesn't exist
|
||||||
if (createNetwork) {
|
if (createNetwork) {
|
||||||
List<? extends NetworkOffering> offerings = _configMgr.listNetworkOfferings(TrafficType.Guest, false);
|
List<? extends NetworkOffering> offerings = _configMgr.listNetworkOfferings(TrafficType.Guest, false);
|
||||||
network = createNetwork(offerings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", false, null, zoneId, null, null, null, null, owner, false, null);
|
network = createNetwork(offerings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", false, null, zoneId, null, null, null, null, owner, false, null, null);
|
||||||
|
|
||||||
if (network == null) {
|
if (network == null) {
|
||||||
s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId);
|
s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId);
|
||||||
@ -2636,7 +2644,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
return (zone.getGatewayProvider() != null && zone.getGatewayProvider().equals(Network.Provider.JuniperSRX.getName()) &&
|
return (zone.getGatewayProvider() != null && zone.getGatewayProvider().equals(Network.Provider.JuniperSRX.getName()) &&
|
||||||
zone.getFirewallProvider() != null && zone.getFirewallProvider().equals(Network.Provider.JuniperSRX.getName()));
|
zone.getFirewallProvider() != null && zone.getFirewallProvider().equals(Network.Provider.JuniperSRX.getName()));
|
||||||
} else {
|
} else {
|
||||||
return (zone.getFirewallProvider() != null && zone.getFirewallProvider().equals(Network.Provider.JuniperSRX.getName()));
|
return (zone.getFirewallProvider() != null && zone.getFirewallProvider().equals(Network.Provider.JuniperSRX.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2764,7 +2772,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
NetworkVO network = _networksDao.findByIdIncludingRemoved(ip.getSourceNetworkId());
|
NetworkVO network = _networksDao.findByIdIncludingRemoved(ip.getSourceNetworkId());
|
||||||
String guestType = "";
|
String guestType = "";
|
||||||
if( (network != null) && (network.getGuestType() != null)){
|
if( (network != null) && (network.getGuestType() != null)){
|
||||||
guestType = network.getGuestType().toString();
|
guestType = network.getGuestType().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_RELEASE, ip.getAccountId(), ip.getDataCenterId(), addrId, ip.getAddress().addr(), isSourceNat, guestType);
|
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_RELEASE, ip.getAccountId(), ip.getDataCenterId(), addrId, ip.getAddress().addr(), isSourceNat, guestType);
|
||||||
@ -2826,14 +2834,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_UPDATE, eventDescription = "updating network", async = false)
|
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_UPDATE, eventDescription = "updating network", async = false)
|
||||||
public Network updateNetwork(long networkId, String name, String displayText, Account caller) {
|
public Network updateNetwork(long networkId, String name, String displayText, List<String> tags, Account caller) {
|
||||||
|
|
||||||
// verify input parameters
|
// verify input parameters
|
||||||
NetworkVO network = _networksDao.findById(networkId);
|
NetworkVO network = _networksDao.findById(networkId);
|
||||||
if (network == null) {
|
if (network == null) {
|
||||||
throw new InvalidParameterValueException("Network id=" + networkId + "doesn't exist in the system");
|
throw new InvalidParameterValueException("Network id=" + networkId + "doesn't exist in the system");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tags != null && tags.size() > 1) {
|
||||||
|
throw new InvalidParameterException("Unable to support more than one tag on network yet");
|
||||||
|
}
|
||||||
|
|
||||||
// Don't allow to update system network
|
// Don't allow to update system network
|
||||||
NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
|
NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
|
||||||
if (offering.isSystemOnly()) {
|
if (offering.isSystemOnly()) {
|
||||||
@ -2849,6 +2861,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
if (displayText != null) {
|
if (displayText != null) {
|
||||||
network.setDisplayText(displayText);
|
network.setDisplayText(displayText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tags != null) {
|
||||||
|
network.setTags(tags);
|
||||||
|
}
|
||||||
|
|
||||||
_networksDao.update(networkId, network);
|
_networksDao.update(networkId, network);
|
||||||
|
|
||||||
|
|||||||
@ -22,11 +22,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.CollectionTable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
import javax.persistence.Enumerated;
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.TableGenerator;
|
import javax.persistence.TableGenerator;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
@ -34,7 +38,6 @@ import javax.persistence.Transient;
|
|||||||
import com.cloud.network.Networks.BroadcastDomainType;
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
import com.cloud.network.Networks.Mode;
|
import com.cloud.network.Networks.Mode;
|
||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.network.dao.NetworkDao;
|
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
import com.cloud.utils.net.NetUtils;
|
import com.cloud.utils.net.NetUtils;
|
||||||
@ -73,7 +76,7 @@ public class NetworkVO implements Network {
|
|||||||
String displayText;;
|
String displayText;;
|
||||||
|
|
||||||
@Column(name="broadcast_uri")
|
@Column(name="broadcast_uri")
|
||||||
URI broadcastUri;
|
URI broadcastUri;
|
||||||
|
|
||||||
@Column(name="gateway")
|
@Column(name="gateway")
|
||||||
String gateway;
|
String gateway;
|
||||||
@ -132,7 +135,7 @@ public class NetworkVO implements Network {
|
|||||||
Date created;
|
Date created;
|
||||||
|
|
||||||
@Column(name="reservation_id")
|
@Column(name="reservation_id")
|
||||||
String reservationId;
|
String reservationId;
|
||||||
|
|
||||||
@Column(name="is_default")
|
@Column(name="is_default")
|
||||||
boolean isDefault;
|
boolean isDefault;
|
||||||
@ -140,7 +143,9 @@ public class NetworkVO implements Network {
|
|||||||
@Column(name="is_security_group_enabled")
|
@Column(name="is_security_group_enabled")
|
||||||
boolean securityGroupEnabled;
|
boolean securityGroupEnabled;
|
||||||
|
|
||||||
@Transient
|
@ElementCollection(targetClass = String.class, fetch=FetchType.EAGER)
|
||||||
|
@Column(name="tag")
|
||||||
|
@CollectionTable(name="network_tags", joinColumns=@JoinColumn(name="network_id"))
|
||||||
List<String> tags;
|
List<String> tags;
|
||||||
|
|
||||||
public NetworkVO() {
|
public NetworkVO() {
|
||||||
@ -408,7 +413,7 @@ public class NetworkVO implements Network {
|
|||||||
return isDefault;
|
return isDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSecurityGroupEnabled() {
|
public boolean isSecurityGroupEnabled() {
|
||||||
return securityGroupEnabled;
|
return securityGroupEnabled;
|
||||||
}
|
}
|
||||||
@ -464,10 +469,4 @@ public class NetworkVO implements Network {
|
|||||||
buf.append(id).append("|").append(trafficType.toString()).append("|").append(networkOfferingId).append("]");
|
buf.append(id).append("|").append(trafficType.toString()).append("|").append(networkOfferingId).append("]");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NetworkDao _networkDao = null;
|
|
||||||
static void init(NetworkDao networkDao) {
|
|
||||||
_networkDao = networkDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,6 +117,10 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
|||||||
getIp(nic, dest.getPod(), vm, network);
|
getIp(nic, dest.getPod(), vm, network);
|
||||||
nic.setStrategy(ReservationStrategy.Create);
|
nic.setStrategy(ReservationStrategy.Create);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||||
|
nic.setDns1(dc.getDns1());
|
||||||
|
nic.setDns2(dc.getDns2());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void getIp(NicProfile nic, Pod pod, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException,
|
protected void getIp(NicProfile nic, Pod pod, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException,
|
||||||
|
|||||||
@ -395,7 +395,7 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
|||||||
long hostId = dest.getHost().getId();
|
long hostId = dest.getHost().getId();
|
||||||
long accountId = instance.getAccountId();
|
long accountId = instance.getAccountId();
|
||||||
List<UserVmVO>vms = _userVmDao.listByAccountId(accountId);
|
List<UserVmVO>vms = _userVmDao.listByAccountId(accountId);
|
||||||
DomainRouterVO router = _routerDao.findBy(accountId, instance.getDataCenterId());
|
DomainRouterVO router = _routerDao.findBy(accountId, instance.getDataCenterIdToDeployIn());
|
||||||
List<VMInstanceVO>ins = new ArrayList<VMInstanceVO>();
|
List<VMInstanceVO>ins = new ArrayList<VMInstanceVO>();
|
||||||
ins.addAll(vms);
|
ins.addAll(vms);
|
||||||
ins.add(router);
|
ins.add(router);
|
||||||
@ -538,7 +538,7 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long accountId = instance.getAccountId();
|
long accountId = instance.getAccountId();
|
||||||
DomainRouterVO router = _routerDao.findBy(accountId, instance.getDataCenterId());
|
DomainRouterVO router = _routerDao.findBy(accountId, instance.getDataCenterIdToDeployIn());
|
||||||
if (router == null) {
|
if (router == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -639,7 +639,7 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tellRouter && instance.getType() != VirtualMachine.Type.DomainRouter) {
|
if (tellRouter && instance.getType() != VirtualMachine.Type.DomainRouter) {
|
||||||
DomainRouterVO router = _routerDao.findBy(accountId, instance.getDataCenterId());
|
DomainRouterVO router = _routerDao.findBy(accountId, instance.getDataCenterIdToDeployIn());
|
||||||
if (router != null) {
|
if (router != null) {
|
||||||
affectedVms.add(new Long(router.getId()));
|
affectedVms.add(new Long(router.getId()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -153,7 +153,7 @@ public class OvsTunnelManagerImpl implements OvsTunnelManager {
|
|||||||
long hostId = dest.getHost().getId();
|
long hostId = dest.getHost().getId();
|
||||||
long accountId = instance.getAccountId();
|
long accountId = instance.getAccountId();
|
||||||
List<UserVmVO>vms = _userVmDao.listByAccountId(accountId);
|
List<UserVmVO>vms = _userVmDao.listByAccountId(accountId);
|
||||||
DomainRouterVO router = _routerDao.findBy(accountId, instance.getDataCenterId());
|
DomainRouterVO router = _routerDao.findBy(accountId, instance.getDataCenterIdToDeployIn());
|
||||||
List<VMInstanceVO>ins = new ArrayList<VMInstanceVO>();
|
List<VMInstanceVO>ins = new ArrayList<VMInstanceVO>();
|
||||||
if (vms != null) {
|
if (vms != null) {
|
||||||
ins.addAll(vms);
|
ins.addAll(vms);
|
||||||
@ -284,7 +284,7 @@ public class OvsTunnelManagerImpl implements OvsTunnelManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DomainRouterVO router = _routerDao.findBy(vm.getAccountId(), vm.getDataCenterId());
|
DomainRouterVO router = _routerDao.findBy(vm.getAccountId(), vm.getDataCenterIdToDeployIn());
|
||||||
if (router.getHostId() == vm.getHostId()) {
|
if (router.getHostId() == vm.getHostId()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -430,7 +430,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
final Transaction txn = Transaction.currentTxn();
|
final Transaction txn = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txn.start();
|
txn.start();
|
||||||
final UserStatisticsVO userStats = _userStatsDao.lock(router.getAccountId(), router.getDataCenterId(), router.getNetworkId(), null, router.getId(), router.getType().toString());
|
final UserStatisticsVO userStats = _userStatsDao.lock(router.getAccountId(), router.getDataCenterIdToDeployIn(), router.getNetworkId(), null, router.getId(), router.getType().toString());
|
||||||
if (userStats != null) {
|
if (userStats != null) {
|
||||||
final RebootAnswer sa = (RebootAnswer) answer;
|
final RebootAnswer sa = (RebootAnswer) answer;
|
||||||
final Long received = sa.getBytesReceived();
|
final Long received = sa.getBytesReceived();
|
||||||
@ -463,7 +463,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
_userStatsDao.update(userStats.getId(), userStats);
|
_userStatsDao.update(userStats.getId(), userStats);
|
||||||
s_logger.debug("Successfully updated user statistics as a part of domR " + router + " reboot/stop");
|
s_logger.debug("Successfully updated user statistics as a part of domR " + router + " reboot/stop");
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("User stats were not created for account " + router.getAccountId() + " and dc " + router.getDataCenterId());
|
s_logger.warn("User stats were not created for account " + router.getAccountId() + " and dc " + router.getDataCenterIdToDeployIn());
|
||||||
}
|
}
|
||||||
txn.commit();
|
txn.commit();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
@ -509,7 +509,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
// Can reboot domain router only in Running state
|
// Can reboot domain router only in Running state
|
||||||
if (router == null || router.getState() != State.Running) {
|
if (router == null || router.getState() != State.Running) {
|
||||||
s_logger.warn("Unable to reboot, virtual router is not in the right state " + router.getState());
|
s_logger.warn("Unable to reboot, virtual router is not in the right state " + router.getState());
|
||||||
throw new ResourceUnavailableException("Unable to reboot domR, it is not in right state " + router.getState(), DataCenter.class, router.getDataCenterId());
|
throw new ResourceUnavailableException("Unable to reboot domR, it is not in right state " + router.getState(), DataCenter.class, router.getDataCenterIdToDeployIn());
|
||||||
}
|
}
|
||||||
|
|
||||||
UserVO user = _userDao.findById(UserContext.current().getCallerUserId());
|
UserVO user = _userDao.findById(UserContext.current().getCallerUserId());
|
||||||
@ -651,7 +651,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
txn.start();
|
txn.start();
|
||||||
UserStatisticsVO stats = _statsDao.lock(router.getAccountId(), router.getDataCenterId(), router.getNetworkId(), null, router.getId(), router.getType().toString());
|
UserStatisticsVO stats = _statsDao.lock(router.getAccountId(), router.getDataCenterIdToDeployIn(), router.getNetworkId(), null, router.getId(), router.getType().toString());
|
||||||
if (stats == null) {
|
if (stats == null) {
|
||||||
s_logger.warn("unable to find stats for account: " + router.getAccountId());
|
s_logger.warn("unable to find stats for account: " + router.getAccountId());
|
||||||
continue;
|
continue;
|
||||||
@ -1042,7 +1042,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
s_logger.debug("Resending ipAssoc, port forwarding, load balancing rules as a part of Virtual router start");
|
s_logger.debug("Resending ipAssoc, port forwarding, load balancing rules as a part of Virtual router start");
|
||||||
long networkId = router.getNetworkId();
|
long networkId = router.getNetworkId();
|
||||||
long ownerId = router.getAccountId();
|
long ownerId = router.getAccountId();
|
||||||
long zoneId = router.getDataCenterId();
|
long zoneId = router.getDataCenterIdToDeployIn();
|
||||||
|
|
||||||
final List<IPAddressVO> userIps = _networkMgr.listPublicIpAddressesInVirtualNetwork(ownerId, zoneId, null, null);
|
final List<IPAddressVO> userIps = _networkMgr.listPublicIpAddressesInVirtualNetwork(ownerId, zoneId, null, null);
|
||||||
List<PublicIpAddress> publicIps = new ArrayList<PublicIpAddress>();
|
List<PublicIpAddress> publicIps = new ArrayList<PublicIpAddress>();
|
||||||
@ -1176,17 +1176,17 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
}
|
}
|
||||||
Answer answer = cmds.getAnswer("users");
|
Answer answer = cmds.getAnswer("users");
|
||||||
if (!answer.getResult()) {
|
if (!answer.getResult()) {
|
||||||
s_logger.error("Unable to start vpn: unable add users to vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName()
|
s_logger.error("Unable to start vpn: unable add users to vpn in zone " + router.getDataCenterIdToDeployIn() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName()
|
||||||
+ " due to " + answer.getDetails());
|
+ " due to " + answer.getDetails());
|
||||||
throw new ResourceUnavailableException("Unable to start vpn: Unable to add users to vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: "
|
throw new ResourceUnavailableException("Unable to start vpn: Unable to add users to vpn in zone " + router.getDataCenterIdToDeployIn() + " for account " + vpn.getAccountId() + " on domR: "
|
||||||
+ router.getInstanceName() + " due to " + answer.getDetails(), DataCenter.class, router.getDataCenterId());
|
+ router.getInstanceName() + " due to " + answer.getDetails(), DataCenter.class, router.getDataCenterIdToDeployIn());
|
||||||
}
|
}
|
||||||
answer = cmds.getAnswer("startVpn");
|
answer = cmds.getAnswer("startVpn");
|
||||||
if (!answer.getResult()) {
|
if (!answer.getResult()) {
|
||||||
s_logger.error("Unable to start vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName() + " due to "
|
s_logger.error("Unable to start vpn in zone " + router.getDataCenterIdToDeployIn() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName() + " due to "
|
||||||
+ answer.getDetails());
|
+ answer.getDetails());
|
||||||
throw new ResourceUnavailableException("Unable to start vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName()
|
throw new ResourceUnavailableException("Unable to start vpn in zone " + router.getDataCenterIdToDeployIn() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName()
|
||||||
+ " due to " + answer.getDetails(), DataCenter.class, router.getDataCenterId());
|
+ " due to " + answer.getDetails(), DataCenter.class, router.getDataCenterIdToDeployIn());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1291,19 +1291,19 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
Answer answer = cmds.getAnswer("dhcp");
|
Answer answer = cmds.getAnswer("dhcp");
|
||||||
if (!answer.getResult()) {
|
if (!answer.getResult()) {
|
||||||
s_logger.error("Unable to set dhcp entry for " + profile + " on domR: " + router.getHostName() + " due to " + answer.getDetails());
|
s_logger.error("Unable to set dhcp entry for " + profile + " on domR: " + router.getHostName() + " due to " + answer.getDetails());
|
||||||
throw new ResourceUnavailableException("Unable to set dhcp entry for " + profile + " due to " + answer.getDetails(), DataCenter.class, router.getDataCenterId());
|
throw new ResourceUnavailableException("Unable to set dhcp entry for " + profile + " due to " + answer.getDetails(), DataCenter.class, router.getDataCenterIdToDeployIn());
|
||||||
}
|
}
|
||||||
|
|
||||||
answer = cmds.getAnswer("password");
|
answer = cmds.getAnswer("password");
|
||||||
if (answer != null && !answer.getResult()) {
|
if (answer != null && !answer.getResult()) {
|
||||||
s_logger.error("Unable to set password for " + profile + " due to " + answer.getDetails());
|
s_logger.error("Unable to set password for " + profile + " due to " + answer.getDetails());
|
||||||
throw new ResourceUnavailableException("Unable to set password due to " + answer.getDetails(), DataCenter.class, router.getDataCenterId());
|
throw new ResourceUnavailableException("Unable to set password due to " + answer.getDetails(), DataCenter.class, router.getDataCenterIdToDeployIn());
|
||||||
}
|
}
|
||||||
|
|
||||||
answer = cmds.getAnswer("vmdata");
|
answer = cmds.getAnswer("vmdata");
|
||||||
if (answer != null && !answer.getResult()) {
|
if (answer != null && !answer.getResult()) {
|
||||||
s_logger.error("Unable to set VM data for " + profile + " due to " + answer.getDetails());
|
s_logger.error("Unable to set VM data for " + profile + " due to " + answer.getDetails());
|
||||||
throw new ResourceUnavailableException("Unable to set VM data due to " + answer.getDetails(), DataCenter.class, router.getDataCenterId());
|
throw new ResourceUnavailableException("Unable to set VM data due to " + answer.getDetails(), DataCenter.class, router.getDataCenterIdToDeployIn());
|
||||||
}
|
}
|
||||||
return router;
|
return router;
|
||||||
}
|
}
|
||||||
@ -1386,10 +1386,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
Account owner = _accountMgr.getAccount(router.getAccountId());
|
Account owner = _accountMgr.getAccount(router.getAccountId());
|
||||||
|
|
||||||
// Check if all networks are implemented for the domR; if not - implement them
|
// Check if all networks are implemented for the domR; if not - implement them
|
||||||
DataCenter dc = _dcDao.findById(router.getDataCenterId());
|
DataCenter dc = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||||
HostPodVO pod = null;
|
HostPodVO pod = null;
|
||||||
if (router.getPodId() != null) {
|
if (router.getPodIdToDeployIn() != null) {
|
||||||
pod = _podDao.findById(router.getPodId());
|
pod = _podDao.findById(router.getPodIdToDeployIn());
|
||||||
}
|
}
|
||||||
DeployDestination dest = new DeployDestination(dc, pod, null, null);
|
DeployDestination dest = new DeployDestination(dc, pod, null, null);
|
||||||
|
|
||||||
@ -1560,7 +1560,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
if (nic != null) {
|
if (nic != null) {
|
||||||
s_logger.debug("Creating user data entry for vm " + vm + " on domR " + router);
|
s_logger.debug("Creating user data entry for vm " + vm + " on domR " + router);
|
||||||
String serviceOffering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getServiceOfferingId()).getDisplayText();
|
String serviceOffering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getServiceOfferingId()).getDisplayText();
|
||||||
String zoneName = _dcDao.findById(router.getDataCenterId()).getName();
|
String zoneName = _dcDao.findById(router.getDataCenterIdToDeployIn()).getName();
|
||||||
cmds.addCommand("vmdata",
|
cmds.addCommand("vmdata",
|
||||||
generateVmDataCommand(router, nic.getIp4Address(), vm.getUserData(), serviceOffering, zoneName, nic.getIp4Address(), vm.getHostName(), vm.getInstanceName(), vm.getId(), null));
|
generateVmDataCommand(router, nic.getIp4Address(), vm.getUserData(), serviceOffering, zoneName, nic.getIp4Address(), vm.getHostName(), vm.getInstanceName(), vm.getId(), null));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -164,7 +164,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate that userVM is in the same availability zone as the IP address
|
// validate that userVM is in the same availability zone as the IP address
|
||||||
if (ipAddress.getDataCenterId() != userVm.getDataCenterId()) {
|
if (ipAddress.getDataCenterId() != userVm.getDataCenterIdToDeployIn()) {
|
||||||
throw new InvalidParameterValueException("Unable to create ip forwarding rule, IP address " + ipAddress + " is not in the same availability zone as virtual machine " + userVm.toString());
|
throw new InvalidParameterValueException("Unable to create ip forwarding rule, IP address " + ipAddress + " is not in the same availability zone as virtual machine " + userVm.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -525,7 +525,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||||||
}
|
}
|
||||||
_accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), host.getDataCenterId());
|
_accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), host.getDataCenterId());
|
||||||
if (Host.Type.SecondaryStorage.equals(host.getType())) {
|
if (Host.Type.SecondaryStorage.equals(host.getType())) {
|
||||||
return _secondaryStorageMgr.destroySecStorageVm(hostId);
|
_secondaryStorageMgr.deleteHost(hostId);
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return _agentMgr.deleteHost(hostId, isForced, caller);
|
return _agentMgr.deleteHost(hostId, isForced, caller);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -771,7 +771,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
DataCenterVO dc = iter.next();
|
DataCenterVO dc = iter.next();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (DomainRouterVO router : routers) {
|
for (DomainRouterVO router : routers) {
|
||||||
if (dc.getId() == router.getDataCenterId()) {
|
if (dc.getId() == router.getDataCenterIdToDeployIn()) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1011,12 +1011,18 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
// if a domainId is provided, we just return the so associated with this domain
|
// if a domainId is provided, we just return the so associated with this domain
|
||||||
if (domainId != null) {
|
if (domainId != null) {
|
||||||
if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
|
if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
|
||||||
|
if (account.getDomainId() != 1 && issystem){ //NON ROOT admin
|
||||||
|
throw new InvalidParameterValueException("Non ROOT admins cannot access system's offering");
|
||||||
|
}
|
||||||
return _offeringsDao.findServiceOfferingByDomainIdAndIsSystem(domainId, issystem);// no perm check
|
return _offeringsDao.findServiceOfferingByDomainIdAndIsSystem(domainId, issystem);// no perm check
|
||||||
} else {
|
} else {
|
||||||
|
if (issystem){
|
||||||
|
throw new InvalidParameterValueException("Non root users cannot access system's offering");
|
||||||
|
}
|
||||||
// check if the user's domain == so's domain || user's domain is a child of so's domain
|
// check if the user's domain == so's domain || user's domain is a child of so's domain
|
||||||
if (isPermissible(account.getDomainId(), domainId)) {
|
if (isPermissible(account.getDomainId(), domainId)) {
|
||||||
// perm check succeeded
|
// perm check succeeded
|
||||||
return _offeringsDao.findServiceOfferingByDomainId(domainId);
|
return _offeringsDao.findServiceOfferingByDomainIdAndIsSystem(domainId, false);
|
||||||
} else {
|
} else {
|
||||||
throw new PermissionDeniedException("The account:" + account.getAccountName() + " does not fall in the same domain hierarchy as the service offering");
|
throw new PermissionDeniedException("The account:" + account.getAccountName() + " does not fall in the same domain hierarchy as the service offering");
|
||||||
}
|
}
|
||||||
@ -1025,10 +1031,17 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
|
|
||||||
// For non-root users
|
// For non-root users
|
||||||
if ((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
|
if ((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
|
||||||
|
if (issystem){
|
||||||
|
throw new InvalidParameterValueException("Only root admins can access system's offering");
|
||||||
|
}
|
||||||
return searchServiceOfferingsInternal(account, name, id, vmId, keyword, searchFilter);
|
return searchServiceOfferingsInternal(account, name, id, vmId, keyword, searchFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for root users, the existing flow
|
// for root users, the existing flow
|
||||||
|
if (account.getDomainId() != 1 && issystem){ //NON ROOT admin
|
||||||
|
throw new InvalidParameterValueException("Non ROOT admins cannot access system's offering");
|
||||||
|
}
|
||||||
|
|
||||||
if (keyword != null) {
|
if (keyword != null) {
|
||||||
SearchCriteria<ServiceOfferingVO> ssc = _offeringsDao.createSearchCriteria();
|
SearchCriteria<ServiceOfferingVO> ssc = _offeringsDao.createSearchCriteria();
|
||||||
ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||||
@ -1061,7 +1074,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
if (name != null) {
|
if (name != null) {
|
||||||
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
|
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
|
||||||
}
|
}
|
||||||
sc.addAnd("systemUse", SearchCriteria.Op.EQ, false);
|
sc.addAnd("systemUse", SearchCriteria.Op.EQ, issystem);
|
||||||
|
|
||||||
return _offeringsDao.search(sc, searchFilter);
|
return _offeringsDao.search(sc, searchFilter);
|
||||||
|
|
||||||
@ -1307,7 +1320,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
|
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
|
||||||
}
|
}
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
sc.addAnd("type", SearchCriteria.Op.LIKE, "%" + type + "%");
|
sc.addAnd("type", SearchCriteria.Op.LIKE, "%" + type);
|
||||||
}
|
}
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
sc.addAnd("status", SearchCriteria.Op.EQ, state);
|
sc.addAnd("status", SearchCriteria.Op.EQ, state);
|
||||||
@ -1611,7 +1624,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
|
|
||||||
HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
|
HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
|
||||||
return listTemplates(cmd.getId(), cmd.getIsoName(), cmd.getKeyword(), isoFilter, true, cmd.isBootable(), accountId, cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), hypervisorType,
|
return listTemplates(cmd.getId(), cmd.getIsoName(), cmd.getKeyword(), isoFilter, true, cmd.isBootable(), accountId, cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), hypervisorType,
|
||||||
isAccountSpecific, true);
|
isAccountSpecific, true, cmd.listInReadyState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1633,11 +1646,11 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
|
HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
|
||||||
|
|
||||||
return listTemplates(cmd.getId(), cmd.getTemplateName(), cmd.getKeyword(), templateFilter, false, null, accountId, cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), hypervisorType,
|
return listTemplates(cmd.getId(), cmd.getTemplateName(), cmd.getKeyword(), templateFilter, false, null, accountId, cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), hypervisorType,
|
||||||
isAccountSpecific, showDomr);
|
isAccountSpecific, showDomr, cmd.listInReadyState());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Pair<Long, Long>> listTemplates(Long templateId, String name, String keyword, TemplateFilter templateFilter, boolean isIso, Boolean bootable, Long accountId, Long pageSize,
|
private Set<Pair<Long, Long>> listTemplates(Long templateId, String name, String keyword, TemplateFilter templateFilter, boolean isIso, Boolean bootable, Long accountId, Long pageSize,
|
||||||
Long startIndex, Long zoneId, HypervisorType hyperType, boolean isAccountSpecific, boolean showDomr) {
|
Long startIndex, Long zoneId, HypervisorType hyperType, boolean isAccountSpecific, boolean showDomr, boolean onlyReady) {
|
||||||
|
|
||||||
Account caller = UserContext.current().getCaller();
|
Account caller = UserContext.current().getCaller();
|
||||||
VMTemplateVO template = null;
|
VMTemplateVO template = null;
|
||||||
@ -1656,10 +1669,6 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show only those that are downloaded.
|
|
||||||
boolean onlyReady = (templateFilter == TemplateFilter.featured) || (templateFilter == TemplateFilter.selfexecutable) || (templateFilter == TemplateFilter.sharedexecutable)
|
|
||||||
|| (templateFilter == TemplateFilter.executable && isAccountSpecific) || (templateFilter == TemplateFilter.community);
|
|
||||||
|
|
||||||
Account account = null;
|
Account account = null;
|
||||||
DomainVO domain = null;
|
DomainVO domain = null;
|
||||||
if (accountId != null) {
|
if (accountId != null) {
|
||||||
@ -2185,8 +2194,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||||
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.IN);
|
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.IN);
|
||||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||||
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
sb.and("dataCenterId", sb.entity().getDataCenterIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
|
sb.and("podId", sb.entity().getPodIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ);
|
sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||||
|
|
||||||
if ((accountId == null) && (domainId != null)) {
|
if ((accountId == null) && (domainId != null)) {
|
||||||
@ -2745,7 +2754,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
public String getConsoleAccessUrlRoot(long vmId) {
|
public String getConsoleAccessUrlRoot(long vmId) {
|
||||||
VMInstanceVO vm = this.findVMInstanceById(vmId);
|
VMInstanceVO vm = this.findVMInstanceById(vmId);
|
||||||
if (vm != null) {
|
if (vm != null) {
|
||||||
ConsoleProxyInfo proxy = getConsoleProxy(vm.getDataCenterId(), vmId);
|
ConsoleProxyInfo proxy = getConsoleProxy(vm.getDataCenterIdToDeployIn(), vmId);
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
return proxy.getProxyImageUrl();
|
return proxy.getProxyImageUrl();
|
||||||
}
|
}
|
||||||
@ -3914,8 +3923,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||||
sb.and("name", sb.entity().getHostName(), SearchCriteria.Op.LIKE);
|
sb.and("name", sb.entity().getHostName(), SearchCriteria.Op.LIKE);
|
||||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||||
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
sb.and("dataCenterId", sb.entity().getDataCenterIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
|
sb.and("podId", sb.entity().getPodIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ);
|
sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||||
sb.and("type", sb.entity().getType(), SearchCriteria.Op.EQ);
|
sb.and("type", sb.entity().getType(), SearchCriteria.Op.EQ);
|
||||||
sb.and("nulltype", sb.entity().getType(), SearchCriteria.Op.IN);
|
sb.and("nulltype", sb.entity().getType(), SearchCriteria.Op.IN);
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.cloud.servlet;
|
package com.cloud.servlet;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
@ -86,6 +87,7 @@ public class RegisterCompleteServlet extends HttpServlet implements ServletConte
|
|||||||
statusCode = 503;
|
statusCode = 503;
|
||||||
responseMessage = "{ \"registration_info\" : { \"errorcode\" : \"503\", \"errortext\" : \"Missing token\" } }";
|
responseMessage = "{ \"registration_info\" : { \"errorcode\" : \"503\", \"errortext\" : \"Missing token\" } }";
|
||||||
} else {
|
} else {
|
||||||
|
s_logger.info("Attempting to register user account with token = "+registrationToken);
|
||||||
User resourceAdminUser = _accountSvc.getActiveUserByRegistrationToken(registrationToken);
|
User resourceAdminUser = _accountSvc.getActiveUserByRegistrationToken(registrationToken);
|
||||||
if (resourceAdminUser != null) {
|
if (resourceAdminUser != null) {
|
||||||
if(!resourceAdminUser.isRegistered()){
|
if(!resourceAdminUser.isRegistered()){
|
||||||
@ -101,12 +103,12 @@ public class RegisterCompleteServlet extends HttpServlet implements ServletConte
|
|||||||
Configuration config = _configDao.findByName("endpointe.url");
|
Configuration config = _configDao.findByName("endpointe.url");
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append("{ \"registration_info\" : { \"endpoint_url\" : \""+config.getValue()+"\", ");
|
sb.append("{ \"registration_info\" : { \"endpoint_url\" : \""+encodeParam(config.getValue())+"\", ");
|
||||||
sb.append("\"domain_id\" : \""+resourceAdminAccount.getDomainId()+"\", ");
|
sb.append("\"domain_id\" : \""+resourceAdminAccount.getDomainId()+"\", ");
|
||||||
sb.append("\"admin_account\" : \""+resourceAdminUser.getUsername()+"\", ");
|
sb.append("\"admin_account\" : \""+encodeParam(resourceAdminUser.getUsername())+"\", ");
|
||||||
sb.append("\"admin_account_api_key\" : \""+resourceAdminUser.getApiKey()+"\", ");
|
sb.append("\"admin_account_api_key\" : \""+resourceAdminUser.getApiKey()+"\", ");
|
||||||
sb.append("\"admin_account_secret_key\" : \""+resourceAdminUser.getSecretKey()+"\", ");
|
sb.append("\"admin_account_secret_key\" : \""+resourceAdminUser.getSecretKey()+"\", ");
|
||||||
sb.append("\"user_account\" : \""+rsUser.getUsername()+"\", ");
|
sb.append("\"user_account\" : \""+encodeParam(rsUser.getUsername())+"\", ");
|
||||||
sb.append("\"user_account_api_key\" : \""+rsUser.getApiKey()+"\", ");
|
sb.append("\"user_account_api_key\" : \""+rsUser.getApiKey()+"\", ");
|
||||||
sb.append("\"user_account_secret_key\" : \""+rsUser.getSecretKey()+"\" ");
|
sb.append("\"user_account_secret_key\" : \""+rsUser.getSecretKey()+"\" ");
|
||||||
sb.append("} }");
|
sb.append("} }");
|
||||||
@ -125,4 +127,13 @@ public class RegisterCompleteServlet extends HttpServlet implements ServletConte
|
|||||||
s_logger.error("unknown exception writing register complete response", ex);
|
s_logger.error("unknown exception writing register complete response", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String encodeParam(String value) {
|
||||||
|
try {
|
||||||
|
return URLEncoder.encode(value, "UTF-8").replaceAll("\\+", "%20");
|
||||||
|
} catch (Exception e) {
|
||||||
|
s_logger.warn("Unable to encode: " + value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -195,5 +195,9 @@ public interface StorageManager extends Manager {
|
|||||||
|
|
||||||
boolean delPoolFromHost(long hostId);
|
boolean delPoolFromHost(long hostId);
|
||||||
|
|
||||||
HostVO getSecondaryStorageHost(long zoneId, long tmpltId);
|
HostVO getSecondaryStorageHost(long zoneId, long tmpltId);
|
||||||
|
|
||||||
|
List<HostVO> getSecondaryStorageHosts(long zoneId);
|
||||||
|
|
||||||
|
List<StoragePoolVO> ListByDataCenterHypervisor(long datacenterId, HypervisorType type);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -298,7 +298,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||||||
protected int _pingInterval = 60; // seconds
|
protected int _pingInterval = 60; // seconds
|
||||||
protected int _hostRetry;
|
protected int _hostRetry;
|
||||||
protected float _overProvisioningFactor = 1;
|
protected float _overProvisioningFactor = 1;
|
||||||
private int _maxVolumeSizeInGb;
|
private long _maxVolumeSizeInGb;
|
||||||
private long _serverId;
|
private long _serverId;
|
||||||
|
|
||||||
private int _snapshotTimeout;
|
private int _snapshotTimeout;
|
||||||
@ -353,6 +353,23 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StoragePoolVO> ListByDataCenterHypervisor(long datacenterId, HypervisorType type) {
|
||||||
|
List<StoragePoolVO> pools = _storagePoolDao.listByDataCenterId(datacenterId);
|
||||||
|
List<StoragePoolVO> retPools = new ArrayList<StoragePoolVO>();
|
||||||
|
for (StoragePoolVO pool : pools ) {
|
||||||
|
if( pool.getStatus() != StoragePoolStatus.Up) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ClusterVO cluster = _clusterDao.findById(pool.getClusterId());
|
||||||
|
if( type == cluster.getHypervisorType()) {
|
||||||
|
retPools.add(pool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.shuffle(retPools);
|
||||||
|
return retPools;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLocalStorageActiveOnHost(Host host) {
|
public boolean isLocalStorageActiveOnHost(Host host) {
|
||||||
@ -834,7 +851,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||||||
}
|
}
|
||||||
|
|
||||||
String maxVolumeSizeInGbString = configDao.getValue("storage.max.volume.size");
|
String maxVolumeSizeInGbString = configDao.getValue("storage.max.volume.size");
|
||||||
_maxVolumeSizeInGb = NumbersUtil.parseInt(maxVolumeSizeInGbString, 2000);
|
_maxVolumeSizeInGb = NumbersUtil.parseLong(maxVolumeSizeInGbString, 2000);
|
||||||
|
|
||||||
HostTemplateStatesSearch = _vmTemplateHostDao.createSearchBuilder();
|
HostTemplateStatesSearch = _vmTemplateHostDao.createSearchBuilder();
|
||||||
HostTemplateStatesSearch.and("id", HostTemplateStatesSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
HostTemplateStatesSearch.and("id", HostTemplateStatesSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
||||||
@ -970,6 +987,18 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||||||
int index = rn.nextInt(size);
|
int index = rn.nextInt(size);
|
||||||
return hosts.get(index);
|
return hosts.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HostVO> getSecondaryStorageHosts(long zoneId) {
|
||||||
|
List<HostVO> hosts = _hostDao.listSecondaryStorageHosts(zoneId);
|
||||||
|
if( hosts == null || hosts.size() == 0) {
|
||||||
|
hosts = _hostDao.listLocalSecondaryStorageHosts(zoneId);
|
||||||
|
if (hosts.isEmpty()) {
|
||||||
|
return new ArrayList<HostVO>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hosts;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStoragePoolTags(long poolId) {
|
public String getStoragePoolTags(long poolId) {
|
||||||
@ -1582,7 +1611,14 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||||||
}
|
}
|
||||||
|
|
||||||
diskOfferingId = cmd.getDiskOfferingId();
|
diskOfferingId = cmd.getDiskOfferingId();
|
||||||
size = cmd.getSize() * 1024 * 1024 * 1024; // user specify size in GB
|
size = cmd.getSize();
|
||||||
|
if ( size != null ) {
|
||||||
|
if ( size > 0 ) {
|
||||||
|
size = size * 1024 * 1024 * 1024; // user specify size in GB
|
||||||
|
} else {
|
||||||
|
throw new InvalidParameterValueException("Disk size must be larger than 0");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (diskOfferingId == null) {
|
if (diskOfferingId == null) {
|
||||||
throw new InvalidParameterValueException("Missing parameter(s),either a positive volume size or a valid disk offering id must be specified.");
|
throw new InvalidParameterValueException("Missing parameter(s),either a positive volume size or a valid disk offering id must be specified.");
|
||||||
}
|
}
|
||||||
@ -2410,8 +2446,8 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||||||
private boolean validateVolumeSizeRange(long size) {
|
private boolean validateVolumeSizeRange(long size) {
|
||||||
if (size < 0 || (size > 0 && size < (1024 * 1024 * 1024))) {
|
if (size < 0 || (size > 0 && size < (1024 * 1024 * 1024))) {
|
||||||
throw new InvalidParameterValueException("Please specify a size of at least 1 Gb.");
|
throw new InvalidParameterValueException("Please specify a size of at least 1 Gb.");
|
||||||
} else if (size > _maxVolumeSizeInGb) {
|
} else if (size > (_maxVolumeSizeInGb * 1024 * 1024 * 1024) ) {
|
||||||
throw new InvalidParameterValueException("The maximum size allowed is " + _maxVolumeSizeInGb + " Gb.");
|
throw new InvalidParameterValueException("volume size " + size + ", but the maximum size allowed is " + _maxVolumeSizeInGb + " Gb.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -2429,7 +2465,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||||||
} else {
|
} else {
|
||||||
size = (size * 1024 * 1024 * 1024);
|
size = (size * 1024 * 1024 * 1024);
|
||||||
}
|
}
|
||||||
VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), size);
|
VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterIdToDeployIn(), owner.getDomainId(), owner.getId(), offering.getId(), size);
|
||||||
if (vm != null) {
|
if (vm != null) {
|
||||||
vol.setInstanceId(vm.getId());
|
vol.setInstanceId(vm.getId());
|
||||||
}
|
}
|
||||||
@ -2460,15 +2496,15 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||||||
SearchCriteria<VMTemplateHostVO> sc = HostTemplateStatesSearch.create();
|
SearchCriteria<VMTemplateHostVO> sc = HostTemplateStatesSearch.create();
|
||||||
sc.setParameters("id", template.getId());
|
sc.setParameters("id", template.getId());
|
||||||
sc.setParameters("state", com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
|
sc.setParameters("state", com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
|
||||||
sc.setJoinParameters("host", "dcId", vm.getDataCenterId());
|
sc.setJoinParameters("host", "dcId", vm.getDataCenterIdToDeployIn());
|
||||||
|
|
||||||
List<VMTemplateHostVO> sss = _vmTemplateHostDao.search(sc, null);
|
List<VMTemplateHostVO> sss = _vmTemplateHostDao.search(sc, null);
|
||||||
if (sss.size() == 0) {
|
if (sss.size() == 0) {
|
||||||
throw new CloudRuntimeException("Template " + template.getName() + " has not been completely downloaded to zone " + vm.getDataCenterId());
|
throw new CloudRuntimeException("Template " + template.getName() + " has not been completely downloaded to zone " + vm.getDataCenterIdToDeployIn());
|
||||||
}
|
}
|
||||||
VMTemplateHostVO ss = sss.get(0);
|
VMTemplateHostVO ss = sss.get(0);
|
||||||
|
|
||||||
VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), ss.getSize());
|
VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterIdToDeployIn(), owner.getDomainId(), owner.getId(), offering.getId(), ss.getSize());
|
||||||
if (vm != null) {
|
if (vm != null) {
|
||||||
vol.setInstanceId(vm.getId());
|
vol.setInstanceId(vm.getId());
|
||||||
}
|
}
|
||||||
@ -2518,7 +2554,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||||||
if (vm.getType() == VirtualMachine.Type.User) {
|
if (vm.getType() == VirtualMachine.Type.User) {
|
||||||
UserVmVO userVM = (UserVmVO) vm.getVirtualMachine();
|
UserVmVO userVM = (UserVmVO) vm.getVirtualMachine();
|
||||||
if (userVM.getIsoId() != null) {
|
if (userVM.getIsoId() != null) {
|
||||||
Pair<String, String> isoPathPair = getAbsoluteIsoPath(userVM.getIsoId(), userVM.getDataCenterId());
|
Pair<String, String> isoPathPair = getAbsoluteIsoPath(userVM.getIsoId(), userVM.getDataCenterIdToDeployIn());
|
||||||
if (isoPathPair != null) {
|
if (isoPathPair != null) {
|
||||||
String isoPath = isoPathPair.first();
|
String isoPath = isoPathPair.first();
|
||||||
VolumeTO iso = new VolumeTO(vm.getId(), Volume.Type.ISO, StoragePoolType.ISO, null, null, null, isoPath, 0, null, null);
|
VolumeTO iso = new VolumeTO(vm.getId(), Volume.Type.ISO, StoragePoolType.ISO, null, null, null, isoPath, 0, null, null);
|
||||||
|
|||||||
@ -37,5 +37,7 @@ public interface SnapshotDao extends GenericDao<SnapshotVO, Long> {
|
|||||||
List<SnapshotVO> listByVolumeIdVersion(long volumeId, String version);
|
List<SnapshotVO> listByVolumeIdVersion(long volumeId, String version);
|
||||||
Long getSecHostId(long volumeId);
|
Long getSecHostId(long volumeId);
|
||||||
long updateSnapshotSecHost(long dcId, long secHostId);
|
long updateSnapshotSecHost(long dcId, long secHostId);
|
||||||
|
List<SnapshotVO> listByHostId(Filter filter, long hostId);
|
||||||
|
List<SnapshotVO> listByHostId(long hostId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import com.cloud.storage.SnapshotVO;
|
import com.cloud.storage.SnapshotVO;
|
||||||
import com.cloud.storage.Snapshot.Type;
|
import com.cloud.storage.Snapshot.Type;
|
||||||
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
@ -47,6 +48,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
|
|||||||
private final SearchBuilder<SnapshotVO> ParentIdSearch;
|
private final SearchBuilder<SnapshotVO> ParentIdSearch;
|
||||||
private final SearchBuilder<SnapshotVO> backupUuidSearch;
|
private final SearchBuilder<SnapshotVO> backupUuidSearch;
|
||||||
private final SearchBuilder<SnapshotVO> VolumeIdVersionSearch;
|
private final SearchBuilder<SnapshotVO> VolumeIdVersionSearch;
|
||||||
|
private final SearchBuilder<SnapshotVO> HostIdSearch;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SnapshotVO findNextSnapshot(long snapshotId) {
|
public SnapshotVO findNextSnapshot(long snapshotId) {
|
||||||
@ -85,6 +87,19 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
|
|||||||
return listBy(sc, filter);
|
return listBy(sc, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SnapshotVO> listByHostId(long hostId) {
|
||||||
|
return listByHostId(null, hostId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SnapshotVO> listByHostId(Filter filter, long hostId ) {
|
||||||
|
SearchCriteria<SnapshotVO> sc = HostIdSearch.create();
|
||||||
|
sc.setParameters("hostId", hostId);
|
||||||
|
sc.setParameters("status", Status.DOWNLOADED);
|
||||||
|
return listBy(sc, filter);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SnapshotVO> listByVolumeIdIncludingRemoved(long volumeId) {
|
public List<SnapshotVO> listByVolumeIdIncludingRemoved(long volumeId) {
|
||||||
SearchCriteria<SnapshotVO> sc = VolumeIdSearch.create();
|
SearchCriteria<SnapshotVO> sc = VolumeIdSearch.create();
|
||||||
@ -111,6 +126,11 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
|
|||||||
VolumeIdSearch.and("volumeId", VolumeIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
VolumeIdSearch.and("volumeId", VolumeIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
||||||
VolumeIdSearch.done();
|
VolumeIdSearch.done();
|
||||||
|
|
||||||
|
HostIdSearch = createSearchBuilder();
|
||||||
|
HostIdSearch.and("hostId", HostIdSearch.entity().getSecHostId(), SearchCriteria.Op.EQ);
|
||||||
|
HostIdSearch.and("status", HostIdSearch.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||||
|
HostIdSearch.done();
|
||||||
|
|
||||||
VolumeIdTypeSearch = createSearchBuilder();
|
VolumeIdTypeSearch = createSearchBuilder();
|
||||||
VolumeIdTypeSearch.and("volumeId", VolumeIdTypeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
VolumeIdTypeSearch.and("volumeId", VolumeIdTypeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
||||||
VolumeIdTypeSearch.and("type", VolumeIdTypeSearch.entity().getsnapshotType(), SearchCriteria.Op.EQ);
|
VolumeIdTypeSearch.and("type", VolumeIdTypeSearch.entity().getsnapshotType(), SearchCriteria.Op.EQ);
|
||||||
|
|||||||
@ -280,7 +280,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
|||||||
sql.delete(sql.length() - 4, sql.length());
|
sql.delete(sql.length() - 4, sql.length());
|
||||||
sql.append(DetailsSqlSuffix);
|
sql.append(DetailsSqlSuffix);
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
PreparedStatement pstmt = s_initStmt;
|
PreparedStatement pstmt = null;
|
||||||
try {
|
try {
|
||||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||||
int i = 1;
|
int i = 1;
|
||||||
@ -297,7 +297,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
|||||||
}
|
}
|
||||||
return pools;
|
return pools;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
|
throw new CloudRuntimeException("Unable to execute " + pstmt, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
|||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
tags.add(rs.getString("name"));
|
tags.add(rs.getString("name"));
|
||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
|
throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
|
||||||
|
|||||||
@ -71,5 +71,6 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long> {
|
|||||||
VMTemplateVO findSystemVMTemplate(long zoneId, HypervisorType hType);
|
VMTemplateVO findSystemVMTemplate(long zoneId, HypervisorType hType);
|
||||||
|
|
||||||
VMTemplateVO findRoutingTemplate(HypervisorType type);
|
VMTemplateVO findRoutingTemplate(HypervisorType type);
|
||||||
|
List<Long> listPrivateTemplatesByHost(Long hostId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,11 +21,13 @@ package com.cloud.storage.dao;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
@ -39,6 +41,7 @@ import com.cloud.host.HostVO;
|
|||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.hypervisor.Hypervisor;
|
import com.cloud.hypervisor.Hypervisor;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
|
import com.cloud.info.RunningHostCountInfo;
|
||||||
import com.cloud.storage.Storage;
|
import com.cloud.storage.Storage;
|
||||||
import com.cloud.storage.Storage.TemplateType;
|
import com.cloud.storage.Storage.TemplateType;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
@ -46,6 +49,7 @@ import com.cloud.storage.VMTemplateVO;
|
|||||||
import com.cloud.storage.VMTemplateZoneVO;
|
import com.cloud.storage.VMTemplateZoneVO;
|
||||||
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
|
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.utils.DateUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.Inject;
|
import com.cloud.utils.component.Inject;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
@ -139,6 +143,30 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
return listBy(sc, filter);
|
return listBy(sc, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Long> listPrivateTemplatesByHost(Long hostId) {
|
||||||
|
|
||||||
|
String sql = "select * from template_host_ref as thr INNER JOIN vm_template as t ON t.id=thr.template_id "
|
||||||
|
+ "where thr.host_id=? and t.public=0 and t.featured=0 and t.type='USER' and t.removed is NULL";
|
||||||
|
|
||||||
|
List<Long> l = new ArrayList<Long>();
|
||||||
|
|
||||||
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try {
|
||||||
|
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||||
|
pstmt.setLong(1, hostId);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
l.add(rs.getLong(1));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
} catch (Throwable e) {
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VMTemplateVO> listReadyTemplates() {
|
public List<VMTemplateVO> listReadyTemplates() {
|
||||||
SearchCriteria<VMTemplateVO> sc = createSearchCriteria();
|
SearchCriteria<VMTemplateVO> sc = createSearchCriteria();
|
||||||
|
|||||||
@ -56,6 +56,8 @@ public interface VMTemplateHostDao extends GenericDao<VMTemplateHostVO, Long> {
|
|||||||
|
|
||||||
boolean templateAvailable(long templateId, long hostId);
|
boolean templateAvailable(long templateId, long hostId);
|
||||||
|
|
||||||
List<VMTemplateHostVO> listByZoneTemplate(long dcId, long templateId);
|
List<VMTemplateHostVO> listByZoneTemplate(long dcId, long templateId, boolean readyOnly);
|
||||||
|
|
||||||
|
void deleteByHost(Long hostId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,15 +24,22 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.host.HostVO;
|
||||||
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
import com.cloud.utils.DateUtil;
|
import com.cloud.utils.DateUtil;
|
||||||
|
import com.cloud.utils.component.Inject;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
|
import com.cloud.utils.db.JoinBuilder;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
@ -40,7 +47,8 @@ import com.cloud.utils.db.Transaction;
|
|||||||
@Local(value={VMTemplateHostDao.class})
|
@Local(value={VMTemplateHostDao.class})
|
||||||
public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long> implements VMTemplateHostDao {
|
public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long> implements VMTemplateHostDao {
|
||||||
public static final Logger s_logger = Logger.getLogger(VMTemplateHostDaoImpl.class.getName());
|
public static final Logger s_logger = Logger.getLogger(VMTemplateHostDaoImpl.class.getName());
|
||||||
|
@Inject
|
||||||
|
HostDao _hostDao;
|
||||||
protected final SearchBuilder<VMTemplateHostVO> HostSearch;
|
protected final SearchBuilder<VMTemplateHostVO> HostSearch;
|
||||||
protected final SearchBuilder<VMTemplateHostVO> TemplateSearch;
|
protected final SearchBuilder<VMTemplateHostVO> TemplateSearch;
|
||||||
protected final SearchBuilder<VMTemplateHostVO> HostTemplateSearch;
|
protected final SearchBuilder<VMTemplateHostVO> HostTemplateSearch;
|
||||||
@ -49,10 +57,11 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
|||||||
protected final SearchBuilder<VMTemplateHostVO> HostTemplatePoolSearch;
|
protected final SearchBuilder<VMTemplateHostVO> HostTemplatePoolSearch;
|
||||||
protected final SearchBuilder<VMTemplateHostVO> TemplateStatusSearch;
|
protected final SearchBuilder<VMTemplateHostVO> TemplateStatusSearch;
|
||||||
protected final SearchBuilder<VMTemplateHostVO> TemplateStatesSearch;
|
protected final SearchBuilder<VMTemplateHostVO> TemplateStatesSearch;
|
||||||
|
protected SearchBuilder<VMTemplateHostVO> ZONE_TEMPLATE_SEARCH;
|
||||||
|
|
||||||
|
|
||||||
protected static final String UPDATE_TEMPLATE_HOST_REF =
|
protected static final String UPDATE_TEMPLATE_HOST_REF =
|
||||||
"UPDATE type_host_ref SET download_state = ?, download_pct= ?, last_updated = ? "
|
"UPDATE template_host_ref SET download_state = ?, download_pct= ?, last_updated = ? "
|
||||||
+ ", error_str = ?, local_path = ?, job_id = ? "
|
+ ", error_str = ?, local_path = ?, job_id = ? "
|
||||||
+ "WHERE host_id = ? and type_id = ?";
|
+ "WHERE host_id = ? and type_id = ?";
|
||||||
|
|
||||||
@ -71,12 +80,6 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
|||||||
"SELECT * FROM template_host_ref t "
|
"SELECT * FROM template_host_ref t "
|
||||||
+ " where t.template_id=? and t.download_state=?";
|
+ " where t.template_id=? and t.download_state=?";
|
||||||
|
|
||||||
protected static final String ZONE_TEMPLATE_SEARCH=
|
|
||||||
"SELECT t.id, t.host_id, t.pool_id, t.template_id, t.created, t.last_updated, t.job_id, "
|
|
||||||
+ "t.download_pct, t.size, t.physical_size, t.download_state, t.error_str, t.local_path, "
|
|
||||||
+ "t.install_path, t.url, t.destroyed, t.is_copy FROM template_host_ref t, host h"
|
|
||||||
+ " where t.host_id = h.id and h.data_center_id=? and t.template_id=? ";
|
|
||||||
|
|
||||||
public VMTemplateHostDaoImpl () {
|
public VMTemplateHostDaoImpl () {
|
||||||
HostSearch = createSearchBuilder();
|
HostSearch = createSearchBuilder();
|
||||||
HostSearch.and("host_id", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
HostSearch.and("host_id", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||||
@ -116,9 +119,21 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
|||||||
PoolTemplateSearch = createSearchBuilder();
|
PoolTemplateSearch = createSearchBuilder();
|
||||||
PoolTemplateSearch.and("pool_id", PoolTemplateSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
PoolTemplateSearch.and("pool_id", PoolTemplateSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||||
PoolTemplateSearch.and("template_id", PoolTemplateSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
PoolTemplateSearch.and("template_id", PoolTemplateSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
||||||
PoolTemplateSearch.done();
|
PoolTemplateSearch.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
|
boolean result = super.configure(name, params);
|
||||||
|
ZONE_TEMPLATE_SEARCH = createSearchBuilder();
|
||||||
|
ZONE_TEMPLATE_SEARCH.and("template_id", ZONE_TEMPLATE_SEARCH.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
||||||
|
ZONE_TEMPLATE_SEARCH.and("state", ZONE_TEMPLATE_SEARCH.entity().getDownloadState(), SearchCriteria.Op.EQ);
|
||||||
|
SearchBuilder<HostVO> hostSearch = _hostDao.createSearchBuilder();
|
||||||
|
hostSearch.and("zone_id", hostSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||||
|
ZONE_TEMPLATE_SEARCH.join("tmplHost", hostSearch, hostSearch.entity().getId(), ZONE_TEMPLATE_SEARCH.entity().getHostId(), JoinBuilder.JoinType.INNER);
|
||||||
|
ZONE_TEMPLATE_SEARCH.done();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(VMTemplateHostVO instance) {
|
public void update(VMTemplateHostVO instance) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
@ -275,25 +290,18 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VMTemplateHostVO> listByZoneTemplate(long dcId, long templateId) {
|
public List<VMTemplateHostVO> listByZoneTemplate(long dcId, long templateId, boolean readyOnly) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
SearchCriteria<VMTemplateHostVO> sc = ZONE_TEMPLATE_SEARCH.create();
|
||||||
PreparedStatement pstmt = null;
|
sc.setParameters("template_id", templateId);
|
||||||
List<VMTemplateHostVO> result = new ArrayList<VMTemplateHostVO>();
|
sc.setJoinParameters("tmplHost", "zone_id", dcId);
|
||||||
try {
|
if (readyOnly) {
|
||||||
String sql = ZONE_TEMPLATE_SEARCH;
|
sc.setParameters("state", VMTemplateHostVO.Status.DOWNLOADED);
|
||||||
pstmt = txn.prepareStatement(sql);
|
List<VMTemplateHostVO> tmplHost = new ArrayList<VMTemplateHostVO>();
|
||||||
|
tmplHost.add(findOneBy(sc));
|
||||||
pstmt.setLong(1, dcId);
|
return tmplHost;
|
||||||
pstmt.setLong(2, templateId);
|
} else {
|
||||||
ResultSet rs = pstmt.executeQuery();
|
return listBy(sc);
|
||||||
while (rs.next()) {
|
|
||||||
result.add(toEntityBean(rs, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
s_logger.warn("Exception: ", e);
|
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -321,6 +329,14 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
|||||||
return findOneIncludingRemovedBy(sc);
|
return findOneIncludingRemovedBy(sc);
|
||||||
else
|
else
|
||||||
return lockOneRandomRow(sc, true);
|
return lockOneRandomRow(sc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByHost(Long hostId) {
|
||||||
|
List<VMTemplateHostVO> tmpltHosts = listByHostId(hostId);
|
||||||
|
for (VMTemplateHostVO tmpltHost : tmpltHosts ) {
|
||||||
|
remove(tmpltHost.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -535,11 +535,11 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
|||||||
if( tmplt.isPublicTemplate() || tmplt.isFeatured() ) {
|
if( tmplt.isPublicTemplate() || tmplt.isFeatured() ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<VMTemplateHostVO> tmpltHosts = _vmTemplateHostDao.listByZoneTemplate(dcId, tmplt.getId());
|
List<VMTemplateHostVO> tmpltHosts = _vmTemplateHostDao.listByZoneTemplate(dcId, tmplt.getId(), false);
|
||||||
for ( VMTemplateHostVO tmpltHost : tmpltHosts ) {
|
for ( VMTemplateHostVO tmpltHost : tmpltHosts ) {
|
||||||
if ( tmpltHost.getDownloadState() == Status.DOWNLOADED || tmpltHost.getDownloadState() == Status.DOWNLOAD_IN_PROGRESS) {
|
if ( tmpltHost.getDownloadState() == Status.DOWNLOADED || tmpltHost.getDownloadState() == Status.DOWNLOAD_IN_PROGRESS) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -659,6 +659,10 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
|||||||
if (toBeDownloaded.size() > 0) {
|
if (toBeDownloaded.size() > 0) {
|
||||||
/*Only download templates whose hypervirsor type is in the zone*/
|
/*Only download templates whose hypervirsor type is in the zone*/
|
||||||
List<HypervisorType> availHypers = _clusterDao.getAvailableHypervisorInZone(ssHost.getDataCenterId());
|
List<HypervisorType> availHypers = _clusterDao.getAvailableHypervisorInZone(ssHost.getDataCenterId());
|
||||||
|
if (availHypers.isEmpty()) {
|
||||||
|
/*This is for cloudzone, local secondary storage resource started before cluster created*/
|
||||||
|
availHypers.add(HypervisorType.KVM);
|
||||||
|
}
|
||||||
/* Baremetal need not to download any template */
|
/* Baremetal need not to download any template */
|
||||||
availHypers.remove(HypervisorType.BareMetal);
|
availHypers.remove(HypervisorType.BareMetal);
|
||||||
availHypers.add(HypervisorType.None); //bug 9809: resume ISO download.
|
availHypers.add(HypervisorType.None); //bug 9809: resume ISO download.
|
||||||
|
|||||||
@ -71,9 +71,11 @@ import com.cloud.network.Networks.TrafficType;
|
|||||||
import com.cloud.offerings.NetworkOfferingVO;
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.service.dao.ServiceOfferingDao;
|
import com.cloud.service.dao.ServiceOfferingDao;
|
||||||
|
import com.cloud.storage.SnapshotVO;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
|
import com.cloud.storage.dao.SnapshotDao;
|
||||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||||
import com.cloud.storage.dao.VMTemplateDao;
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||||
@ -162,7 +164,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||||||
private AgentManager _agentMgr;
|
private AgentManager _agentMgr;
|
||||||
@Inject
|
@Inject
|
||||||
private NetworkManager _networkMgr;
|
private NetworkManager _networkMgr;
|
||||||
|
@Inject
|
||||||
|
protected SnapshotDao _snapshotDao;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ClusterManager _clusterMgr;
|
private ClusterManager _clusterMgr;
|
||||||
|
|
||||||
@ -282,6 +286,26 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteHost(Long hostId) {
|
||||||
|
List<SnapshotVO> snapshots = _snapshotDao.listByHostId(hostId);
|
||||||
|
if( snapshots != null && !snapshots.isEmpty()) {
|
||||||
|
throw new CloudRuntimeException("Can not delete this secondary storage due to there are still snapshots on it ");
|
||||||
|
}
|
||||||
|
List<Long> list = _templateDao.listPrivateTemplatesByHost(hostId);
|
||||||
|
if( list != null && !list.isEmpty()) {
|
||||||
|
throw new CloudRuntimeException("Can not delete this secondary storage due to there are still private template on it ");
|
||||||
|
}
|
||||||
|
_vmTemplateHostDao.deleteByHost(hostId);
|
||||||
|
HostVO host = _hostDao.findById(hostId);
|
||||||
|
host.setGuid(null);
|
||||||
|
_hostDao.update(hostId, host);
|
||||||
|
_hostDao.remove(hostId);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generateVMSetupCommand(Long ssAHostId) {
|
public boolean generateVMSetupCommand(Long ssAHostId) {
|
||||||
HostVO ssAHost = _hostDao.findById(ssAHostId);
|
HostVO ssAHost = _hostDao.findById(ssAHostId);
|
||||||
@ -356,7 +380,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||||||
SecStorageFirewallCfgCommand thiscpc = new SecStorageFirewallCfgCommand();
|
SecStorageFirewallCfgCommand thiscpc = new SecStorageFirewallCfgCommand();
|
||||||
thiscpc.addPortConfig(thisSecStorageVm.getPublicIpAddress(), copyPort, true, TemplateConstants.DEFAULT_TMPLT_COPY_INTF);
|
thiscpc.addPortConfig(thisSecStorageVm.getPublicIpAddress(), copyPort, true, TemplateConstants.DEFAULT_TMPLT_COPY_INTF);
|
||||||
for (SecondaryStorageVmVO ssVm : alreadyRunning) {
|
for (SecondaryStorageVmVO ssVm : alreadyRunning) {
|
||||||
if ( ssVm.getDataCenterId() == zoneId ) {
|
if ( ssVm.getDataCenterIdToDeployIn() == zoneId ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ssVm.getPublicIpAddress() != null) {
|
if (ssVm.getPublicIpAddress() != null) {
|
||||||
@ -844,7 +868,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||||||
}
|
}
|
||||||
|
|
||||||
SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this,
|
SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this,
|
||||||
new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_REBOOTED, secStorageVm.getDataCenterId(), secStorageVm.getId(), secStorageVm, null));
|
new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_REBOOTED, secStorageVm.getDataCenterIdToDeployIn(), secStorageVm.getId(), secStorageVm, null));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -971,7 +995,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||||||
buf.append(" bootproto=dhcp");
|
buf.append(" bootproto=dhcp");
|
||||||
}
|
}
|
||||||
|
|
||||||
DataCenterVO dc = _dcDao.findById(profile.getVirtualMachine().getDataCenterId());
|
DataCenterVO dc = _dcDao.findById(profile.getVirtualMachine().getDataCenterIdToDeployIn());
|
||||||
buf.append(" internaldns1=").append(dc.getInternalDns1());
|
buf.append(" internaldns1=").append(dc.getInternalDns1());
|
||||||
if (dc.getInternalDns2() != null) {
|
if (dc.getInternalDns2() != null) {
|
||||||
buf.append(" internaldns2=").append(dc.getInternalDns2());
|
buf.append(" internaldns2=").append(dc.getInternalDns2());
|
||||||
|
|||||||
@ -43,5 +43,6 @@ public interface SecondaryStorageVmManager extends Manager {
|
|||||||
public boolean generateVMSetupCommand(Long hostId);
|
public boolean generateVMSetupCommand(Long hostId);
|
||||||
|
|
||||||
public Pair<HostVO, SecondaryStorageVmVO> assignSecStorageVm(long zoneId, Command cmd);
|
public Pair<HostVO, SecondaryStorageVmVO> assignSecStorageVm(long zoneId, Command cmd);
|
||||||
boolean generateSetupCommand(Long hostId);
|
boolean generateSetupCommand(Long hostId);
|
||||||
|
boolean deleteHost(Long hostId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -194,17 +194,26 @@ public class UploadMonitorImpl implements UploadMonitor {
|
|||||||
String errorString = "";
|
String errorString = "";
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
List<HostVO> storageServers = _serverDao.listByTypeDataCenter(Host.Type.SecondaryStorage, dataCenterId);
|
List<HostVO> storageServers = _serverDao.listByTypeDataCenter(Host.Type.SecondaryStorage, dataCenterId);
|
||||||
if(storageServers == null ) {
|
if(storageServers == null || storageServers.size() == 0) {
|
||||||
throw new CloudRuntimeException("No Storage Server found at the datacenter - " +dataCenterId);
|
throw new CloudRuntimeException("No Storage Server found at the datacenter - " +dataCenterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type type = (template.getFormat() == ImageFormat.ISO) ? Type.ISO : Type.TEMPLATE ;
|
Type type = (template.getFormat() == ImageFormat.ISO) ? Type.ISO : Type.TEMPLATE ;
|
||||||
|
|
||||||
//Check if ssvm is up
|
List<HostVO> storageServerVMs = _serverDao.listByTypeDataCenter(Host.Type.SecondaryStorageVM, dataCenterId);
|
||||||
HostVO sserver = storageServers.get(0);
|
//Check if one ssvm is up
|
||||||
if(sserver.getStatus() != com.cloud.host.Status.Up){
|
boolean no_vm_up = true;
|
||||||
throw new CloudRuntimeException("Couldnt create extract link - Secondary Storage Vm is not up");
|
HostVO use_ssvm = null;
|
||||||
}
|
for (HostVO ssvm: storageServerVMs){
|
||||||
|
if(ssvm.getStatus() == com.cloud.host.Status.Up){
|
||||||
|
no_vm_up = false;
|
||||||
|
use_ssvm = ssvm;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(no_vm_up){
|
||||||
|
throw new CloudRuntimeException("Couldnt create extract link - Secondary Storage Vm is not up");
|
||||||
|
}
|
||||||
|
|
||||||
//Check if it already exists.
|
//Check if it already exists.
|
||||||
List<UploadVO> extractURLList = _uploadDao.listByTypeUploadStatus(template.getId(), type, UploadVO.Status.DOWNLOAD_URL_CREATED);
|
List<UploadVO> extractURLList = _uploadDao.listByTypeUploadStatus(template.getId(), type, UploadVO.Status.DOWNLOAD_URL_CREATED);
|
||||||
@ -213,15 +222,15 @@ public class UploadMonitorImpl implements UploadMonitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// It doesn't exist so create a DB entry.
|
// It doesn't exist so create a DB entry.
|
||||||
UploadVO uploadTemplateObj = new UploadVO(sserver.getId(), template.getId(), new Date(),
|
UploadVO uploadTemplateObj = new UploadVO(use_ssvm.getId(), template.getId(), new Date(),
|
||||||
Status.DOWNLOAD_URL_NOT_CREATED, 0, type, Mode.HTTP_DOWNLOAD);
|
Status.DOWNLOAD_URL_NOT_CREATED, 0, type, Mode.HTTP_DOWNLOAD);
|
||||||
uploadTemplateObj.setInstallPath(vmTemplateHost.getInstallPath());
|
uploadTemplateObj.setInstallPath(vmTemplateHost.getInstallPath());
|
||||||
_uploadDao.persist(uploadTemplateObj);
|
_uploadDao.persist(uploadTemplateObj);
|
||||||
try{
|
try{
|
||||||
// Create Symlink at ssvm
|
// Create Symlink at ssvm
|
||||||
String uuid = UUID.randomUUID().toString() + ".vhd";
|
String uuid = UUID.randomUUID().toString() + ".vhd";
|
||||||
CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(vmTemplateHost.getInstallPath(), uuid);
|
CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(storageServers.get(0).getParent(), vmTemplateHost.getInstallPath(), uuid);
|
||||||
long result = send(sserver.getId(), cmd, null);
|
long result = send(use_ssvm.getId(), cmd, null);
|
||||||
if (result == -1){
|
if (result == -1){
|
||||||
errorString = "Unable to create a link for " +type+ " id:"+template.getId();
|
errorString = "Unable to create a link for " +type+ " id:"+template.getId();
|
||||||
s_logger.error(errorString);
|
s_logger.error(errorString);
|
||||||
@ -230,7 +239,7 @@ public class UploadMonitorImpl implements UploadMonitor {
|
|||||||
|
|
||||||
//Construct actual URL locally now that the symlink exists at SSVM
|
//Construct actual URL locally now that the symlink exists at SSVM
|
||||||
List<SecondaryStorageVmVO> ssVms = _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, dataCenterId, State.Running);
|
List<SecondaryStorageVmVO> ssVms = _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, dataCenterId, State.Running);
|
||||||
if (ssVms.size() > 0) {
|
if (ssVms.size() > 0) {
|
||||||
SecondaryStorageVmVO ssVm = ssVms.get(0);
|
SecondaryStorageVmVO ssVm = ssVms.get(0);
|
||||||
if (ssVm.getPublicIpAddress() == null) {
|
if (ssVm.getPublicIpAddress() == null) {
|
||||||
errorString = "A running secondary storage vm has a null public ip?";
|
errorString = "A running secondary storage vm has a null public ip?";
|
||||||
|
|||||||
@ -262,12 +262,20 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HostVO secondaryStorageHost = _storageMgr.getSecondaryStorageHost(zoneId);
|
List<HostVO> sservers = _storageMgr.getSecondaryStorageHosts(zoneId);
|
||||||
|
|
||||||
VMTemplateHostVO tmpltHostRef = null;
|
VMTemplateHostVO tmpltHostRef = null;
|
||||||
if (secondaryStorageHost != null) {
|
if (sservers != null) {
|
||||||
tmpltHostRef = _tmpltHostDao.findByHostTemplate(secondaryStorageHost.getId(), templateId);
|
for(HostVO secondaryStorageHost: sservers){
|
||||||
if (tmpltHostRef != null && tmpltHostRef.getDownloadState() != com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
|
tmpltHostRef = _tmpltHostDao.findByHostTemplate(secondaryStorageHost.getId(), templateId);
|
||||||
throw new InvalidParameterValueException("The " + desc + " has not been downloaded ");
|
if (tmpltHostRef != null){
|
||||||
|
if (tmpltHostRef.getDownloadState() != com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
|
||||||
|
throw new InvalidParameterValueException("The " + desc + " has not been downloaded ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -819,7 +827,7 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||||||
vm.setIsoId(iso.getId());
|
vm.setIsoId(iso.getId());
|
||||||
_userVmDao.update(vmId, vm);
|
_userVmDao.update(vmId, vm);
|
||||||
}
|
}
|
||||||
if ( !attach ) {
|
if ( success && !attach ) {
|
||||||
vm.setIsoId(null);
|
vm.setIsoId(null);
|
||||||
_userVmDao.update(vmId, vm);
|
_userVmDao.update(vmId, vm);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,10 +75,9 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
|||||||
_upgradeMap.put("2.2.5", new DbUpgrade[] { new Upgrade225to226()});
|
_upgradeMap.put("2.2.5", new DbUpgrade[] { new Upgrade225to226()});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void runScript(File file) {
|
protected void runScript(Connection conn, File file) {
|
||||||
try {
|
try {
|
||||||
FileReader reader = new FileReader(file);
|
FileReader reader = new FileReader(file);
|
||||||
Connection conn = Transaction.getStandaloneConnection();
|
|
||||||
ScriptRunner runner = new ScriptRunner(conn, false, true);
|
ScriptRunner runner = new ScriptRunner(conn, false, true);
|
||||||
runner.runScript(reader);
|
runner.runScript(reader);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
@ -142,7 +141,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
|||||||
File[] scripts = upgrade.getPrepareScripts();
|
File[] scripts = upgrade.getPrepareScripts();
|
||||||
if (scripts != null) {
|
if (scripts != null) {
|
||||||
for (File script : scripts) {
|
for (File script : scripts) {
|
||||||
runScript(script);
|
runScript(conn, script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,11 +202,19 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
|||||||
+ upgrade.getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion());
|
+ upgrade.getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion());
|
||||||
|
|
||||||
txn.start();
|
txn.start();
|
||||||
|
|
||||||
|
Connection conn;
|
||||||
|
try {
|
||||||
|
conn = txn.getConnection();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
s_logger.error("Unable to cleanup the database", e);
|
||||||
|
throw new CloudRuntimeException("Unable to cleanup the database", e);
|
||||||
|
}
|
||||||
|
|
||||||
File[] scripts = upgrade.getCleanupScripts();
|
File[] scripts = upgrade.getCleanupScripts();
|
||||||
if (scripts != null) {
|
if (scripts != null) {
|
||||||
for (File script : scripts) {
|
for (File script : scripts) {
|
||||||
runScript(script);
|
runScript(conn, script);
|
||||||
s_logger.debug("Cleanup script " + script.getAbsolutePath() + " is executed successfully");
|
s_logger.debug("Cleanup script " + script.getAbsolutePath() + " is executed successfully");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -511,23 +511,34 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||||||
throw new InvalidParameterValueException("Failed to list limits for account " + accountName + " no domain id specified.");
|
throw new InvalidParameterValueException("Failed to list limits for account " + accountName + " no domain id specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Account userAccount = _accountDao.findActiveAccount(accountName, domainId);
|
DomainVO domain = _domainDao.findById(domainId);
|
||||||
|
if (domain == null) {
|
||||||
|
throw new InvalidParameterValueException("Unable to find domain by id " + domainId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Account userAccount = _accountDao.findActiveAccount(accountName, domainId);
|
||||||
if (userAccount == null) {
|
if (userAccount == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
|
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
|
||||||
} else if (account != null
|
}
|
||||||
&& (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || account.getType() == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN || account.getType() == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)) {
|
|
||||||
// If this is a non-root admin, make sure that the admin and the user account belong in the same domain or
|
if (account != null) {
|
||||||
// that the user account's domain is a child domain of the parent
|
checkAccess(account, domain);
|
||||||
if (account.getDomainId() != userAccount.getDomainId() && !_domainDao.isChildDomain(account.getDomainId(), userAccount.getDomainId())) {
|
|
||||||
throw new PermissionDeniedException("You do not have permission to access limits for this account: " + accountName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
accountId = userAccount.getId();
|
accountId = userAccount.getId();
|
||||||
domainId = null;
|
domainId = null;
|
||||||
} else if (domainId != null) {
|
} else if (domainId != null) {
|
||||||
// Look up limits for the specified domain
|
// Look up limits for the specified domain
|
||||||
|
|
||||||
|
DomainVO domain = _domainDao.findById(domainId);
|
||||||
|
if (domain == null) {
|
||||||
|
throw new InvalidParameterValueException("Unable to find domain by id " + domainId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (account != null) {
|
||||||
|
checkAccess(account, domain);
|
||||||
|
}
|
||||||
|
|
||||||
accountId = null;
|
accountId = null;
|
||||||
} else if (account == null) {
|
} else if (account == null) {
|
||||||
// Look up limits for the ROOT domain
|
// Look up limits for the ROOT domain
|
||||||
@ -934,7 +945,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||||||
s_logger.error("Unable to destroy vm: " + vm.getId());
|
s_logger.error("Unable to destroy vm: " + vm.getId());
|
||||||
accountCleanupNeeded = true;
|
accountCleanupNeeded = true;
|
||||||
}
|
}
|
||||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName(), vm.getServiceOfferingId(),
|
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(), vm.getHostName(), vm.getServiceOfferingId(),
|
||||||
vm.getTemplateId(), vm.getHypervisorType().toString());
|
vm.getTemplateId(), vm.getHypervisorType().toString());
|
||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -523,7 +523,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that the VM and the volume are in the same zone
|
// Check that the VM and the volume are in the same zone
|
||||||
if (vm.getDataCenterId() != volume.getDataCenterId()) {
|
if (vm.getDataCenterIdToDeployIn() != volume.getDataCenterId()) {
|
||||||
throw new InvalidParameterValueException("Please specify a VM that is in the same zone as the volume.");
|
throw new InvalidParameterValueException("Please specify a VM that is in the same zone as the volume.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,8 +561,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
if (volume.getState().equals(Volume.State.Allocated)) {
|
if (volume.getState().equals(Volume.State.Allocated)) {
|
||||||
/* Need to create the volume */
|
/* Need to create the volume */
|
||||||
VMTemplateVO rootDiskTmplt = _templateDao.findById(vm.getTemplateId());
|
VMTemplateVO rootDiskTmplt = _templateDao.findById(vm.getTemplateId());
|
||||||
DataCenterVO dcVO = _dcDao.findById(vm.getDataCenterId());
|
DataCenterVO dcVO = _dcDao.findById(vm.getDataCenterIdToDeployIn());
|
||||||
HostPodVO pod = _podDao.findById(vm.getPodId());
|
HostPodVO pod = _podDao.findById(vm.getPodIdToDeployIn());
|
||||||
StoragePoolVO rootDiskPool = _storagePoolDao.findById(rootVolumeOfVm.getPoolId());
|
StoragePoolVO rootDiskPool = _storagePoolDao.findById(rootVolumeOfVm.getPoolId());
|
||||||
ServiceOfferingVO svo = _serviceOfferingDao.findById(vm.getServiceOfferingId());
|
ServiceOfferingVO svo = _serviceOfferingDao.findById(vm.getServiceOfferingId());
|
||||||
DiskOfferingVO diskVO = _diskOfferingDao.findById(volume.getDiskOfferingId());
|
DiskOfferingVO diskVO = _diskOfferingDao.findById(volume.getDiskOfferingId());
|
||||||
@ -838,7 +838,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
if (tmplt.getTemplateType() == TemplateType.PERHOST) {
|
if (tmplt.getTemplateType() == TemplateType.PERHOST) {
|
||||||
isoPath = tmplt.getName();
|
isoPath = tmplt.getName();
|
||||||
} else {
|
} else {
|
||||||
isoPathPair = _storageMgr.getAbsoluteIsoPath(isoId, vm.getDataCenterId());
|
isoPathPair = _storageMgr.getAbsoluteIsoPath(isoId, vm.getDataCenterIdToDeployIn());
|
||||||
if (isoPathPair == null) {
|
if (isoPathPair == null) {
|
||||||
s_logger.warn("Couldn't get absolute iso path");
|
s_logger.warn("Couldn't get absolute iso path");
|
||||||
return false;
|
return false;
|
||||||
@ -1105,7 +1105,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
|
|
||||||
_accountMgr.incrementResourceCount(account.getId(), ResourceType.volume, new Long(volumes.size()));
|
_accountMgr.incrementResourceCount(account.getId(), ResourceType.volume, new Long(volumes.size()));
|
||||||
|
|
||||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_CREATE, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm
|
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_CREATE, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm
|
||||||
.getHypervisorType().toString());
|
.getHypervisorType().toString());
|
||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
@ -1456,11 +1456,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
volumeId = snapshot.getVolumeId();
|
volumeId = snapshot.getVolumeId();
|
||||||
|
|
||||||
String origTemplateInstallPath = null;
|
String origTemplateInstallPath = null;
|
||||||
List<StoragePoolVO> storagePools = _storagePoolDao.listByDataCenterId(zoneId);
|
List<StoragePoolVO> pools = _storageMgr.ListByDataCenterHypervisor(zoneId, snapshot.getHypervisorType());
|
||||||
if (storagePools == null || storagePools.size() == 0) {
|
if (pools == null || pools.size() == 0 ) {
|
||||||
throw new CloudRuntimeException("Unable to find storage pools in zone " + zoneId);
|
throw new CloudRuntimeException("Unable to find storage pools in zone " + zoneId);
|
||||||
}
|
}
|
||||||
pool = storagePools.get(0);
|
pool = pools.get(0);
|
||||||
if (snapshot.getVersion() != null && snapshot.getVersion().equalsIgnoreCase("2.1")) {
|
if (snapshot.getVersion() != null && snapshot.getVersion().equalsIgnoreCase("2.1")) {
|
||||||
VolumeVO volume = _volsDao.findByIdIncludingRemoved(volumeId);
|
VolumeVO volume = _volsDao.findByIdIncludingRemoved(volumeId);
|
||||||
if (volume == null) {
|
if (volume == null) {
|
||||||
@ -1625,7 +1625,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
s_logger.warn("Unable to delete volume:" + volume.getId() + " for vm:" + vmId + " whilst transitioning to error state");
|
s_logger.warn("Unable to delete volume:" + volume.getId() + " for vm:" + vmId + " whilst transitioning to error state");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName());
|
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(), vm.getHostName());
|
||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2192,7 +2192,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
if (virtualNetworks.isEmpty()) {
|
if (virtualNetworks.isEmpty()) {
|
||||||
s_logger.debug("Creating default Virtual network for account " + owner + " as a part of deployVM process");
|
s_logger.debug("Creating default Virtual network for account " + owner + " as a part of deployVM process");
|
||||||
Network newNetwork = _networkMgr.createNetwork(defaultVirtualOffering.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", false, null,
|
Network newNetwork = _networkMgr.createNetwork(defaultVirtualOffering.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", false, null,
|
||||||
zone.getId(), null, null, null, null, owner, false, null);
|
zone.getId(), null, null, null, null, owner, false, null, null);
|
||||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||||
} else if (virtualNetworks.size() > 1) {
|
} else if (virtualNetworks.size() > 1) {
|
||||||
throw new InvalidParameterValueException("More than 1 default Virtaul networks are found for account " + owner + "; please specify networkIds");
|
throw new InvalidParameterValueException("More than 1 default Virtaul networks are found for account " + owner + "; please specify networkIds");
|
||||||
@ -2205,7 +2205,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
if (defaultVirtualOffering.get(0).getAvailability() == Availability.Optional) {
|
if (defaultVirtualOffering.get(0).getAvailability() == Availability.Optional) {
|
||||||
s_logger.debug("Creating default Virtual network for account " + owner + " as a part of deployVM process");
|
s_logger.debug("Creating default Virtual network for account " + owner + " as a part of deployVM process");
|
||||||
Network newNetwork = _networkMgr.createNetwork(defaultVirtualOffering.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", false, null,
|
Network newNetwork = _networkMgr.createNetwork(defaultVirtualOffering.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", false, null,
|
||||||
zone.getId(), null, null, null, null, owner, false, null);
|
zone.getId(), null, null, null, null, owner, false, null, null);
|
||||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidParameterValueException("Unable to find default networks for account " + owner);
|
throw new InvalidParameterValueException("Unable to find default networks for account " + owner);
|
||||||
@ -2400,7 +2400,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
sshPublicKey = pair.getPublicKey();
|
sshPublicKey = pair.getPublicKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
_accountMgr.checkAccess(caller, template);
|
// _accountMgr.checkAccess(caller, template);
|
||||||
|
|
||||||
DataCenterDeployment plan = new DataCenterDeployment(zone.getId());
|
DataCenterDeployment plan = new DataCenterDeployment(zone.getId());
|
||||||
|
|
||||||
@ -2569,7 +2569,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
DataCenterDeployment plan = null;
|
DataCenterDeployment plan = null;
|
||||||
if (destinationHost != null) {
|
if (destinationHost != null) {
|
||||||
s_logger.debug("Destination Host to deploy the VM is specified, specifying a deployment plan to deploy the VM");
|
s_logger.debug("Destination Host to deploy the VM is specified, specifying a deployment plan to deploy the VM");
|
||||||
plan = new DataCenterDeployment(vm.getDataCenterId(), destinationHost.getPodId(), destinationHost.getClusterId(), destinationHost.getId(), null);
|
plan = new DataCenterDeployment(vm.getDataCenterIdToDeployIn(), destinationHost.getPodId(), destinationHost.getClusterId(), destinationHost.getId(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
vm = _itMgr.start(vm, params, caller, owner, plan);
|
vm = _itMgr.start(vm, params, caller, owner, plan);
|
||||||
@ -2604,7 +2604,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
}
|
}
|
||||||
if (template != null && template.getFormat() == ImageFormat.ISO && vm.getIsoId() != null) {
|
if (template != null && template.getFormat() == ImageFormat.ISO && vm.getIsoId() != null) {
|
||||||
String isoPath = null;
|
String isoPath = null;
|
||||||
Pair<String, String> isoPathPair = _storageMgr.getAbsoluteIsoPath(template.getId(), vm.getDataCenterId());
|
Pair<String, String> isoPathPair = _storageMgr.getAbsoluteIsoPath(template.getId(), vm.getDataCenterIdToDeployIn());
|
||||||
if (isoPathPair == null) {
|
if (isoPathPair == null) {
|
||||||
s_logger.warn("Couldn't get absolute iso path");
|
s_logger.warn("Couldn't get absolute iso path");
|
||||||
return false;
|
return false;
|
||||||
@ -2656,7 +2656,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
@Override
|
@Override
|
||||||
public boolean finalizeStart(VirtualMachineProfile<UserVmVO> profile, long hostId, Commands cmds, ReservationContext context) {
|
public boolean finalizeStart(VirtualMachineProfile<UserVmVO> profile, long hostId, Commands cmds, ReservationContext context) {
|
||||||
UserVmVO vm = profile.getVirtualMachine();
|
UserVmVO vm = profile.getVirtualMachine();
|
||||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_START, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm
|
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_START, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm
|
||||||
.getHypervisorType().toString());
|
.getHypervisorType().toString());
|
||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
Answer startAnswer = cmds.getAnswer(StartAnswer.class);
|
Answer startAnswer = cmds.getAnswer(StartAnswer.class);
|
||||||
@ -2677,7 +2677,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
for (NicVO nic : nics) {
|
for (NicVO nic : nics) {
|
||||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||||
long isDefault = (nic.isDefaultNic()) ? 1 : 0;
|
long isDefault = (nic.isDefaultNic()) ? 1 : 0;
|
||||||
usageEvent = new UsageEventVO(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName(), network.getNetworkOfferingId(), null, isDefault);
|
usageEvent = new UsageEventVO(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(), vm.getHostName(), network.getNetworkOfferingId(), null, isDefault);
|
||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
if (network.getTrafficType() == TrafficType.Guest) {
|
if (network.getTrafficType() == TrafficType.Guest) {
|
||||||
originalIp = nic.getIp4Address();
|
originalIp = nic.getIp4Address();
|
||||||
@ -2698,7 +2698,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ipChanged) {
|
if (ipChanged) {
|
||||||
DataCenterVO dc = _dcDao.findById(vm.getDataCenterId());
|
DataCenterVO dc = _dcDao.findById(vm.getDataCenterIdToDeployIn());
|
||||||
UserVmVO userVm = profile.getVirtualMachine();
|
UserVmVO userVm = profile.getVirtualMachine();
|
||||||
if (dc.getDhcpProvider().equalsIgnoreCase(Provider.ExternalDhcpServer.getName())){
|
if (dc.getDhcpProvider().equalsIgnoreCase(Provider.ExternalDhcpServer.getName())){
|
||||||
_nicDao.update(guestNic.getId(), guestNic);
|
_nicDao.update(guestNic.getId(), guestNic);
|
||||||
@ -2769,13 +2769,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
@Override
|
@Override
|
||||||
public void finalizeStop(VirtualMachineProfile<UserVmVO> profile, StopAnswer answer) {
|
public void finalizeStop(VirtualMachineProfile<UserVmVO> profile, StopAnswer answer) {
|
||||||
VMInstanceVO vm = profile.getVirtualMachine();
|
VMInstanceVO vm = profile.getVirtualMachine();
|
||||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_STOP, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName());
|
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_STOP, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(), vm.getHostName());
|
||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
|
|
||||||
List<NicVO> nics = _nicDao.listByVmId(vm.getId());
|
List<NicVO> nics = _nicDao.listByVmId(vm.getId());
|
||||||
for (NicVO nic : nics) {
|
for (NicVO nic : nics) {
|
||||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||||
usageEvent = new UsageEventVO(EventTypes.EVENT_NETWORK_OFFERING_REMOVE, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), null, network.getNetworkOfferingId(), null, 0L);
|
usageEvent = new UsageEventVO(EventTypes.EVENT_NETWORK_OFFERING_REMOVE, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(), null, network.getNetworkOfferingId(), null, 0L);
|
||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2853,7 +2853,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName());
|
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(), vm.getHostName());
|
||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
|
|
||||||
if (vmState != State.Error) {
|
if (vmState != State.Error) {
|
||||||
@ -2990,8 +2990,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
sb.and("stateEQ", sb.entity().getState(), SearchCriteria.Op.EQ);
|
sb.and("stateEQ", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||||
sb.and("stateNEQ", sb.entity().getState(), SearchCriteria.Op.NEQ);
|
sb.and("stateNEQ", sb.entity().getState(), SearchCriteria.Op.NEQ);
|
||||||
sb.and("stateNIN", sb.entity().getState(), SearchCriteria.Op.NIN);
|
sb.and("stateNIN", sb.entity().getState(), SearchCriteria.Op.NIN);
|
||||||
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
sb.and("dataCenterId", sb.entity().getDataCenterIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
|
sb.and("podId", sb.entity().getPodIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ);
|
sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ);
|
||||||
sb.and("hostIdEQ", sb.entity().getHostId(), SearchCriteria.Op.EQ);
|
sb.and("hostIdEQ", sb.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||||
sb.and("hostIdIN", sb.entity().getHostId(), SearchCriteria.Op.IN);
|
sb.and("hostIdIN", sb.entity().getHostId(), SearchCriteria.Op.IN);
|
||||||
|
|||||||
@ -586,7 +586,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||||||
ServiceOfferingVO offering = _offeringDao.findById(vm.getServiceOfferingId());
|
ServiceOfferingVO offering = _offeringDao.findById(vm.getServiceOfferingId());
|
||||||
VMTemplateVO template = _templateDao.findById(vm.getTemplateId());
|
VMTemplateVO template = _templateDao.findById(vm.getTemplateId());
|
||||||
|
|
||||||
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vm.getPodId(), null, null, null);
|
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterIdToDeployIn(), vm.getPodIdToDeployIn(), null, null, null);
|
||||||
if(planToDeploy != null){
|
if(planToDeploy != null){
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("advanceStart: DeploymentPlan is provided, using that plan to deploy");
|
s_logger.debug("advanceStart: DeploymentPlan is provided, using that plan to deploy");
|
||||||
@ -1318,13 +1318,13 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||||||
ConcurrentOperationException, ResourceUnavailableException {
|
ConcurrentOperationException, ResourceUnavailableException {
|
||||||
T rebootedVm = null;
|
T rebootedVm = null;
|
||||||
|
|
||||||
DataCenter dc = _configMgr.getZone(vm.getDataCenterId());
|
DataCenter dc = _configMgr.getZone(vm.getDataCenterIdToDeployIn());
|
||||||
HostPodVO pod = _configMgr.getPod(vm.getPodId());
|
|
||||||
Host host = _hostDao.findById(vm.getHostId());
|
Host host = _hostDao.findById(vm.getHostId());
|
||||||
Cluster cluster = null;
|
Cluster cluster = null;
|
||||||
if (host != null) {
|
if (host != null) {
|
||||||
cluster = _configMgr.getCluster(host.getClusterId());
|
cluster = _configMgr.getCluster(host.getClusterId());
|
||||||
}
|
}
|
||||||
|
HostPodVO pod = _configMgr.getPod(host.getPodId());
|
||||||
DeployDestination dest = new DeployDestination(dc, pod, cluster, host);
|
DeployDestination dest = new DeployDestination(dc, pod, cluster, host);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1433,7 +1433,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||||||
Command command = null;
|
Command command = null;
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("VM " + serverName + ": server state = " + serverState.toString() + " and agent state = " + agentState.toString());
|
s_logger.debug("VM " + serverName + ": server state = " + serverState + " and agent state = " + agentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agentState == State.Error) {
|
if (agentState == State.Error) {
|
||||||
@ -1446,12 +1446,12 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||||||
alertType = AlertManager.ALERT_TYPE_CONSOLE_PROXY;
|
alertType = AlertManager.ALERT_TYPE_CONSOLE_PROXY;
|
||||||
}
|
}
|
||||||
|
|
||||||
HostPodVO podVO = _podDao.findById(vm.getPodId());
|
HostPodVO podVO = _podDao.findById(vm.getPodIdToDeployIn());
|
||||||
DataCenterVO dcVO = _dcDao.findById(vm.getDataCenterId());
|
DataCenterVO dcVO = _dcDao.findById(vm.getDataCenterIdToDeployIn());
|
||||||
HostVO hostVO = _hostDao.findById(vm.getHostId());
|
HostVO hostVO = _hostDao.findById(vm.getHostId());
|
||||||
|
|
||||||
String hostDesc = "name: " + hostVO.getName() + " (id:" + hostVO.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
|
String hostDesc = "name: " + hostVO.getName() + " (id:" + hostVO.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
|
||||||
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "VM (name: " + vm.getInstanceName() + ", id: " + vm.getId() + ") stopped on host " + hostDesc + " due to storage failure",
|
_alertMgr.sendAlert(alertType, vm.getDataCenterIdToDeployIn(), vm.getPodIdToDeployIn(), "VM (name: " + vm.getInstanceName() + ", id: " + vm.getId() + ") stopped on host " + hostDesc + " due to storage failure",
|
||||||
"Virtual Machine " + vm.getInstanceName() + " (id: " + vm.getId() + ") running on host [" + vm.getHostId() + "] stopped due to storage failure.");
|
"Virtual Machine " + vm.getInstanceName() + " (id: " + vm.getId() + ") running on host [" + vm.getHostId() + "] stopped due to storage failure.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -117,7 +117,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
|||||||
|
|
||||||
public ConsoleProxyDaoImpl() {
|
public ConsoleProxyDaoImpl() {
|
||||||
DataCenterStatusSearch = createSearchBuilder();
|
DataCenterStatusSearch = createSearchBuilder();
|
||||||
DataCenterStatusSearch.and("dc", DataCenterStatusSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
DataCenterStatusSearch.and("dc", DataCenterStatusSearch.entity().getDataCenterIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
DataCenterStatusSearch.and("states", DataCenterStatusSearch.entity().getState(), SearchCriteria.Op.IN);
|
DataCenterStatusSearch.and("states", DataCenterStatusSearch.entity().getState(), SearchCriteria.Op.IN);
|
||||||
DataCenterStatusSearch.done();
|
DataCenterStatusSearch.done();
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
|||||||
HostUpSearch = createSearchBuilder();
|
HostUpSearch = createSearchBuilder();
|
||||||
HostUpSearch.and("host", HostUpSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
HostUpSearch.and("host", HostUpSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||||
HostUpSearch.and("states", HostUpSearch.entity().getState(), SearchCriteria.Op.NIN);
|
HostUpSearch.and("states", HostUpSearch.entity().getState(), SearchCriteria.Op.NIN);
|
||||||
HostUpSearch.done();
|
HostUpSearch.done();
|
||||||
|
|
||||||
StateChangeSearch = createSearchBuilder();
|
StateChangeSearch = createSearchBuilder();
|
||||||
StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
|
StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||||
@ -171,7 +171,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
|||||||
UpdateBuilder ub = getUpdateBuilder(proxy);
|
UpdateBuilder ub = getUpdateBuilder(proxy);
|
||||||
ub.set(proxy, "state", State.Destroyed);
|
ub.set(proxy, "state", State.Destroyed);
|
||||||
ub.set(proxy, "privateIpAddress", null);
|
ub.set(proxy, "privateIpAddress", null);
|
||||||
update(id, ub);
|
update(id, ub, proxy);
|
||||||
|
|
||||||
boolean result = super.remove(id);
|
boolean result = super.remove(id);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
@ -204,7 +204,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
|||||||
public List<ConsoleProxyVO> listUpByHostId(long hostId) {
|
public List<ConsoleProxyVO> listUpByHostId(long hostId) {
|
||||||
SearchCriteria<ConsoleProxyVO> sc = HostUpSearch.create();
|
SearchCriteria<ConsoleProxyVO> sc = HostUpSearch.create();
|
||||||
sc.setParameters("host", hostId);
|
sc.setParameters("host", hostId);
|
||||||
sc.setParameters("states", new Object[] {State.Destroyed, State.Stopped, State.Expunging});
|
sc.setParameters("states", new Object[] {State.Destroyed, State.Stopped, State.Expunging});
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,9 +29,9 @@ import com.cloud.network.dao.NetworkDaoImpl;
|
|||||||
import com.cloud.network.router.VirtualRouter.Role;
|
import com.cloud.network.router.VirtualRouter.Role;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
|
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
|
||||||
import com.cloud.utils.db.SearchCriteria.Op;
|
import com.cloud.utils.db.SearchCriteria.Op;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.db.UpdateBuilder;
|
import com.cloud.utils.db.UpdateBuilder;
|
||||||
@ -49,7 +49,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
|||||||
|
|
||||||
protected DomainRouterDaoImpl() {
|
protected DomainRouterDaoImpl() {
|
||||||
AllFieldsSearch = createSearchBuilder();
|
AllFieldsSearch = createSearchBuilder();
|
||||||
AllFieldsSearch.and("dc", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
|
AllFieldsSearch.and("dc", AllFieldsSearch.entity().getDataCenterIdToDeployIn(), Op.EQ);
|
||||||
AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ);
|
AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ);
|
||||||
AllFieldsSearch.and("role", AllFieldsSearch.entity().getRole(), Op.EQ);
|
AllFieldsSearch.and("role", AllFieldsSearch.entity().getRole(), Op.EQ);
|
||||||
AllFieldsSearch.and("domainId", AllFieldsSearch.entity().getDomainId(), Op.EQ);
|
AllFieldsSearch.and("domainId", AllFieldsSearch.entity().getDomainId(), Op.EQ);
|
||||||
@ -57,7 +57,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
|||||||
AllFieldsSearch.and("lastHost", AllFieldsSearch.entity().getLastHostId(), Op.EQ);
|
AllFieldsSearch.and("lastHost", AllFieldsSearch.entity().getLastHostId(), Op.EQ);
|
||||||
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
|
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
|
||||||
AllFieldsSearch.and("network", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
|
AllFieldsSearch.and("network", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
|
||||||
AllFieldsSearch.and("podId", AllFieldsSearch.entity().getPodId(), Op.EQ);
|
AllFieldsSearch.and("podId", AllFieldsSearch.entity().getPodIdToDeployIn(), Op.EQ);
|
||||||
AllFieldsSearch.done();
|
AllFieldsSearch.done();
|
||||||
|
|
||||||
IdStatesSearch = createSearchBuilder();
|
IdStatesSearch = createSearchBuilder();
|
||||||
@ -83,7 +83,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
|||||||
router.setPublicIpAddress(null);
|
router.setPublicIpAddress(null);
|
||||||
UpdateBuilder ub = getUpdateBuilder(router);
|
UpdateBuilder ub = getUpdateBuilder(router);
|
||||||
ub.set(router, "state", State.Destroyed);
|
ub.set(router, "state", State.Destroyed);
|
||||||
update(id, ub);
|
update(id, ub, router);
|
||||||
|
|
||||||
boolean result = super.remove(id);
|
boolean result = super.remove(id);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
|
|
||||||
public SecondaryStorageVmDaoImpl() {
|
public SecondaryStorageVmDaoImpl() {
|
||||||
DataCenterStatusSearch = createSearchBuilder();
|
DataCenterStatusSearch = createSearchBuilder();
|
||||||
DataCenterStatusSearch.and("dc", DataCenterStatusSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
DataCenterStatusSearch.and("dc", DataCenterStatusSearch.entity().getDataCenterIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
DataCenterStatusSearch.and("states", DataCenterStatusSearch.entity().getState(), SearchCriteria.Op.IN);
|
DataCenterStatusSearch.and("states", DataCenterStatusSearch.entity().getState(), SearchCriteria.Op.IN);
|
||||||
DataCenterStatusSearch.and("role", DataCenterStatusSearch.entity().getRole(), SearchCriteria.Op.EQ);
|
DataCenterStatusSearch.and("role", DataCenterStatusSearch.entity().getRole(), SearchCriteria.Op.EQ);
|
||||||
DataCenterStatusSearch.done();
|
DataCenterStatusSearch.done();
|
||||||
@ -86,7 +86,7 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
HostUpSearch.done();
|
HostUpSearch.done();
|
||||||
|
|
||||||
ZoneSearch = createSearchBuilder();
|
ZoneSearch = createSearchBuilder();
|
||||||
ZoneSearch.and("zone", ZoneSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
ZoneSearch.and("zone", ZoneSearch.entity().getDataCenterIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
ZoneSearch.and("role", ZoneSearch.entity().getRole(), SearchCriteria.Op.EQ);
|
ZoneSearch.and("role", ZoneSearch.entity().getRole(), SearchCriteria.Op.EQ);
|
||||||
ZoneSearch.done();
|
ZoneSearch.done();
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
UpdateBuilder ub = getUpdateBuilder(proxy);
|
UpdateBuilder ub = getUpdateBuilder(proxy);
|
||||||
ub.set(proxy, "state", State.Destroyed);
|
ub.set(proxy, "state", State.Destroyed);
|
||||||
ub.set(proxy, "privateIpAddress", null);
|
ub.set(proxy, "privateIpAddress", null);
|
||||||
update(id, ub);
|
update(id, ub, proxy);
|
||||||
|
|
||||||
boolean result = super.remove(id);
|
boolean result = super.remove(id);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
@ -125,8 +125,9 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
SearchCriteria<SecondaryStorageVmVO> sc = DataCenterStatusSearch.create();
|
SearchCriteria<SecondaryStorageVmVO> sc = DataCenterStatusSearch.create();
|
||||||
sc.setParameters("states", (Object[])states);
|
sc.setParameters("states", (Object[])states);
|
||||||
sc.setParameters("dc", dataCenterId);
|
sc.setParameters("dc", dataCenterId);
|
||||||
if(role != null)
|
if(role != null) {
|
||||||
sc.setParameters("role", role);
|
sc.setParameters("role", role);
|
||||||
|
}
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,8 +135,9 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
public List<SecondaryStorageVmVO> getSecStorageVmListInStates(SecondaryStorageVm.Role role, State... states) {
|
public List<SecondaryStorageVmVO> getSecStorageVmListInStates(SecondaryStorageVm.Role role, State... states) {
|
||||||
SearchCriteria<SecondaryStorageVmVO> sc = StateSearch.create();
|
SearchCriteria<SecondaryStorageVmVO> sc = StateSearch.create();
|
||||||
sc.setParameters("states", (Object[])states);
|
sc.setParameters("states", (Object[])states);
|
||||||
if(role != null)
|
if(role != null) {
|
||||||
sc.setParameters("role", role);
|
sc.setParameters("role", role);
|
||||||
|
}
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
@ -144,8 +146,9 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
public List<SecondaryStorageVmVO> listByHostId(SecondaryStorageVm.Role role, long hostId) {
|
public List<SecondaryStorageVmVO> listByHostId(SecondaryStorageVm.Role role, long hostId) {
|
||||||
SearchCriteria<SecondaryStorageVmVO> sc = HostSearch.create();
|
SearchCriteria<SecondaryStorageVmVO> sc = HostSearch.create();
|
||||||
sc.setParameters("host", hostId);
|
sc.setParameters("host", hostId);
|
||||||
if(role != null)
|
if(role != null) {
|
||||||
sc.setParameters("role", role);
|
sc.setParameters("role", role);
|
||||||
|
}
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,9 +156,10 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
public List<SecondaryStorageVmVO> listUpByHostId(SecondaryStorageVm.Role role, long hostId) {
|
public List<SecondaryStorageVmVO> listUpByHostId(SecondaryStorageVm.Role role, long hostId) {
|
||||||
SearchCriteria<SecondaryStorageVmVO> sc = HostUpSearch.create();
|
SearchCriteria<SecondaryStorageVmVO> sc = HostUpSearch.create();
|
||||||
sc.setParameters("host", hostId);
|
sc.setParameters("host", hostId);
|
||||||
sc.setParameters("states", new Object[] {State.Destroyed, State.Stopped, State.Expunging});
|
sc.setParameters("states", new Object[] {State.Destroyed, State.Stopped, State.Expunging});
|
||||||
if(role != null)
|
if(role != null) {
|
||||||
sc.setParameters("role", role);
|
sc.setParameters("role", role);
|
||||||
|
}
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,12 +170,13 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try {
|
try {
|
||||||
String sql;
|
String sql;
|
||||||
if(role == null)
|
if(role == null) {
|
||||||
sql = "SELECT s.id FROM secondary_storage_vm s, vm_instance v, host h " +
|
sql = "SELECT s.id FROM secondary_storage_vm s, vm_instance v, host h " +
|
||||||
"WHERE s.id=v.id AND v.state='Running' AND v.host_id=h.id AND h.mgmt_server_id=?";
|
"WHERE s.id=v.id AND v.state='Running' AND v.host_id=h.id AND h.mgmt_server_id=?";
|
||||||
else
|
} else {
|
||||||
sql = "SELECT s.id FROM secondary_storage_vm s, vm_instance v, host h " +
|
sql = "SELECT s.id FROM secondary_storage_vm s, vm_instance v, host h " +
|
||||||
"WHERE s.id=v.id AND v.state='Running' AND s.role=? AND v.host_id=h.id AND h.mgmt_server_id=?";
|
"WHERE s.id=v.id AND v.state='Running' AND s.role=? AND v.host_id=h.id AND h.mgmt_server_id=?";
|
||||||
|
}
|
||||||
|
|
||||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||||
|
|
||||||
@ -209,8 +214,9 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
public List<SecondaryStorageVmVO> listByZoneId(SecondaryStorageVm.Role role, long zoneId) {
|
public List<SecondaryStorageVmVO> listByZoneId(SecondaryStorageVm.Role role, long zoneId) {
|
||||||
SearchCriteria<SecondaryStorageVmVO> sc = ZoneSearch.create();
|
SearchCriteria<SecondaryStorageVmVO> sc = ZoneSearch.create();
|
||||||
sc.setParameters("zone", zoneId);
|
sc.setParameters("zone", zoneId);
|
||||||
if(role != null)
|
if(role != null) {
|
||||||
sc.setParameters("role", role);
|
sc.setParameters("role", role);
|
||||||
|
}
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,8 +225,9 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
SearchCriteria<SecondaryStorageVmVO> sc = LastHostSearch.create();
|
SearchCriteria<SecondaryStorageVmVO> sc = LastHostSearch.create();
|
||||||
sc.setParameters("lastHost", hostId);
|
sc.setParameters("lastHost", hostId);
|
||||||
sc.setParameters("state", State.Stopped);
|
sc.setParameters("state", State.Stopped);
|
||||||
if(role != null)
|
if(role != null) {
|
||||||
sc.setParameters("role", role);
|
sc.setParameters("role", role);
|
||||||
|
}
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
@ -233,10 +240,11 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
|||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try {
|
try {
|
||||||
String sql;
|
String sql;
|
||||||
if(role == null)
|
if(role == null) {
|
||||||
sql = "SELECT s.id, count(l.id) as count FROM secondary_storage_vm s INNER JOIN vm_instance v ON s.id=v.id LEFT JOIN cmd_exec_log l ON s.id=l.instance_id WHERE v.state='Running' AND v.data_center_id=? GROUP BY s.id ORDER BY count";
|
sql = "SELECT s.id, count(l.id) as count FROM secondary_storage_vm s INNER JOIN vm_instance v ON s.id=v.id LEFT JOIN cmd_exec_log l ON s.id=l.instance_id WHERE v.state='Running' AND v.data_center_id=? GROUP BY s.id ORDER BY count";
|
||||||
else
|
} else {
|
||||||
sql = "SELECT s.id, count(l.id) as count FROM secondary_storage_vm s INNER JOIN vm_instance v ON s.id=v.id LEFT JOIN cmd_exec_log l ON s.id=l.instance_id WHERE v.state='Running' AND v.data_center_id=? AND s.role=? GROUP BY s.id ORDER BY count";
|
sql = "SELECT s.id, count(l.id) as count FROM secondary_storage_vm s INNER JOIN vm_instance v ON s.id=v.id LEFT JOIN cmd_exec_log l ON s.id=l.instance_id WHERE v.state='Running' AND v.data_center_id=? AND s.role=? GROUP BY s.id ORDER BY count";
|
||||||
|
}
|
||||||
|
|
||||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||||
|
|
||||||
|
|||||||
@ -97,12 +97,12 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
|||||||
|
|
||||||
AccountPodSearch = createSearchBuilder();
|
AccountPodSearch = createSearchBuilder();
|
||||||
AccountPodSearch.and("account", AccountPodSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
AccountPodSearch.and("account", AccountPodSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||||
AccountPodSearch.and("pod", AccountPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
AccountPodSearch.and("pod", AccountPodSearch.entity().getPodIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
AccountPodSearch.done();
|
AccountPodSearch.done();
|
||||||
|
|
||||||
AccountDataCenterSearch = createSearchBuilder();
|
AccountDataCenterSearch = createSearchBuilder();
|
||||||
AccountDataCenterSearch.and("account", AccountDataCenterSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
AccountDataCenterSearch.and("account", AccountDataCenterSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||||
AccountDataCenterSearch.and("dc", AccountDataCenterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
AccountDataCenterSearch.and("dc", AccountDataCenterSearch.entity().getDataCenterIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
AccountDataCenterSearch.done();
|
AccountDataCenterSearch.done();
|
||||||
|
|
||||||
StateChangeSearch = createSearchBuilder();
|
StateChangeSearch = createSearchBuilder();
|
||||||
@ -125,7 +125,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
|||||||
CountByAccountPod = createSearchBuilder(Long.class);
|
CountByAccountPod = createSearchBuilder(Long.class);
|
||||||
CountByAccountPod.select(null, Func.COUNT, null);
|
CountByAccountPod.select(null, Func.COUNT, null);
|
||||||
CountByAccountPod.and("account", CountByAccountPod.entity().getAccountId(), SearchCriteria.Op.EQ);
|
CountByAccountPod.and("account", CountByAccountPod.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||||
CountByAccountPod.and("pod", CountByAccountPod.entity().getPodId(), SearchCriteria.Op.EQ);
|
CountByAccountPod.and("pod", CountByAccountPod.entity().getPodIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
CountByAccountPod.done();
|
CountByAccountPod.done();
|
||||||
|
|
||||||
_updateTimeAttr = _allAttributes.get("updateTime");
|
_updateTimeAttr = _allAttributes.get("updateTime");
|
||||||
@ -211,7 +211,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
|||||||
|
|
||||||
AccountDataCenterVirtualSearch = createSearchBuilder();
|
AccountDataCenterVirtualSearch = createSearchBuilder();
|
||||||
AccountDataCenterVirtualSearch.and("account", AccountDataCenterVirtualSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
AccountDataCenterVirtualSearch.and("account", AccountDataCenterVirtualSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||||
AccountDataCenterVirtualSearch.and("dc", AccountDataCenterVirtualSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
AccountDataCenterVirtualSearch.and("dc", AccountDataCenterVirtualSearch.entity().getDataCenterIdToDeployIn(), SearchCriteria.Op.EQ);
|
||||||
AccountDataCenterVirtualSearch.join("nicSearch", nicSearch, AccountDataCenterVirtualSearch.entity().getId(), nicSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
|
AccountDataCenterVirtualSearch.join("nicSearch", nicSearch, AccountDataCenterVirtualSearch.entity().getId(), nicSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
|
||||||
AccountDataCenterVirtualSearch.done();
|
AccountDataCenterVirtualSearch.done();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,13 +67,13 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
|||||||
AllFieldsSearch.and("host", AllFieldsSearch.entity().getHostId(), Op.EQ);
|
AllFieldsSearch.and("host", AllFieldsSearch.entity().getHostId(), Op.EQ);
|
||||||
AllFieldsSearch.and("lastHost", AllFieldsSearch.entity().getLastHostId(), Op.EQ);
|
AllFieldsSearch.and("lastHost", AllFieldsSearch.entity().getLastHostId(), Op.EQ);
|
||||||
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
|
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
|
||||||
AllFieldsSearch.and("zone", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
|
AllFieldsSearch.and("zone", AllFieldsSearch.entity().getDataCenterIdToDeployIn(), Op.EQ);
|
||||||
AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), Op.EQ);
|
AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), Op.EQ);
|
||||||
AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ);
|
AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ);
|
||||||
AllFieldsSearch.done();
|
AllFieldsSearch.done();
|
||||||
|
|
||||||
ZoneTemplateNonExpungedSearch = createSearchBuilder();
|
ZoneTemplateNonExpungedSearch = createSearchBuilder();
|
||||||
ZoneTemplateNonExpungedSearch.and("zone", ZoneTemplateNonExpungedSearch.entity().getDataCenterId(), Op.EQ);
|
ZoneTemplateNonExpungedSearch.and("zone", ZoneTemplateNonExpungedSearch.entity().getDataCenterIdToDeployIn(), Op.EQ);
|
||||||
ZoneTemplateNonExpungedSearch.and("template", ZoneTemplateNonExpungedSearch.entity().getTemplateId(), Op.EQ);
|
ZoneTemplateNonExpungedSearch.and("template", ZoneTemplateNonExpungedSearch.entity().getTemplateId(), Op.EQ);
|
||||||
ZoneTemplateNonExpungedSearch.and("state", ZoneTemplateNonExpungedSearch.entity().getState(), Op.NEQ);
|
ZoneTemplateNonExpungedSearch.and("state", ZoneTemplateNonExpungedSearch.entity().getState(), Op.NEQ);
|
||||||
ZoneTemplateNonExpungedSearch.done();
|
ZoneTemplateNonExpungedSearch.done();
|
||||||
|
|||||||
57
server/test/com/cloud/network/dao/NetworkDaoTest.java
Normal file
57
server/test/com/cloud/network/dao/NetworkDaoTest.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package com.cloud.network.dao;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import com.cloud.network.Network.GuestIpType;
|
||||||
|
import com.cloud.network.NetworkVO;
|
||||||
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
|
import com.cloud.network.Networks.Mode;
|
||||||
|
import com.cloud.network.Networks.TrafficType;
|
||||||
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
|
|
||||||
|
|
||||||
|
public class NetworkDaoTest extends TestCase {
|
||||||
|
public void testTags() {
|
||||||
|
NetworkDaoImpl dao = ComponentLocator.inject(NetworkDaoImpl.class);
|
||||||
|
|
||||||
|
dao.expunge(1001l);
|
||||||
|
NetworkVO network = new NetworkVO(1001, TrafficType.Control, GuestIpType.Direct, Mode.Dhcp, BroadcastDomainType.Native, 1, 1, 1, 1, 1001, "Name", "DisplayText", false, true);
|
||||||
|
network.setGuruName("guru_name");
|
||||||
|
List<String> tags = new ArrayList<String>();
|
||||||
|
|
||||||
|
tags.add("a");
|
||||||
|
tags.add("b");
|
||||||
|
network.setTags(tags);
|
||||||
|
|
||||||
|
network = dao.persist(network);
|
||||||
|
List<String> saveTags = network.getTags();
|
||||||
|
assert(saveTags.size() == 2 && saveTags.contains("a") && saveTags.contains("b"));
|
||||||
|
|
||||||
|
NetworkVO retrieved = dao.findById(1001l);
|
||||||
|
List<String> retrievedTags = retrieved.getTags();
|
||||||
|
assert(retrievedTags.size() == 2 && retrievedTags.contains("a") && retrievedTags.contains("b"));
|
||||||
|
|
||||||
|
List<String> updateTags = new ArrayList<String>();
|
||||||
|
updateTags.add("e");
|
||||||
|
updateTags.add("f");
|
||||||
|
retrieved.setTags(updateTags);
|
||||||
|
dao.update(retrieved.getId(), retrieved);
|
||||||
|
|
||||||
|
retrieved = dao.findById(1001l);
|
||||||
|
retrievedTags = retrieved.getTags();
|
||||||
|
assert(retrievedTags.size() == 2 && retrievedTags.contains("e") && retrievedTags.contains("f"));
|
||||||
|
|
||||||
|
|
||||||
|
dao.expunge(1001l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListBy() {
|
||||||
|
NetworkDaoImpl dao = ComponentLocator.inject(NetworkDaoImpl.class);
|
||||||
|
|
||||||
|
dao.listBy(1l, 1l, 1l, "192.168.192.0/24");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
server/test/com/cloud/vm/dao/UserVmDaoImplTest.java
Normal file
24
server/test/com/cloud/vm/dao/UserVmDaoImplTest.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package com.cloud.vm.dao;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
|
import com.cloud.vm.UserVmVO;
|
||||||
|
import com.cloud.vm.VirtualMachine;
|
||||||
|
|
||||||
|
|
||||||
|
public class UserVmDaoImplTest extends TestCase {
|
||||||
|
public void testPersist() {
|
||||||
|
UserVmDao dao = ComponentLocator.inject(UserVmDaoImpl.class);
|
||||||
|
|
||||||
|
dao.expunge(1000l);
|
||||||
|
|
||||||
|
UserVmVO vo = new UserVmVO(1000l, "instancename", "displayname", 1, HypervisorType.XenServer, 1, true, true, 1, 1, 1, "userdata", "name");
|
||||||
|
dao.persist(vo);
|
||||||
|
|
||||||
|
vo = dao.findById(1000l);
|
||||||
|
assert (vo.getType() == VirtualMachine.Type.User) : "Incorrect type " + vo.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -185,7 +185,7 @@ CREATE TABLE `cloud`.`networks` (
|
|||||||
`is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not',
|
`is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
CONSTRAINT `fk_networks__network_offering_id` FOREIGN KEY (`network_offering_id`) REFERENCES `network_offerings`(`id`),
|
CONSTRAINT `fk_networks__network_offering_id` FOREIGN KEY (`network_offering_id`) REFERENCES `network_offerings`(`id`),
|
||||||
CONSTRAINT `fk_networks__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`),
|
CONSTRAINT `fk_networks__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE,
|
||||||
CONSTRAINT `fk_networks__related` FOREIGN KEY(`related`) REFERENCES `networks`(`id`) ON DELETE CASCADE,
|
CONSTRAINT `fk_networks__related` FOREIGN KEY(`related`) REFERENCES `networks`(`id`) ON DELETE CASCADE,
|
||||||
CONSTRAINT `fk_networks__account_id` FOREIGN KEY(`account_id`) REFERENCES `account`(`id`),
|
CONSTRAINT `fk_networks__account_id` FOREIGN KEY(`account_id`) REFERENCES `account`(`id`),
|
||||||
CONSTRAINT `fk_networks__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`),
|
CONSTRAINT `fk_networks__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`),
|
||||||
@ -197,7 +197,7 @@ CREATE TABLE `cloud`.`network_tags` (
|
|||||||
`network_id` bigint unsigned NOT NULL COMMENT 'id of the network',
|
`network_id` bigint unsigned NOT NULL COMMENT 'id of the network',
|
||||||
`tag` varchar(255) NOT NULL COMMENT 'tag',
|
`tag` varchar(255) NOT NULL COMMENT 'tag',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
CONSTRAINT `fk_network_tags__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`),
|
CONSTRAINT `fk_network_tags__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE,
|
||||||
UNIQUE KEY(`network_id`, `tag`)
|
UNIQUE KEY(`network_id`, `tag`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ CREATE TABLE `cloud`.`cluster` (
|
|||||||
`allocation_state` varchar(32) NOT NULL DEFAULT 'Enabled' COMMENT 'Is this cluster enabled for allocation for new resources',
|
`allocation_state` varchar(32) NOT NULL DEFAULT 'Enabled' COMMENT 'Is this cluster enabled for allocation for new resources',
|
||||||
`removed` datetime COMMENT 'date removed if not null',
|
`removed` datetime COMMENT 'date removed if not null',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
CONSTRAINT `fk_cluster__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `cloud`.`data_center`(`id`),
|
CONSTRAINT `fk_cluster__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `cloud`.`data_center`(`id`) ON DELETE CASCADE,
|
||||||
CONSTRAINT `fk_cluster__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`),
|
CONSTRAINT `fk_cluster__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`),
|
||||||
UNIQUE `i_cluster__pod_id__name`(`pod_id`, `name`),
|
UNIQUE `i_cluster__pod_id__name`(`pod_id`, `name`),
|
||||||
INDEX `i_cluster__allocation_state`(`allocation_state`)
|
INDEX `i_cluster__allocation_state`(`allocation_state`)
|
||||||
@ -490,6 +490,7 @@ CREATE TABLE `cloud`.`data_center` (
|
|||||||
`is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not',
|
`is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not',
|
||||||
`allocation_state` varchar(32) NOT NULL DEFAULT 'Enabled' COMMENT 'Is this data center enabled for allocation for new resources',
|
`allocation_state` varchar(32) NOT NULL DEFAULT 'Enabled' COMMENT 'Is this data center enabled for allocation for new resources',
|
||||||
`zone_token` varchar(255),
|
`zone_token` varchar(255),
|
||||||
|
`removed` datetime COMMENT 'date removed if not null',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
CONSTRAINT `fk_data_center__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`),
|
CONSTRAINT `fk_data_center__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`),
|
||||||
INDEX `i_data_center__domain_id`(`domain_id`),
|
INDEX `i_data_center__domain_id`(`domain_id`),
|
||||||
@ -839,6 +840,7 @@ CREATE TABLE `cloud`.`vm_instance` (
|
|||||||
`created` datetime NOT NULL COMMENT 'date created',
|
`created` datetime NOT NULL COMMENT 'date created',
|
||||||
`removed` datetime COMMENT 'date removed if not null',
|
`removed` datetime COMMENT 'date removed if not null',
|
||||||
`type` varchar(32) NOT NULL COMMENT 'type of vm it is',
|
`type` varchar(32) NOT NULL COMMENT 'type of vm it is',
|
||||||
|
`vm_type` varchar(32) NOT NULL COMMENT 'vm type',
|
||||||
`account_id` bigint unsigned NOT NULL COMMENT 'user id of owner',
|
`account_id` bigint unsigned NOT NULL COMMENT 'user id of owner',
|
||||||
`domain_id` bigint unsigned NOT NULL,
|
`domain_id` bigint unsigned NOT NULL,
|
||||||
`service_offering_id` bigint unsigned NOT NULL COMMENT 'service offering id',
|
`service_offering_id` bigint unsigned NOT NULL COMMENT 'service offering id',
|
||||||
|
|||||||
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