change associatesUcsProfileToBlade to async api

This commit is contained in:
frank 2013-07-25 15:25:06 -07:00
parent 784bef766c
commit 4191f157c1
5 changed files with 22 additions and 3 deletions

View File

@ -443,6 +443,8 @@ public class EventTypes {
public static final String EVENT_DEDICATE_RESOURCE_RELEASE = "DEDICATE.RESOURCE.RELEASE";
public static final String EVENT_CLEANUP_VM_RESERVATION = "VM.RESERVATION.CLEANUP";
public static final String EVENT_UCS_ASSOCIATED_PROFILE = "UCS.ASSOCIATEPROFILE";
static {

View File

@ -608,6 +608,7 @@ listBaremetalPxePingServer=1
#### UCS commands
addUcsManager=1
listUcsManager=1
listUcsProfile=1
listUcsBlade=1
associatesUcsProfileToBlade=1

View File

@ -322,6 +322,11 @@ public class UcsManagerImpl implements UcsManager {
String res = client.call(cmd);
XmlObject xo = XmlObjectParser.parseFromString(res);
s_logger.debug(String.format("association response is %s", res));
if (xo.get("outConfig.computeBlade.association").equals("none")) {
throw new CloudRuntimeException(String.format("cannot associated a profile to blade[dn:%s]. please check your UCS manasger for detailed error information", dn));
}
return xo.get("outConfig.computeBlade.association").equals("associated");
}

View File

@ -29,6 +29,7 @@ import org.apache.cloudstack.api.response.UcsBladeResponse;
import org.apache.cloudstack.api.response.UcsManagerResponse;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
@ -37,7 +38,7 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.ucs.manager.UcsManager;
import com.cloud.user.Account;
@APICommand(name="associatesUcsProfileToBlade", description="associate a profile to a blade", responseObject=UcsBladeResponse.class)
public class AssociateUcsProfileToBladeCmd extends BaseCmd {
public class AssociateUcsProfileToBladeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(AssociateUcsProfileToBladeCmd.class);
@Inject
@ -96,4 +97,14 @@ public class AssociateUcsProfileToBladeCmd extends BaseCmd {
public void setBladeId(Long bladeId) {
this.bladeId = bladeId;
}
@Override
public String getEventType() {
return EventTypes.EVENT_UCS_ASSOCIATED_PROFILE;
}
@Override
public String getEventDescription() {
return "associating a ucs profile to blade";
}
}

4
utils/src/com/cloud/utils/xmlobject/XmlObject.java Normal file → Executable file
View File

@ -50,10 +50,10 @@ public class XmlObject {
elements.put(key, e);
} else {
if (old instanceof List) {
System.out.println(String.format("already list %s, add", key));
//System.out.println(String.format("already list %s, add", key));
((List)old).add(e);
} else {
System.out.println(String.format("not list list %s, add list", key));
//System.out.println(String.format("not list list %s, add list", key));
List lst = new ArrayList();
lst.add(old);
lst.add(e);