Skip to content

Commit 42738c2

Browse files
author
frank
committed
change associatesUcsProfileToBlade to async api
1 parent a39de00 commit 42738c2

5 files changed

Lines changed: 22 additions & 3 deletions

File tree

api/src/com/cloud/event/EventTypes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ public class EventTypes {
444444
public static final String EVENT_DEDICATE_RESOURCE_RELEASE = "DEDICATE.RESOURCE.RELEASE";
445445

446446
public static final String EVENT_CLEANUP_VM_RESERVATION = "VM.RESERVATION.CLEANUP";
447+
448+
public static final String EVENT_UCS_ASSOCIATED_PROFILE = "UCS.ASSOCIATEPROFILE";
447449

448450
static {
449451

client/tomcatconf/commands.properties.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ listBaremetalPxePingServer=1
608608

609609
#### UCS commands
610610
addUcsManager=1
611+
listUcsManager=1
611612
listUcsProfile=1
612613
listUcsBlade=1
613614
associatesUcsProfileToBlade=1

plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ private boolean isProfileAssociated(Long ucsMgrId, String dn) {
322322
String res = client.call(cmd);
323323
XmlObject xo = XmlObjectParser.parseFromString(res);
324324
s_logger.debug(String.format("association response is %s", res));
325+
326+
if (xo.get("outConfig.computeBlade.association").equals("none")) {
327+
throw new CloudRuntimeException(String.format("cannot associated a profile to blade[dn:%s]. please check your UCS manasger for detailed error information", dn));
328+
}
329+
325330
return xo.get("outConfig.computeBlade.association").equals("associated");
326331
}
327332

plugins/hypervisors/ucs/src/org/apache/cloudstack/api/AssociateUcsProfileToBladeCmd.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.cloudstack.api.response.UcsManagerResponse;
3030
import org.apache.log4j.Logger;
3131

32+
import com.cloud.event.EventTypes;
3233
import com.cloud.exception.ConcurrentOperationException;
3334
import com.cloud.exception.InsufficientCapacityException;
3435
import com.cloud.exception.NetworkRuleConflictException;
@@ -37,7 +38,7 @@
3738
import com.cloud.ucs.manager.UcsManager;
3839
import com.cloud.user.Account;
3940
@APICommand(name="associatesUcsProfileToBlade", description="associate a profile to a blade", responseObject=UcsBladeResponse.class)
40-
public class AssociateUcsProfileToBladeCmd extends BaseCmd {
41+
public class AssociateUcsProfileToBladeCmd extends BaseAsyncCmd {
4142
public static final Logger s_logger = Logger.getLogger(AssociateUcsProfileToBladeCmd.class);
4243

4344
@Inject
@@ -96,4 +97,14 @@ public Long getBladeId() {
9697
public void setBladeId(Long bladeId) {
9798
this.bladeId = bladeId;
9899
}
100+
101+
@Override
102+
public String getEventType() {
103+
return EventTypes.EVENT_UCS_ASSOCIATED_PROFILE;
104+
}
105+
106+
@Override
107+
public String getEventDescription() {
108+
return "associating a ucs profile to blade";
109+
}
99110
}

utils/src/com/cloud/utils/xmlobject/XmlObject.java

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ public XmlObject putElement(String key, Object e) {
5050
elements.put(key, e);
5151
} else {
5252
if (old instanceof List) {
53-
System.out.println(String.format("already list %s, add", key));
53+
//System.out.println(String.format("already list %s, add", key));
5454
((List)old).add(e);
5555
} else {
56-
System.out.println(String.format("not list list %s, add list", key));
56+
//System.out.println(String.format("not list list %s, add list", key));
5757
List lst = new ArrayList();
5858
lst.add(old);
5959
lst.add(e);

0 commit comments

Comments
 (0)