Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.zstack.core.db.Q;
import org.zstack.core.errorcode.ErrorFacade;
import org.zstack.header.allocator.*;
import org.zstack.header.apimediator.ApiMessageInterceptionException;
import org.zstack.header.core.ReturnValueCompletion;
import org.zstack.header.errorcode.ErrorCode;
import org.zstack.header.errorcode.OperationFailureException;
Expand Down Expand Up @@ -144,6 +145,8 @@ private void runFlow(AbstractHostAllocatorFlow flow) {
} else {
fail(ofe.getErrorCode());
}
} catch (ApiMessageInterceptionException e) {
fail(e.getError());
} catch (Throwable t) {
logger.warn("unhandled throwable", t);
String errMsg = t != null ? t.toString() : "unknown error";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public void allocate() {

throwExceptionIfIAmTheFirstFlow();

// skip quota check if the operator is admin
String sessionAccountUuid = spec.getSessionAccountUuid();
if (sessionAccountUuid != null && AccountConstant.isAdminPermission(sessionAccountUuid)) {
next(candidates);
return;
}

final String vmInstanceUuid = spec.getVmInstance().getUuid();
final String accountUuid = Account.getAccountUuidOfResource(vmInstanceUuid);
if (accountUuid == null || AccountConstant.isAdminPermission(accountUuid)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class AllocateHostMsg extends NeedReplyMessage {
private long oldMemoryCapacity = 0;
private AllocationScene allocationScene;
private String architecture;
private String sessionAccountUuid;

public List<Set<String>> getOptionalPrimaryStorageUuids() {
return optionalPrimaryStorageUuids;
Expand Down Expand Up @@ -211,4 +212,12 @@ public String getArchitecture() {
public void setArchitecture(String architecture) {
this.architecture = architecture;
}

public String getSessionAccountUuid() {
return sessionAccountUuid;
}

public void setSessionAccountUuid(String sessionAccountUuid) {
this.sessionAccountUuid = sessionAccountUuid;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class HostAllocatorSpec {
private long oldMemoryCapacity = 0;
private AllocationScene allocationScene;
private String architecture;
private String sessionAccountUuid;

public AllocationScene getAllocationScene() {
return allocationScene;
Expand Down Expand Up @@ -222,6 +223,14 @@ public void setArchitecture(String architecture) {
this.architecture = architecture;
}

public String getSessionAccountUuid() {
return sessionAccountUuid;
}

public void setSessionAccountUuid(String sessionAccountUuid) {
this.sessionAccountUuid = sessionAccountUuid;
}

public static HostAllocatorSpec fromAllocationMsg(AllocateHostMsg msg) {
HostAllocatorSpec spec = new HostAllocatorSpec();
spec.setAllocatorStrategy(msg.getAllocatorStrategy());
Expand Down Expand Up @@ -250,6 +259,7 @@ public static HostAllocatorSpec fromAllocationMsg(AllocateHostMsg msg) {
msg.getOptionalPrimaryStorageUuids().forEach(spec::addOptionalPrimaryStorageUuids);
spec.setAllocationScene(msg.getAllocationScene());
spec.setArchitecture(msg.getArchitecture());
spec.setSessionAccountUuid(msg.getSessionAccountUuid());
if (msg.getSystemTags() != null && !msg.getSystemTags().isEmpty()){
spec.setSystemTags(new ArrayList<String>(msg.getSystemTags()));
}
Expand Down