Merge branch '3.0.x' of ssh://git.cloud.com/var/lib/git/cloudstack-oss into 3.0.x

This commit is contained in:
Pranav Saxena 2012-07-25 03:12:28 +05:30
commit 17268517bb
28 changed files with 4734 additions and 97 deletions

View File

@ -36,6 +36,9 @@ public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=false, description="name of this customer gateway")
private String name;
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="public ip address id of the customer gateway")
private String gatewayIp;
@ -70,6 +73,10 @@ public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd {
return "s2s_customer_gateway";
}
public String getName() {
return name;
}
public String getIpsecPsk() {
return ipsecPsk;
}

View File

@ -44,6 +44,13 @@ public class ListAutoScalePoliciesCmd extends BaseListAccountResourcesCmd {
@Parameter(name = ApiConstants.CONDITION_ID, type = CommandType.LONG, description = "the ID of the condition of the policy")
private Long conditionId;
@Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, required = true, description = "the action to be executed if all the conditions evaluate to true for the specified duration.")
private String action;
@IdentityMapper(entityTableName="autoscale_vmgroups")
@Parameter(name = ApiConstants.VMGROUP_ID, type = CommandType.LONG, description = "the ID of the autoscale vm group")
private Long vmGroupId;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@ -56,6 +63,13 @@ public class ListAutoScalePoliciesCmd extends BaseListAccountResourcesCmd {
return conditionId;
}
public String getAction() {
return action;
}
public Long getVmGroupId() {
return vmGroupId;
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////

View File

@ -49,6 +49,9 @@ public class ListConditionsCmd extends BaseListAccountResourcesCmd {
@Parameter(name = ApiConstants.COUNTER_ID, type = CommandType.LONG, required = false, description = "Counter-id of the condition.")
private Long counterId;
@IdentityMapper(entityTableName="autoscale_policies")
@Parameter(name = ApiConstants.POLICY_ID, type = CommandType.LONG, description = "the ID of the policy")
private Long policyId;
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@ -81,6 +84,10 @@ public class ListConditionsCmd extends BaseListAccountResourcesCmd {
return counterId;
}
public Long getPolicyId() {
return policyId;
}
@Override
public String getCommandName() {
return s_name;

View File

@ -24,6 +24,9 @@ public class Site2SiteCustomerGatewayResponse extends BaseResponse implements Co
@SerializedName(ApiConstants.ID) @Param(description="the vpn gateway ID")
private IdentityProxy id = new IdentityProxy("s2s_customer_gateway");
@SerializedName(ApiConstants.NAME) @Param(description="name of the customer gateway")
private String name;
@SerializedName(ApiConstants.GATEWAY) @Param(description="public ip address id of the customer gateway")
private String gatewayIp;
@ -58,6 +61,10 @@ public class Site2SiteCustomerGatewayResponse extends BaseResponse implements Co
this.id.setValue(id);
}
public void setName(String name) {
this.name = name;
}
public void setGatewayIp(String gatewayIp) {
this.gatewayIp = gatewayIp;
}

View File

@ -10,4 +10,5 @@ public interface Site2SiteCustomerGateway extends ControlledEntity {
public String getGuestCidrList();
public String getIpsecPsk();
public Date getRemoved();
String getName();
}

View File

@ -890,9 +890,9 @@ public class VirtualRoutingResource implements Manager {
throw new ConfigurationException("Unable to find bumpUpPriority.sh");
}
_routerProxyPath = findScript("routerProxy.sh");
_routerProxyPath = findScript("router_proxy.sh");
if (_routerProxyPath == null) {
throw new ConfigurationException("Unable to find routerProxy.sh");
throw new ConfigurationException("Unable to find router_proxy.sh");
}
return true;

View File

@ -13,7 +13,6 @@
package com.cloud.network.resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Formatter;
import java.util.HashMap;
import java.util.List;
@ -282,7 +281,7 @@ public class NetscalerResource implements ServerResource {
return;
}
try {
String[] features = _netscalerService.get_enabled_features();
String[] features = login_get_service(true).get_enabled_features();
if (features != null) {
for (String feature : features) {
if (feature.equalsIgnoreCase("LB")) {
@ -294,7 +293,7 @@ public class NetscalerResource implements ServerResource {
// enable load balancing on the device
String[] feature = new String[1];
feature[0] = "LB";
apiCallResult = _netscalerService.enable_features(feature);
apiCallResult = login_get_service(true).enable_features(feature);
if (apiCallResult.errorcode != 0) {
throw new ExecutionException("Enabling load balancing feature on the device failed.");
}
@ -466,18 +465,31 @@ public class NetscalerResource implements ServerResource {
return autoScalePolicyTO.getAction().equals("scaledown");
}
private long allocateNextAvailablePriority(List<Long> priorities) {
long cur_prirotiy = 1;
Collections.sort(priorities);
for (Long priority : priorities) {
if(cur_prirotiy != priority) {
priorities.add(cur_prirotiy);
return cur_prirotiy;
}
cur_prirotiy++;
private void removeAutoScalePolicy(String timerName, String policyName) throws Exception {
// unbind timer policy
// unbbind timer trigger lb_astimer -policyName lb_policy_scaleUp
com.citrix.netscaler.nitro.resource.config.timer.timertrigger_timerpolicy_binding timer_policy_binding = new com.citrix.netscaler.nitro.resource.config.timer.timertrigger_timerpolicy_binding();
try {
timer_policy_binding.set_name(timerName);
timer_policy_binding.set_policyname(policyName);
timer_policy_binding.set_global("DEFAULT");
timer_policy_binding.delete(login_get_service(true), timer_policy_binding);
} catch (Exception e) {
// Ignore Exception
throw e;
}
priorities.add(cur_prirotiy);;
return cur_prirotiy;
// Removing Timer policy
// rm timer policy lb_policy_scaleUp_cpu_mem
com.citrix.netscaler.nitro.resource.config.timer.timerpolicy timerPolicy = new com.citrix.netscaler.nitro.resource.config.timer.timerpolicy();
try {
timerPolicy.set_name(policyName);
timerPolicy.delete(login_get_service(true), timerPolicy);
} catch (Exception e) {
// Ignore Exception
throw e;
}
}
@SuppressWarnings("static-access")
@ -542,9 +554,18 @@ public class NetscalerResource implements ServerResource {
String scaleUpActionName = generateAutoScaleScaleUpActionName(srcIp, srcPort);
String mtName = generateSnmpMetricTableName(srcIp, srcPort);
String monitorName = generateSnmpMonitorName(srcIp, srcPort);
String serviceGroupName = generateAutoScaleServiceGroupName(srcIp, srcPort);
AutoScaleVmGroupTO vmGroupTO = loadBalancerTO.getAutoScaleVmGroupTO();
List<AutoScalePolicyTO> policies = vmGroupTO.getPolicies();
/* Delete min/max member policies */
String minMemberPolicyName = generateAutoScaleMinPolicyName(srcIp, srcPort);
removeAutoScalePolicy(timerName, minMemberPolicyName);
String maxMemberPolicyName = generateAutoScaleMaxPolicyName(srcIp, srcPort);
removeAutoScalePolicy(timerName, maxMemberPolicyName);
boolean isSnmp = false;
/* Create Counters */
for (AutoScalePolicyTO autoScalePolicyTO : policies) {
@ -558,27 +579,9 @@ public class NetscalerResource implements ServerResource {
}
String policyId = Long.toString(autoScalePolicyTO.getId());
String policyName = generateAutoScalePolicyName(srcIp, srcPort,policyId);
// unbind timer policy
// unbbind timer trigger lb_astimer -policyName lb_policy_scaleUp
com.citrix.netscaler.nitro.resource.config.timer.timertrigger_timerpolicy_binding timer_policy_binding = new com.citrix.netscaler.nitro.resource.config.timer.timertrigger_timerpolicy_binding();
try {
timer_policy_binding.set_name(timerName);
timer_policy_binding.set_policyname(policyName);
timer_policy_binding.delete(login_get_service(true), timer_policy_binding);
} catch (Exception e) {
// Ignore Exception
throw e;
}
// Removing Timer policy
// rm timer policy lb_policy_scaleUp_cpu_mem
com.citrix.netscaler.nitro.resource.config.timer.timerpolicy timerPolicy = new com.citrix.netscaler.nitro.resource.config.timer.timerpolicy();
try {
timerPolicy.set_name(policyName);
timerPolicy.delete(login_get_service(true), timerPolicy);
} catch (Exception e) {
// Ignore Exception
throw e;
}
removeAutoScalePolicy(timerName, policyName);
}
/* Delete AutoScale Config */
@ -623,11 +626,22 @@ public class NetscalerResource implements ServerResource {
}
if(isSnmp) {
com.citrix.netscaler.nitro.resource.config.lb.lbmonitor_servicegroup_binding monitor_servicegroup_binding = new com.citrix.netscaler.nitro.resource.config.lb.lbmonitor_servicegroup_binding();
try {
monitor_servicegroup_binding.set_monitorname(monitorName);
monitor_servicegroup_binding.set_servicegroupname(serviceGroupName);
monitor_servicegroup_binding.delete(login_get_service(true), monitor_servicegroup_binding);
} catch (Exception e) {
// Ignore Exception
throw e;
}
// Delete Monitor
// rm lb monitor lb_metric_table_mon
com.citrix.netscaler.nitro.resource.config.lb.lbmonitor monitor = new com.citrix.netscaler.nitro.resource.config.lb.lbmonitor();
try {
monitor.set_monitorname(monitorName);
monitor.set_type("LOAD");
monitor.delete(login_get_service(true), monitor);
} catch (Exception e) {
// Ignore Exception
@ -637,7 +651,7 @@ public class NetscalerResource implements ServerResource {
// Delete Metric Table
com.citrix.netscaler.nitro.resource.config.lb.lbmetrictable metricTable = new com.citrix.netscaler.nitro.resource.config.lb.lbmetrictable();
try {
metricTable.set_metric(mtName);
metricTable.set_metrictable(mtName);
metricTable.delete(login_get_service(true), metricTable);
} catch (Exception e) {
// Ignore Exception
@ -715,13 +729,11 @@ public class NetscalerResource implements ServerResource {
int interval = vmGroupTO.getInterval();
int snmpPort = profileTO.getSnmpPort();
String snmpCommunity = profileTO.getSnmpCommunity();
ArrayList<Long> priorities = new ArrayList<Long>();
long cur_prirotiy = 1;
// Set min and max autoscale members;
// add lb vserver lb http 10.102.31.100 80 -minAutoscaleMinMembers 3 -maxAutoscaleMembers 10
/*
int minAutoScaleMembers = vmGroupTO.getMinMembers();
int maxAutoScaleMembers = vmGroupTO.getMaxMembers();
com.citrix.netscaler.nitro.resource.config.lb.lbvserver lbvserver = new com.citrix.netscaler.nitro.resource.config.lb.lbvserver();
@ -734,7 +746,6 @@ public class NetscalerResource implements ServerResource {
// Ignore Exception
throw e;
}
*/
/* AutoScale Config */
// Add AutoScale Profile
@ -755,7 +766,7 @@ public class NetscalerResource implements ServerResource {
} catch (Exception e) {
// Ignore Exception
// throw e;
throw e;
}
// Add Timer
@ -841,7 +852,7 @@ public class NetscalerResource implements ServerResource {
interval, interval);
/* Create max member policy */
String maxMemberPolicyName = generateAutoScaleMinPolicyName(srcIp, srcPort);
String maxMemberPolicyName = generateAutoScaleMaxPolicyName(srcIp, srcPort);
String maxMemberPolicyExp = "SYS.VSERVER(\"" + nsVirtualServerName + "\").ACTIVESERVICES.GT(SYS.VSERVER(\"" + nsVirtualServerName + "\").MAXAUTOSCALEMEMBERS)";
addAutoScalePolicy(timerName, maxMemberPolicyName, cur_prirotiy++, maxMemberPolicyExp, scaleDownActionName,
interval, interval);
@ -2023,14 +2034,6 @@ public class NetscalerResource implements ServerResource {
vserver.set_persistencetype("NONE");
}
}
if(vmGroupTO != null) {
vserver.set_minautoscalemembers(vmGroupTO.getMinMembers());
vserver.set_maxautoscalemembers(vmGroupTO.getMaxMembers());
vserver.set_mysqlcharacterset(null);
vserver.set_mysqlprotocolversion(null);
vserver.set_mysqlservercapabilities(null);
vserver.set_mssqlserverversion(null);
}
if (vserverExisis) {
apiCallResult = lbvserver.update(login_get_service(vmGroupTO != null),vserver);
@ -2251,4 +2254,7 @@ public class NetscalerResource implements ServerResource {
return;
}
}

Binary file not shown.

View File

@ -3902,6 +3902,7 @@ public class ApiResponseHelper implements ResponseGenerator {
public Site2SiteCustomerGatewayResponse createSite2SiteCustomerGatewayResponse(Site2SiteCustomerGateway result) {
Site2SiteCustomerGatewayResponse response = new Site2SiteCustomerGatewayResponse();
response.setId(result.getId());
response.setName(result.getName());
response.setGatewayIp(result.getGatewayIp());
response.setGuestCidrList(result.getGuestCidrList());
response.setIpsecPsk(result.getIpsecPsk());

View File

@ -23,6 +23,9 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway {
@Column(name="uuid")
private String uuid;
@Column(name="name")
private String name;
@Column(name="gateway_ip")
private String gatewayIp;
@ -52,7 +55,8 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway {
public Site2SiteCustomerGatewayVO() { }
public Site2SiteCustomerGatewayVO(long accountId, long domainId, String gatewayIp, String guestCidrList, String ipsecPsk, String ikePolicy, String espPolicy, long lifetime) {
public Site2SiteCustomerGatewayVO(String name, long accountId, long domainId, String gatewayIp, String guestCidrList, String ipsecPsk, String ikePolicy, String espPolicy, long lifetime) {
this.name = name;
this.gatewayIp = gatewayIp;
this.guestCidrList = guestCidrList;
this.ipsecPsk = ipsecPsk;
@ -69,6 +73,15 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway {
return id;
}
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String getGatewayIp() {
return gatewayIp;

View File

@ -43,7 +43,9 @@ import com.cloud.api.commands.ListCountersCmd;
import com.cloud.api.commands.UpdateAutoScalePolicyCmd;
import com.cloud.api.commands.UpdateAutoScaleVmGroupCmd;
import com.cloud.api.commands.UpdateAutoScaleVmProfileCmd;
import com.cloud.configuration.Config;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.DataCenter;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.event.ActionEvent;
@ -127,6 +129,8 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
@Inject
UserDao _userDao;
@Inject
ConfigurationDao _configDao;
@Inject
IPAddressDao _ipAddressDao;
@Override
@ -168,7 +172,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
for (Counter counter : counters) {
if (!supportedCounters.contains(counter.getSource().name().toString())) {
throw new InvalidParameterException("AutoScale counter with source='" + counter.getSource() + "' is not supported " +
"in the network where lb is configured");
"in the network where lb is configured");
}
}
}
@ -258,11 +262,27 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
throw new InvalidParameterValueException("Destroy Vm Grace Period cannot be less than 0.");
}
User autoscaleUser = _userDao.findById(autoscaleUserId);
if (autoscaleUser.getAccountId() != vmProfile.getAccountId()) {
User user = _userDao.findById(autoscaleUserId);
if (user.getAccountId() != vmProfile.getAccountId()) {
throw new InvalidParameterValueException("AutoScale User id does not belong to the same account");
}
String apiKey = user.getApiKey();
String secretKey = user.getSecretKey();
String csUrl = _configDao.getValue(Config.EndpointeUrl.key());
if(apiKey == null) {
throw new InvalidParameterValueException("apiKey for user: " + user.getUsername() + " is empty. Please generate it");
}
if(secretKey == null) {
throw new InvalidParameterValueException("secretKey for user: " + user.getUsername() + " is empty. Please generate it");
}
if(csUrl == null || csUrl.contains("localhost")) {
throw new InvalidParameterValueException("Global setting endpointe.url has to be set to the Management Server's API end point");
}
vmProfile = _autoScaleVmProfileDao.persist(vmProfile);
return vmProfile;
@ -304,6 +324,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
autoscaleUserId = UserContext.current().getCallerUserId();
}
AutoScaleVmProfileVO profileVO = new AutoScaleVmProfileVO(cmd.getZoneId(), cmd.getDomainId(), cmd.getAccountId(), cmd.getServiceOfferingId(), cmd.getTemplateId(), cmd.getOtherDeployParams(),
cmd.getSnmpCommunity(), cmd.getSnmpPort(), cmd.getDestroyVmGraceperiod(), autoscaleUserId);
profileVO = checkValidityAndPersist(profileVO);
@ -542,7 +563,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
Account caller = UserContext.current().getCaller();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean,
ListProjectResourcesCriteria>(domainId, isRecursive, null);
ListProjectResourcesCriteria>(domainId, isRecursive, null);
_accountMgr.buildACLSearchParameters(caller, id, accountName, null, permittedAccounts, domainIdRecursiveListProject,
listAll, false);
domainId = domainIdRecursiveListProject.first();
@ -574,8 +595,11 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
SearchBuilder<AutoScalePolicyVO> sb = searchWrapper.getSearchBuilder();
Long id = cmd.getId();
Long conditionId = cmd.getConditionId();
String action = cmd.getAction();
Long vmGroupId = cmd.getVmGroupId();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("action", sb.entity().getAction(), SearchCriteria.Op.EQ);
if (conditionId != null) {
SearchBuilder<AutoScalePolicyConditionMapVO> asPolicyConditionSearch = _autoScalePolicyConditionMapDao.createSearchBuilder();
@ -583,15 +607,30 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
sb.join("asPolicyConditionSearch", asPolicyConditionSearch, sb.entity().getId(), asPolicyConditionSearch.entity().getPolicyId(), JoinBuilder.JoinType.INNER);
}
if (vmGroupId != null) {
SearchBuilder<AutoScaleVmGroupPolicyMapVO> asVmGroupPolicySearch = _autoScaleVmGroupPolicyMapDao.createSearchBuilder();
asVmGroupPolicySearch.and("vmGroupId", asVmGroupPolicySearch.entity().getVmGroupId(), SearchCriteria.Op.EQ);
sb.join("asVmGroupPolicySearch", asVmGroupPolicySearch, sb.entity().getId(), asVmGroupPolicySearch.entity().getPolicyId(), JoinBuilder.JoinType.INNER);
}
SearchCriteria<AutoScalePolicyVO> sc = searchWrapper.buildSearchCriteria();
if (id != null) {
sc.setParameters("id", id);
}
if (action != null) {
sc.setParameters("action", action);
}
if (conditionId != null) {
sc.setJoinParameters("asPolicyConditionSearch", "conditionId", conditionId);
}
if (vmGroupId != null) {
sc.setJoinParameters("asVmGroupPolicySearch", "vmGroupId", vmGroupId);
}
return searchWrapper.search();
}
@ -682,7 +721,11 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
AutoScaleVmGroup vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
if (isLoadBalancerBasedAutoScaleVmGroup(vmGroup)) {
return _lbRulesMgr.configureLbAutoScaleVmGroup(vmGroupid);
try {
return _lbRulesMgr.configureLbAutoScaleVmGroup(vmGroupid);
} catch (RuntimeException re) {
s_logger.warn("Exception during configureLbAutoScaleVmGrouop in lb rules manager", re);
}
}
// This should never happen, because today loadbalancerruleid is manadatory for AutoScaleVmGroup.
@ -1011,8 +1054,14 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
public List<? extends Condition> listConditions(ListConditionsCmd cmd) {
Long id = cmd.getId();
Long counterId = cmd.getCounterId();
Long policyId = cmd.getPolicyId();
SearchWrapper<ConditionVO> searchWrapper = new SearchWrapper<ConditionVO>(_conditionDao, ConditionVO.class, cmd, cmd.getId());
SearchBuilder<ConditionVO> sb = searchWrapper.getSearchBuilder();
if (policyId != null) {
SearchBuilder<AutoScalePolicyConditionMapVO> asPolicyConditionSearch = _autoScalePolicyConditionMapDao.createSearchBuilder();
asPolicyConditionSearch.and("policyId", asPolicyConditionSearch.entity().getPolicyId(), SearchCriteria.Op.EQ);
sb.join("asPolicyConditionSearch", asPolicyConditionSearch, sb.entity().getId(), asPolicyConditionSearch.entity().getConditionId(), JoinBuilder.JoinType.INNER);
}
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("counterId", sb.entity().getCounterid(), SearchCriteria.Op.EQ);
@ -1028,6 +1077,10 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
sc.setParameters("counterId", counterId);
}
if (policyId != null) {
sc.setJoinParameters("asPolicyConditionSearch", "policyId", policyId);
}
return searchWrapper.search();
}

View File

@ -5,4 +5,5 @@ import com.cloud.utils.db.GenericDao;
public interface Site2SiteCustomerGatewayDao extends GenericDao<Site2SiteCustomerGatewayVO, Long> {
Site2SiteCustomerGatewayVO findByGatewayIp(String ip);
Site2SiteCustomerGatewayVO findByName(String name);
}

View File

@ -18,6 +18,7 @@ public class Site2SiteCustomerGatewayDaoImpl extends GenericDaoBase<Site2SiteCus
protected Site2SiteCustomerGatewayDaoImpl() {
AllFieldsSearch = createSearchBuilder();
AllFieldsSearch.and("gatewayIp", AllFieldsSearch.entity().getGatewayIp(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), SearchCriteria.Op.EQ);
AllFieldsSearch.done();
}
@ -28,4 +29,11 @@ public class Site2SiteCustomerGatewayDaoImpl extends GenericDaoBase<Site2SiteCus
return findOneBy(sc);
}
@Override
public Site2SiteCustomerGatewayVO findByName(String name) {
SearchCriteria<Site2SiteCustomerGatewayVO> sc = AllFieldsSearch.create();
sc.setParameters("name", name);
return findOneBy(sc);
}
}

View File

@ -259,6 +259,18 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
String secretKey = user.getSecretKey();
String csUrl = _configDao.getValue(Config.EndpointeUrl.key());
if(apiKey == null) {
throw new InvalidParameterValueException("apiKey for user: " + user.getUsername() + " is empty. Please generate it");
}
if(secretKey == null) {
throw new InvalidParameterValueException("secretKey for user: " + user.getUsername() + " is empty. Please generate it");
}
if(csUrl == null || csUrl.contains("localhost")) {
throw new InvalidParameterValueException("Global setting endpointe.url has to be set to the Management Server's API end point");
}
LbAutoScaleVmProfile lbAutoScaleVmProfile = new LbAutoScaleVmProfile(autoScaleVmProfile, apiKey, secretKey, csUrl);
return new LbAutoScaleVmGroup(vmGroup, autoScalePolicies, lbAutoScaleVmProfile);
}

View File

@ -1283,6 +1283,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
super.finalizeStop(profile, answer);
//Mark VPN connections as Disconnected
DomainRouterVO router = profile.getVirtualMachine();
_s2sVpnMgr.markDisconnectVpnConnByVpc(router.getVpcId());
Long vpcId = router.getVpcId();
if (vpcId != null) {
_s2sVpnMgr.markDisconnectVpnConnByVpc(vpcId);
}
}
}

View File

@ -113,10 +113,14 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
@Override
public Site2SiteCustomerGateway createCustomerGateway(CreateVpnCustomerGatewayCmd cmd) {
String name = cmd.getName();
String gatewayIp = cmd.getGatewayIp();
if (!NetUtils.isValidIp(gatewayIp)) {
throw new InvalidParameterValueException("The customer gateway ip " + gatewayIp + " is invalid!");
}
if (name == null) {
name = "VPN-" + gatewayIp;
}
String guestCidrList = cmd.getGuestCidrList();
if (!NetUtils.validateGuestCidrList(guestCidrList)) {
throw new InvalidParameterValueException("The customer gateway guest cidr list " + guestCidrList + " is invalid guest cidr!");
@ -141,12 +145,15 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
if (_customerGatewayDao.findByGatewayIp(gatewayIp) != null) {
throw new InvalidParameterValueException("The customer gateway with ip " + gatewayIp + " already existed!");
}
if (_customerGatewayDao.findByName(name) != null) {
throw new InvalidParameterValueException("The customer gateway with name " + name + " already existed!");
}
Long accountId = cmd.getEntityOwnerId();
Long domainId = cmd.getDomainId();
if (domainId == null) {
domainId = Domain.ROOT_DOMAIN;
}
Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO(accountId, domainId, gatewayIp, guestCidrList, ipsecPsk,
Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO(name, accountId, domainId, gatewayIp, guestCidrList, ipsecPsk,
ikePolicy, espPolicy, lifetime);
_customerGatewayDao.persist(gw);
return gw;
@ -344,6 +351,7 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
stopVpnConnection(id);
}
startVpnConnection(id);
conn = _vpnConnectionDao.findById(id);
return conn;
}

View File

@ -1785,19 +1785,6 @@ public class ManagementServerImpl implements ManagementServer {
vlanType = VlanType.VirtualNetwork;
}
// don't show SSVM/CPVM ips
boolean omitSystemVmIps = false;
if (vlanType == VlanType.VirtualNetwork && (allocatedOnly) && vpcId == null) {
SearchBuilder<NicVO> nonSystemVmSearch = _nicDao.createSearchBuilder();
nonSystemVmSearch.and().op("vmTypeNnull", nonSystemVmSearch.entity().getVmType(), Op.NULL);
nonSystemVmSearch.or("vmType", nonSystemVmSearch.entity().getVmType(), Op.NOTIN);
nonSystemVmSearch.cp();
sb.join("nonSystemVms", nonSystemVmSearch, sb.entity().getAddress(),
nonSystemVmSearch.entity().getIp4Address(), JoinType.LEFTOUTER);
omitSystemVmIps = true;
}
SearchCriteria<IPAddressVO> sc = sb.create();
if (isAllocated) {
_accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
@ -1814,10 +1801,6 @@ public class ManagementServerImpl implements ManagementServer {
count++;
}
}
if (omitSystemVmIps) {
sc.setJoinParameters("nonSystemVms", "vmType", VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
}
if (zone != null) {
sc.setParameters("dataCenterId", zone);

View File

@ -582,12 +582,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
return null;
}
@Override
public PhysicalNetwork translateZoneIdToPhysicalNetwork(long zoneId) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isSecurityGroupSupportedInNetwork(Network network) {
// TODO Auto-generated method stub
@ -1089,4 +1083,13 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.cloud.network.NetworkManager#ipUsedInVpc(com.cloud.network.IpAddress)
*/
@Override
public boolean ipUsedInVpc(IpAddress ip) {
// TODO Auto-generated method stub
return false;
}
}

View File

@ -22,14 +22,15 @@ import org.junit.Before;
import com.cloud.upgrade.dao.VersionDaoImpl;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.db.DbTestUtils;
public class Upgarde304to305Test extends TestCase{
public class Upgrade304to305Test extends TestCase{
private static final Logger s_logger = Logger.getLogger(AdvanceZone217To224UpgradeTest.class);
@Override
@Before
public void setUp() throws Exception {
//DbTestUtils.executeScript("PreviousDatabaseSchema/304/cloud_304.sql", false, true);
DbTestUtils.executeScript("test/dbupgrade/cloud_304.sql", false, true);
}
@Override

View File

@ -2161,6 +2161,7 @@ CREATE TABLE `cloud`.`s2s_vpn_gateway` (
CREATE TABLE `cloud`.`s2s_customer_gateway` (
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
`uuid` varchar(40),
`name` varchar(255) NOT NULL,
`gateway_ip` char(40) NOT NULL,
`guest_cidr_list` varchar(200) NOT NULL,
`ipsec_psk` varchar(256),

View File

@ -280,3 +280,56 @@ CREATE TABLE `cloud`.`autoscale_vmgroup_policy_map` (
CONSTRAINT `fk_autoscale_vmgroup_policy_map__policy_id` FOREIGN KEY `fk_autoscale_vmgroup_policy_map__policy_id` (`policy_id`) REFERENCES `autoscale_policies` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`s2s_vpn_gateway` (
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
`uuid` varchar(40),
`addr_id` bigint unsigned NOT NULL,
`vpc_id` bigint unsigned NOT NULL,
`domain_id` bigint unsigned NOT NULL,
`account_id` bigint unsigned NOT NULL,
`removed` datetime COMMENT 'date removed if not null',
PRIMARY KEY (`id`),
CONSTRAINT `fk_s2s_vpn_gateway__addr_id` FOREIGN KEY (`addr_id`) REFERENCES `user_ip_address` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_s2s_vpn_gateway__vpc_id` FOREIGN KEY (`vpc_id`) REFERENCES `vpc` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_s2s_vpn_gateway__account_id` FOREIGN KEY (`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_s2s_vpn_gateway__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE,
CONSTRAINT `uc_s2s_vpn_gateway__uuid` UNIQUE (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`s2s_customer_gateway` (
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
`uuid` varchar(40),
`name` varchar(255) NOT NULL,
`gateway_ip` char(40) NOT NULL,
`guest_cidr_list` varchar(200) NOT NULL,
`ipsec_psk` varchar(256),
`ike_policy` varchar(30) NOT NULL,
`esp_policy` varchar(30) NOT NULL,
`lifetime` int,
`domain_id` bigint unsigned NOT NULL,
`account_id` bigint unsigned NOT NULL,
`removed` datetime COMMENT 'date removed if not null',
PRIMARY KEY (`id`),
CONSTRAINT `fk_s2s_customer_gateway__account_id` FOREIGN KEY (`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_s2s_customer_gateway__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE,
CONSTRAINT `uc_s2s_customer_gateway__uuid` UNIQUE (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`s2s_vpn_connection` (
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
`uuid` varchar(40),
`vpn_gateway_id` bigint unsigned NULL,
`customer_gateway_id` bigint unsigned NULL,
`state` varchar(32) NOT NULL,
`domain_id` bigint unsigned NOT NULL,
`account_id` bigint unsigned NOT NULL,
`created` datetime NOT NULL COMMENT 'date created',
`removed` datetime COMMENT 'date removed if not null',
PRIMARY KEY (`id`),
CONSTRAINT `fk_s2s_vpn_connection__vpn_gateway_id` FOREIGN KEY (`vpn_gateway_id`) REFERENCES `s2s_vpn_gateway` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_s2s_vpn_connection__customer_gateway_id` FOREIGN KEY (`customer_gateway_id`) REFERENCES `s2s_customer_gateway` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_s2s_vpn_connection__account_id` FOREIGN KEY (`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_s2s_vpn_connection__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE,
CONSTRAINT `uc_s2s_vpn_connection__uuid` UNIQUE (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

4395
test/dbupgrade/cloud_304.sql Normal file

File diff suppressed because one or more lines are too long

View File

@ -2208,6 +2208,9 @@
addButton: true
}
},
tags: cloudStack.api.tags({ resourceType: 'LoadBalancer', contextId: 'multiRule' }),
add: {
label: 'label.add.vms',
action: function(args) {
@ -2657,6 +2660,9 @@
addButton: true
}
},
tags: cloudStack.api.tags({ resourceType: 'PortForwardingRule', contextId: 'multiRule' }),
add: {
label: 'label.add.vm',
action: function(args) {
@ -2705,6 +2711,19 @@
}
},
actions: {
edit: {
label: 'label.edit',
// Blank -- edit is just for tags right now
action: function(args) {
args.response.success({
notification: {
label: 'label.edit.pf',
poll: function(args) { args.complete(); }
}
});
}
},
destroy: {
label: 'label.remove.pf',
action: function(args) {
@ -3754,6 +3773,9 @@
id: { label: 'label.id' }
}
],
tags: cloudStack.api.tags({ resourceType: 'Vpc', contextId: 'vpc' }),
dataProvider: function(args) {
$.ajax({
url: createURL("listVPCs"),

View File

@ -663,7 +663,7 @@ cloudStack.api = {
args.response.success({
_custom: { jobId: json.createtagsresponse.jobid },
notification: {
desc: 'Add tag for instance',
desc: 'Add tag for ' + resourceType,
poll: pollAsyncJobResult
}
});
@ -687,7 +687,7 @@ cloudStack.api = {
args.response.success({
_custom: { jobId: json.deletetagsresponse.jobid },
notification: {
desc: 'Remove tag for instance',
desc: 'Remove tag for ' + resourceType,
poll: pollAsyncJobResult
}
});
@ -697,14 +697,18 @@ cloudStack.api = {
},
dataProvider: function(args) {
var resourceId = args.context[contextId][0].id;
var data = {
resourceId: resourceId,
resourceType: resourceType
};
if (args.context.projects) {
data.projectid=args.context.projects[0].id;
}
$.ajax({
url: createURL('listTags'),
data: {
listAll: true,
resourceId: resourceId,
resourceType: resourceType
},
data: data,
success: function(json) {
args.response.success({
data: json.listtagsresponse ?

View File

@ -300,7 +300,6 @@
$detailView.find('.ui-tabs-panel .detail-group.actions')
).fadeIn();
$detailView.find('.tagger').removeClass('readonly');
$detailView.find('.tagger').find('input[type=text]').val('');
var convertInputs = function($inputs) {
@ -344,8 +343,6 @@
}
//Remove required labels
$detailView.find('span.field-required').remove();
$detailView.find('.tagger').addClass('readonly');
};
// Put in original values
@ -959,7 +956,7 @@
$.extend(true, {}, tabs.tags, {
context: $detailView.data('view-args').context
})
).appendTo($detailView.find('.main-groups')).addClass('readonly');
).appendTo($detailView.find('.main-groups'));
}
return true;

View File

@ -334,8 +334,12 @@
});
if (options.tags) {
$(':ui-dialog').append(
$('<div>').addClass('multi-edit-tags').tagger(options.tags)
$(':ui-dialog:last').append(
$('<div>').addClass('multi-edit-tags').tagger($.extend(true, {}, options.tags, {
context: $.extend(true, {}, options.context, {
multiRule: [multiRule]
})
}))
);
}
}

View File

@ -276,7 +276,7 @@
cloudStack.ui.event.call('addNotification', {
section: notification.section,
desc: notification.desc,
interval: 5000,
interval: notification.interval ? notification.interval : 5000,
_custom: notification._custom,
poll: function(args) {
var complete = args.complete;

View File

@ -77,6 +77,9 @@
addButton: true
}
},
tags: cloudStack.api.tags({ resourceType: 'NetworkACL', contextId: 'multiRule' }),
add: {
label: 'Add',
action: function(args) {
@ -104,6 +107,19 @@
}
},
actions: {
edit: {
label: 'label.edit',
// Blank -- edit is just for tags right now
action: function(args) {
args.response.success({
notification: {
label: 'Edit ACL item',
poll: function(args) { args.complete(); }
}
});
}
},
destroy: {
label: 'Remove ACL',
action: function(args) {
@ -589,6 +605,9 @@
addButton: true
}
},
tags: cloudStack.api.tags({ resourceType: 'StaticRoute', contextId: 'multiRule' }),
add: {
label: 'Add',
action: function(args) {
@ -616,6 +635,19 @@
}
},
actions: {
edit: {
label: 'label.edit',
// Blank -- edit is just for tags right now
action: function(args) {
args.response.success({
notification: {
label: 'Edit static route',
poll: function(args) { args.complete(); }
}
});
}
},
destroy: {
label: 'Remove static route',
action: function(args) {
@ -878,6 +910,7 @@
created: { label: 'label.date', converter: cloudStack.converters.toLocalDate }
}
],
dataProvider: function(args) {
$.ajax({
url: createURL("listVpnConnections&id=" + args.context.vpnConnection[0].id),