mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Api refactor:
* Moved ManagementServer interface from "core" to "server" package * Changed AddConfig, UpdateCfg, UpdateAccount commands
This commit is contained in:
parent
8825147f0d
commit
167433e562
@ -24,8 +24,10 @@ import com.cloud.api.BaseCmd;
|
|||||||
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.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
|
import com.cloud.configuration.ConfigurationVO;
|
||||||
|
import com.cloud.storage.DiskOfferingVO;
|
||||||
|
|
||||||
@Implementation(method="addConfig", manager=Manager.ManagementServer)
|
@Implementation(method="addConfig", manager=Manager.ConfigManager)
|
||||||
public class AddConfigCmd extends BaseCmd {
|
public class AddConfigCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(AddConfigCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(AddConfigCmd.class.getName());
|
||||||
|
|
||||||
@ -87,6 +89,7 @@ public class AddConfigCmd extends BaseCmd {
|
|||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
|
|||||||
@ -25,24 +25,19 @@ import java.util.Map;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
||||||
|
@Implementation(method="updateAccount", manager=Manager.ManagementServer)
|
||||||
public class UpdateAccountCmd extends BaseCmd{
|
public class UpdateAccountCmd extends BaseCmd{
|
||||||
public static final Logger s_logger = Logger.getLogger(UpdateAccountCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(UpdateAccountCmd.class.getName());
|
||||||
private static final String s_name = "updateaccountresponse";
|
private static final String s_name = "updateaccountresponse";
|
||||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||||
|
|
||||||
static {
|
|
||||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.NEW_NAME, Boolean.TRUE));
|
|
||||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT, Boolean.TRUE));
|
|
||||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.DOMAIN_ID, Boolean.TRUE));
|
|
||||||
|
|
||||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT_OBJ, Boolean.FALSE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
//////////////// API parameters /////////////////////
|
//////////////// API parameters /////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
@ -80,52 +75,48 @@ public class UpdateAccountCmd extends BaseCmd{
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public List<Pair<Enum, Boolean>> getProperties() {
|
|
||||||
return s_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
// public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||||
Long domainId = (Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
|
// Long domainId = (Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
|
||||||
String accountName = (String)params.get(BaseCmd.Properties.ACCOUNT.getName());
|
// String accountName = (String)params.get(BaseCmd.Properties.ACCOUNT.getName());
|
||||||
String newAccountName = (String)params.get(BaseCmd.Properties.NEW_NAME.getName());
|
// String newAccountName = (String)params.get(BaseCmd.Properties.NEW_NAME.getName());
|
||||||
Account adminAccount = (Account)params.get(BaseCmd.Properties.ACCOUNT_OBJ.getName());;
|
// Account adminAccount = (Account)params.get(BaseCmd.Properties.ACCOUNT_OBJ.getName());;
|
||||||
Boolean updateAccountResult = false;
|
// Boolean updateAccountResult = false;
|
||||||
Account account = null;
|
// Account account = null;
|
||||||
|
//
|
||||||
// check if account exists in the system
|
// // check if account exists in the system
|
||||||
account = getManagementServer().findAccountByName(accountName, domainId);
|
// account = getManagementServer().findAccountByName(accountName, domainId);
|
||||||
if (account == null) {
|
// if (account == null) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find account " + accountName + " in domain " + domainId);
|
// throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find account " + accountName + " in domain " + domainId);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if ((adminAccount != null) && !getManagementServer().isChildDomain(adminAccount.getDomainId(), account.getDomainId())) {
|
// if ((adminAccount != null) && !getManagementServer().isChildDomain(adminAccount.getDomainId(), account.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid account " + accountName + " in domain " + domainId + " given, unable to update account.");
|
// throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid account " + accountName + " in domain " + domainId + " given, unable to update account.");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// don't allow modify system account
|
// // don't allow modify system account
|
||||||
if (account.getId().longValue() == Account.ACCOUNT_ID_SYSTEM) {
|
// if (account.getId().longValue() == Account.ACCOUNT_ID_SYSTEM) {
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "can not modify system account");
|
// throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "can not modify system account");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
getManagementServer().updateAccount(account.getId(), newAccountName);
|
// getManagementServer().updateAccount(account.getId(), newAccountName);
|
||||||
account = getManagementServer().findAccountById(account.getId());
|
// account = getManagementServer().findAccountById(account.getId());
|
||||||
if (account.getAccountName().equals(newAccountName)) {
|
// if (account.getAccountName().equals(newAccountName)) {
|
||||||
updateAccountResult = true;
|
// updateAccountResult = true;
|
||||||
}
|
// }
|
||||||
} catch (Exception ex) {
|
// } catch (Exception ex) {
|
||||||
s_logger.error("Exception updating account", ex);
|
// s_logger.error("Exception updating account", ex);
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update account " + accountName + " in domain " + domainId + ": internal error.");
|
// throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update account " + accountName + " in domain " + domainId + ": internal error.");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
// List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
||||||
if (updateAccountResult == true) {
|
// if (updateAccountResult == true) {
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.SUCCESS.getName(), new Boolean(true)));
|
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.SUCCESS.getName(), new Boolean(true)));
|
||||||
} else {
|
// } else {
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update account " + accountName + " in domain " + domainId);
|
// throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update account " + accountName + " in domain " + domainId);
|
||||||
}
|
// }
|
||||||
return returnValues;
|
// return returnValues;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,23 +25,18 @@ import java.util.Map;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.user.User;
|
import com.cloud.user.User;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
||||||
|
@Implementation(method="updateConfiguration", manager=Manager.ConfigManager)
|
||||||
public class UpdateCfgCmd extends BaseCmd {
|
public class UpdateCfgCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(UpdateCfgCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(UpdateCfgCmd.class.getName());
|
||||||
|
|
||||||
private static final String s_name = "updateconfigurationresponse";
|
private static final String s_name = "updateconfigurationresponse";
|
||||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.NAME, Boolean.TRUE));
|
|
||||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.VALUE, Boolean.FALSE));
|
|
||||||
|
|
||||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.USER_ID, Boolean.FALSE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
//////////////// API parameters /////////////////////
|
//////////////// API parameters /////////////////////
|
||||||
@ -72,30 +67,27 @@ public class UpdateCfgCmd extends BaseCmd {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
public List<Pair<Enum, Boolean>> getProperties() {
|
|
||||||
return s_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
// public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||||
String name = (String) params.get(BaseCmd.Properties.NAME.getName());
|
// String name = (String) params.get(BaseCmd.Properties.NAME.getName());
|
||||||
String value = (String) params.get(BaseCmd.Properties.VALUE.getName());
|
// String value = (String) params.get(BaseCmd.Properties.VALUE.getName());
|
||||||
Long userId = (Long)params.get(BaseCmd.Properties.USER_ID.getName());
|
// Long userId = (Long)params.get(BaseCmd.Properties.USER_ID.getName());
|
||||||
|
//
|
||||||
if (userId == null) {
|
// if (userId == null) {
|
||||||
userId = Long.valueOf(User.UID_SYSTEM);
|
// userId = Long.valueOf(User.UID_SYSTEM);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
getManagementServer().updateConfiguration(userId, name, value);
|
// getManagementServer().updateConfiguration(userId, name, value);
|
||||||
} catch (Exception ex) {
|
// } catch (Exception ex) {
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
// throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
// List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.SUCCESS.getName(), "true"));
|
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.SUCCESS.getName(), "true"));
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.DISPLAY_TEXT.getName(), "Successfully updated configuration value."));
|
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.DISPLAY_TEXT.getName(), "Successfully updated configuration value."));
|
||||||
|
//
|
||||||
return returnValues;
|
// return returnValues;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,8 +19,10 @@ package com.cloud.configuration;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.cloud.api.commands.AddConfigCmd;
|
||||||
import com.cloud.api.commands.CreateDiskOfferingCmd;
|
import com.cloud.api.commands.CreateDiskOfferingCmd;
|
||||||
import com.cloud.api.commands.DeleteDiskOfferingCmd;
|
import com.cloud.api.commands.DeleteDiskOfferingCmd;
|
||||||
|
import com.cloud.api.commands.UpdateCfgCmd;
|
||||||
import com.cloud.api.commands.UpdateDiskOfferingCmd;
|
import com.cloud.api.commands.UpdateDiskOfferingCmd;
|
||||||
import com.cloud.api.commands.UpdateZoneCmd;
|
import com.cloud.api.commands.UpdateZoneCmd;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
@ -47,6 +49,16 @@ public interface ConfigurationManager extends Manager {
|
|||||||
*/
|
*/
|
||||||
void updateConfiguration(long userId, String name, String value) throws InvalidParameterValueException, InternalErrorException;
|
void updateConfiguration(long userId, String name, String value) throws InvalidParameterValueException, InternalErrorException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a configuration entry with a new value
|
||||||
|
* @param userId
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void updateConfiguration(UpdateCfgCmd cmd) throws InvalidParameterValueException, InternalErrorException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new service offering
|
* Creates a new service offering
|
||||||
* @param id
|
* @param id
|
||||||
@ -84,7 +96,7 @@ public interface ConfigurationManager extends Manager {
|
|||||||
* @param tags
|
* @param tags
|
||||||
* @return updated disk offering
|
* @return updated disk offering
|
||||||
*/
|
*/
|
||||||
DiskOfferingVO updateDiskOffering(UpdateDiskOfferingCmd cmd);
|
DiskOfferingVO updateDiskOffering(UpdateDiskOfferingCmd cmd) throws InvalidParameterValueException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a disk offering
|
* Deletes a disk offering
|
||||||
@ -238,5 +250,5 @@ public interface ConfigurationManager extends Manager {
|
|||||||
* @param description
|
* @param description
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean addConfig(String instance, String component,String category, String name, String value, String description);
|
public boolean addConfig(AddConfigCmd cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,8 +33,10 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
|
import com.cloud.api.commands.AddConfigCmd;
|
||||||
import com.cloud.api.commands.CreateDiskOfferingCmd;
|
import com.cloud.api.commands.CreateDiskOfferingCmd;
|
||||||
import com.cloud.api.commands.DeleteDiskOfferingCmd;
|
import com.cloud.api.commands.DeleteDiskOfferingCmd;
|
||||||
|
import com.cloud.api.commands.UpdateCfgCmd;
|
||||||
import com.cloud.api.commands.UpdateDiskOfferingCmd;
|
import com.cloud.api.commands.UpdateDiskOfferingCmd;
|
||||||
import com.cloud.api.commands.UpdateZoneCmd;
|
import com.cloud.api.commands.UpdateZoneCmd;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
@ -158,6 +160,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, "Successfully edited configuration value.", "name=" + name, "value=" + value);
|
saveConfigurationEvent(userId, null, EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, "Successfully edited configuration value.", "name=" + name, "value=" + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateConfiguration(UpdateCfgCmd cmd) throws InvalidParameterValueException, InternalErrorException{
|
||||||
|
long userId = UserContext.current().getUserId();
|
||||||
|
String name = cmd.getName();
|
||||||
|
String value = cmd.getValue();
|
||||||
|
updateConfiguration (userId, name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private String validateConfigurationValue(String name, String value) throws InvalidParameterValueException {
|
private String validateConfigurationValue(String name, String value) throws InvalidParameterValueException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
@ -921,18 +930,25 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||||||
return _diskOfferingDao.persist(newDiskOffering);
|
return _diskOfferingDao.persist(newDiskOffering);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiskOfferingVO updateDiskOffering(UpdateDiskOfferingCmd cmd) {
|
public DiskOfferingVO updateDiskOffering(UpdateDiskOfferingCmd cmd) throws InvalidParameterValueException{
|
||||||
Long diskOfferingId = cmd.getId();
|
Long diskOfferingId = cmd.getId();
|
||||||
String name = cmd.getName();
|
String name = cmd.getName();
|
||||||
String displayText = cmd.getDisplayText();
|
String displayText = cmd.getDisplayText();
|
||||||
String tags = cmd.getTags();
|
String tags = cmd.getTags();
|
||||||
|
|
||||||
|
//Check if diskOffering exists
|
||||||
|
DiskOfferingVO diskOffering = _diskOfferingDao.findById(diskOfferingId);
|
||||||
|
|
||||||
|
if (diskOffering == null) {
|
||||||
|
throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
|
||||||
|
}
|
||||||
|
|
||||||
boolean updateNeeded = (name != null || displayText != null || tags != null);
|
boolean updateNeeded = (name != null || displayText != null || tags != null);
|
||||||
if (!updateNeeded) {
|
if (!updateNeeded) {
|
||||||
return _diskOfferingDao.findById(diskOfferingId);
|
return _diskOfferingDao.findById(diskOfferingId);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskOfferingVO diskOffering = _diskOfferingDao.createForUpdate(diskOfferingId);
|
diskOffering = _diskOfferingDao.createForUpdate(diskOfferingId);
|
||||||
|
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
diskOffering.setName(name);
|
diskOffering.setName(name);
|
||||||
@ -1735,8 +1751,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addConfig(String instance, String component,String category, String name, String value, String description)
|
public boolean addConfig(AddConfigCmd cmd){
|
||||||
{
|
String category = cmd.getCategory();
|
||||||
|
String instance = cmd.getInstance();
|
||||||
|
String component = cmd.getComponent();
|
||||||
|
String name = cmd.getName();
|
||||||
|
String value = cmd.getValue();
|
||||||
|
String description = cmd.getDescription();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ConfigurationVO entity = new ConfigurationVO(category, instance, component, name, value, description);
|
ConfigurationVO entity = new ConfigurationVO(category, instance, component, name, value, description);
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.cloud.alert.AlertVO;
|
import com.cloud.alert.AlertVO;
|
||||||
|
import com.cloud.api.commands.UpdateAccountCmd;
|
||||||
import com.cloud.async.AsyncJobResult;
|
import com.cloud.async.AsyncJobResult;
|
||||||
import com.cloud.async.AsyncJobVO;
|
import com.cloud.async.AsyncJobVO;
|
||||||
import com.cloud.capacity.CapacityVO;
|
import com.cloud.capacity.CapacityVO;
|
||||||
@ -98,6 +99,7 @@ import com.cloud.vm.VMInstanceVO;
|
|||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.VmStats;
|
import com.cloud.vm.VmStats;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManagementServer is the interface to talk to the Managment Server.
|
* ManagementServer is the interface to talk to the Managment Server.
|
||||||
* This will be the line drawn between the UI and MS. If we need to build
|
* This will be the line drawn between the UI and MS. If we need to build
|
||||||
@ -223,7 +225,7 @@ public interface ManagementServer {
|
|||||||
* @return true if update was successful, false otherwise
|
* @return true if update was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
boolean updateAccount(long accountId, String accountName);
|
boolean updateAccount(UpdateAccountCmd cmd) throws InvalidParameterValueException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables a user by userId
|
* Enables a user by userId
|
||||||
@ -1030,20 +1032,20 @@ public interface ManagementServer {
|
|||||||
*/
|
*/
|
||||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String dns3, String dns4, String vnetRange, String guestCidr) throws InvalidParameterValueException, InternalErrorException;
|
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String dns3, String dns4, String vnetRange, String guestCidr) throws InvalidParameterValueException, InternalErrorException;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Edits a zone in the database
|
// * Edits a zone in the database
|
||||||
* @param userId
|
// * @param userId
|
||||||
* @param zoneId
|
// * @param zoneId
|
||||||
* @param newZoneName
|
// * @param newZoneName
|
||||||
* @param dns1
|
// * @param dns1
|
||||||
* @param dns2
|
// * @param dns2
|
||||||
* @param dns3
|
// * @param dns3
|
||||||
* @param dns4
|
// * @param dns4
|
||||||
* @param vnetRange range of the vnet to add to the zone.
|
// * @param vnetRange range of the vnet to add to the zone.
|
||||||
* @param guestNetworkCidr
|
// * @param guestNetworkCidr
|
||||||
* @return Zone
|
// * @return Zone
|
||||||
*/
|
// */
|
||||||
DataCenterVO editZone(long userId, Long zoneId, String newZoneName, String dns1, String dns2, String dns3, String dns4, String vnetRange, String guestCidr) throws InvalidParameterValueException, InternalErrorException;
|
// DataCenterVO editZone(long userId, Long zoneId, String newZoneName, String dns1, String dns2, String dns3, String dns4, String vnetRange, String guestCidr) throws InvalidParameterValueException, InternalErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a zone from the database
|
* Deletes a zone from the database
|
||||||
@ -1436,7 +1438,7 @@ public interface ManagementServer {
|
|||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void updateConfiguration(long userId, String name, String value) throws InvalidParameterValueException, InternalErrorException;
|
// void updateConfiguration(long userId, String name, String value) throws InvalidParameterValueException, InternalErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates or updates an IP forwarding or load balancer rule.
|
* Creates or updates an IP forwarding or load balancer rule.
|
||||||
@ -2132,7 +2134,7 @@ public interface ManagementServer {
|
|||||||
|
|
||||||
boolean checkLocalStorageConfigVal();
|
boolean checkLocalStorageConfigVal();
|
||||||
|
|
||||||
boolean addConfig(String instance, String component, String category, String name, String value, String description);
|
// boolean addConfig(String instance, String component, String category, String name, String value, String description);
|
||||||
|
|
||||||
boolean validateCustomVolumeSizeRange(long size) throws InvalidParameterValueException;
|
boolean validateCustomVolumeSizeRange(long size) throws InvalidParameterValueException;
|
||||||
}
|
}
|
||||||
@ -76,6 +76,7 @@ import com.cloud.api.commands.ReconnectHostCmd;
|
|||||||
import com.cloud.api.commands.StartRouterCmd;
|
import com.cloud.api.commands.StartRouterCmd;
|
||||||
import com.cloud.api.commands.StartSystemVMCmd;
|
import com.cloud.api.commands.StartSystemVMCmd;
|
||||||
import com.cloud.api.commands.StartVMCmd;
|
import com.cloud.api.commands.StartVMCmd;
|
||||||
|
import com.cloud.api.commands.UpdateAccountCmd;
|
||||||
import com.cloud.api.commands.UpgradeVMCmd;
|
import com.cloud.api.commands.UpgradeVMCmd;
|
||||||
import com.cloud.async.AsyncInstanceCreateStatus;
|
import com.cloud.async.AsyncInstanceCreateStatus;
|
||||||
import com.cloud.async.AsyncJobExecutor;
|
import com.cloud.async.AsyncJobExecutor;
|
||||||
@ -1137,15 +1138,41 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateAccount(long accountId, String accountName) {
|
public boolean updateAccount(UpdateAccountCmd cmd) throws InvalidParameterValueException{
|
||||||
|
Long domainId = cmd.getDomainId();
|
||||||
|
String accountName = cmd.getAccountName();
|
||||||
|
String newAccountName = cmd.getNewName();
|
||||||
|
|
||||||
|
if (newAccountName == null) {
|
||||||
|
newAccountName = accountName;
|
||||||
|
}
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
AccountVO account = _accountDao.findById(accountId);
|
Account account = _accountDao.findAccount(accountName, domainId);
|
||||||
if ((account == null) || (account.getAccountName().equals(accountName))) {
|
|
||||||
|
//Check if account exists
|
||||||
|
if (account == null) {
|
||||||
|
s_logger.error("Unable to find account " + accountName + " in domain " + domainId);
|
||||||
|
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Don't allow to modify system account
|
||||||
|
if (account.getId().longValue() == Account.ACCOUNT_ID_SYSTEM) {
|
||||||
|
throw new InvalidParameterValueException ("Can not modify system account");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check if user performing the action is allowed to modify this account
|
||||||
|
Account adminAccount = (Account)UserContext.current().getAccountObject();
|
||||||
|
if ((adminAccount != null) && isChildDomain(adminAccount.getDomainId(), account.getDomainId())) {
|
||||||
|
throw new InvalidParameterValueException("Invalid account " + accountName + " in domain " + domainId + " given, unable to update account.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (account.getAccountName().equals(accountName)) {
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
AccountVO acctForUpdate = _accountDao.createForUpdate();
|
AccountVO acctForUpdate = _accountDao.createForUpdate();
|
||||||
acctForUpdate.setAccountName(accountName);
|
acctForUpdate.setAccountName(newAccountName);
|
||||||
success = _accountDao.update(Long.valueOf(accountId), acctForUpdate);
|
success = _accountDao.update(Long.valueOf(account.getId()), acctForUpdate);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@ -4204,11 +4231,6 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
return _hostPodDao.listByDataCenterId(dataCenterId);
|
return _hostPodDao.listByDataCenterId(dataCenterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateConfiguration(long userId, String name, String value) throws InvalidParameterValueException, InternalErrorException {
|
|
||||||
_configMgr.updateConfiguration(userId, name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean useVirtualNetwork, String tags) {
|
public ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean useVirtualNetwork, String tags) {
|
||||||
return _configMgr.createServiceOffering(userId, name, cpu, ramSize, speed, displayText, localStorageRequired, offerHA, useVirtualNetwork, tags);
|
return _configMgr.createServiceOffering(userId, name, cpu, ramSize, speed, displayText, localStorageRequired, offerHA, useVirtualNetwork, tags);
|
||||||
@ -4240,10 +4262,10 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
return _configMgr.createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr);
|
return _configMgr.createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public DataCenterVO editZone(long userId, Long zoneId, String newZoneName, String dns1, String dns2, String dns3, String dns4, String vnetRange, String guestCidr) throws InvalidParameterValueException, InternalErrorException {
|
// public DataCenterVO editZone(long userId, Long zoneId, String newZoneName, String dns1, String dns2, String dns3, String dns4, String vnetRange, String guestCidr) throws InvalidParameterValueException, InternalErrorException {
|
||||||
return _configMgr.editZone(userId, zoneId, newZoneName, dns1, dns2, dns3, dns4, vnetRange, guestCidr);
|
// return _configMgr.editZone(userId, zoneId, newZoneName, dns1, dns2, dns3, dns4, vnetRange, guestCidr);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteZone(long userId, Long zoneId) throws InvalidParameterValueException, InternalErrorException {
|
public void deleteZone(long userId, Long zoneId) throws InvalidParameterValueException, InternalErrorException {
|
||||||
@ -8185,12 +8207,6 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addConfig(String instance, String component,String category, String name, String value, String description)
|
|
||||||
{
|
|
||||||
return _configMgr.addConfig(category, instance, component, name, value, description);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean preparePrimaryStorageForMaintenance(long primaryStorageId, long userId) {
|
public boolean preparePrimaryStorageForMaintenance(long primaryStorageId, long userId) {
|
||||||
return _storageMgr.preparePrimaryStorageForMaintenance(primaryStorageId, userId);
|
return _storageMgr.preparePrimaryStorageForMaintenance(primaryStorageId, userId);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user