}
autoScalePolicies.add(new LbAutoScalePolicy(autoScalePolicy, lbConditions));
}
AutoScaleVmProfile autoScaleVmProfile = _autoScaleVmProfileDao.findById(vmGroup.getProfileId());
Long autoscaleUserId = autoScaleVmProfile.getAutoScaleUserId();
User user = _userDao.findByIdIncludingRemoved(autoscaleUserId);
String apiKey = user.getApiKey();
String secretKey = user.getSecretKey();
String csUrl = _configDao.getValue(Config.EndpointeUrl.key());
String zoneId = _dcDao.findById(autoScaleVmProfile.getZoneId()).getUuid();
String domainId = _domainDao.findById(autoScaleVmProfile.getDomainId()).getUuid();
String serviceOfferingId = _offeringsDao.findById(autoScaleVmProfile.getServiceOfferingId()).getUuid();
String templateId = _templateDao.findById(autoScaleVmProfile.getTemplateId()).getUuid();
String vmName = "AutoScale-LB-" + lbName;
String lbNetworkUuid = null;
DataCenter zone = _configMgr.getZone(vmGroup.getZoneId());
if (zone == null) {
// This should never happen, but still a cautious check
s_logger.warn("Unable to find zone while packaging AutoScale Vm Group, zoneid: " + vmGroup.getZoneId());
throw new InvalidParameterValueException("Unable to find zone");
} else {
if (zone.getNetworkType() == NetworkType.Advanced) {
NetworkVO lbNetwork = _networkDao.findById(lbNetworkId);
lbNetworkUuid = lbNetwork.getUuid();
}
}
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(