Merge remote-tracking branch 'apache/4.15'

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
Abhishek Kumar 2021-05-24 16:43:53 +05:30
commit 4b7fa4e630
11 changed files with 57 additions and 56 deletions

View File

@ -131,6 +131,9 @@ public enum Status {
s_fsm.addTransition(Status.Up, Event.PingTimeout, Status.Alert);
s_fsm.addTransition(Status.Up, Event.AgentDisconnected, Status.Alert);
s_fsm.addTransition(Status.Up, Event.ShutdownRequested, Status.Disconnected);
s_fsm.addTransition(Status.Disconnected, Event.ShutdownRequested, Status.Disconnected);
s_fsm.addTransition(Status.Down, Event.ShutdownRequested, Status.Disconnected);
s_fsm.addTransition(Status.Rebalancing, Event.ShutdownRequested, Status.Disconnected);
s_fsm.addTransition(Status.Up, Event.HostDown, Status.Down);
s_fsm.addTransition(Status.Up, Event.Ping, Status.Up);
s_fsm.addTransition(Status.Up, Event.AgentConnected, Status.Connecting);

View File

@ -20,6 +20,8 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Displayable;
@ -186,6 +188,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Partition,
}
}
static final Set<Type> systemVMs = new HashSet<>(Arrays.asList(VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm));
static final String IsDynamicScalingEnabled = "enable.dynamic.scaling";
public enum Event {

View File

@ -183,7 +183,7 @@ public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
if (!hypervisor.equalsIgnoreCase(Hypervisor.HypervisorType.VMware.toString()) && osTypeId == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Missing parameter ostypeid");
}
if (hypervisor.equalsIgnoreCase(Hypervisor.HypervisorType.VMware.toString()) && osTypeId != null) {
if (hypervisor.equalsIgnoreCase(Hypervisor.HypervisorType.VMware.toString()) && deployAsIs && osTypeId != null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid parameter ostypeid, not applicable for VMware");
}
}

View File

@ -43,6 +43,7 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import com.cloud.api.ApiDBUtils;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.command.admin.vm.MigrateVMCmd;
@ -2087,6 +2088,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
s_logger.warn("Unable to actually stop " + vm + " but continue with release because it's a force stop");
vmGuru.finalizeStop(profile, answer);
}
} else {
if (VirtualMachine.systemVMs.contains(vm.getType())) {
HostVO systemVmHost = ApiDBUtils.findHostByTypeNameAndZoneId(vm.getDataCenterId(), vm.getHostName(),
VirtualMachine.Type.SecondaryStorageVm.equals(vm.getType()) ? Host.Type.SecondaryStorageVM : Host.Type.ConsoleProxy);
if (systemVmHost != null) {
_agentMgr.agentStatusTransitTo(systemVmHost, Status.Event.ShutdownRequested, _nodeId);
}
}
}
}

View File

@ -2086,9 +2086,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
VirtualMachineDiskInfo matchingExistingDisk = getMatchingExistingDisk(diskInfoBuilder, vol, hyperHost, context);
controllerKey = getDiskController(matchingExistingDisk, vol, vmSpec, ideControllerKey, scsiControllerKey);
String diskController = getDiskController(vmMo, matchingExistingDisk, vol, controllerInfo);
String diskController = getDiskController(vmMo, matchingExistingDisk, vol, controllerInfo, deployAsIs);
if (DiskControllerType.getType(diskController) == DiskControllerType.osdefault) {
diskController = vmMo.getRecommendedDiskController(null);
}
@ -3298,47 +3296,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
return null;
}
private int getDiskController(VirtualMachineDiskInfo matchingExistingDisk, DiskTO vol, VirtualMachineTO vmSpec, int ideControllerKey, int scsiControllerKey) {
int controllerKey;
if (matchingExistingDisk != null) {
s_logger.info("Chose disk controller based on existing information: " + matchingExistingDisk.getDiskDeviceBusName());
if (matchingExistingDisk.getDiskDeviceBusName().startsWith("ide"))
return ideControllerKey;
else
return scsiControllerKey;
}
if (vol.getType() == Volume.Type.ROOT) {
Map<String, String> vmDetails = vmSpec.getDetails();
if (vmDetails != null && vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER) != null) {
if (vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER).equalsIgnoreCase("scsi")) {
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> scsi, based on root disk controller settings: "
+ vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER));
controllerKey = scsiControllerKey;
} else {
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> ide, based on root disk controller settings: "
+ vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER));
controllerKey = ideControllerKey;
}
} else {
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> scsi. due to null root disk controller setting");
controllerKey = scsiControllerKey;
}
} else {
// DATA volume always use SCSI device
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> scsi");
controllerKey = scsiControllerKey;
}
return controllerKey;
}
private String getDiskController(VirtualMachineMO vmMo, VirtualMachineDiskInfo matchingExistingDisk, DiskTO vol, Pair<String, String> controllerInfo) throws Exception {
int controllerKey;
private String getDiskController(VirtualMachineMO vmMo, VirtualMachineDiskInfo matchingExistingDisk, DiskTO vol, Pair<String, String> controllerInfo, boolean deployAsIs) throws Exception {
DiskControllerType controllerType = DiskControllerType.none;
if (matchingExistingDisk != null) {
if (deployAsIs && matchingExistingDisk != null) {
String currentBusName = matchingExistingDisk.getDiskDeviceBusName();
if (currentBusName != null) {
s_logger.info("Chose disk controller based on existing information: " + currentBusName);

View File

@ -1456,7 +1456,7 @@ public class ApiResponseHelper implements ResponseGenerator {
}
}
if (vm.getType() == Type.SecondaryStorageVm || vm.getType() == Type.ConsoleProxy) {
if (VirtualMachine.systemVMs.contains(vm.getType())) {
Host systemVmHost = ApiDBUtils.findHostByTypeNameAndZoneId(vm.getDataCenterId(), vm.getHostName(),
Type.SecondaryStorageVm.equals(vm.getType()) ? Host.Type.SecondaryStorageVM : Host.Type.ConsoleProxy);
if (systemVmHost != null) {

View File

@ -2554,6 +2554,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
String extraConfig = cmd.getExtraConfig();
UserVmVO vmInstance = _vmDao.findById(cmd.getId());
if (MapUtils.isNotEmpty(details) || cmd.isCleanupDetails()) {
VMTemplateVO template = _templateDao.findById(vmInstance.getTemplateId());
if (template != null && template.isDeployAsIs()) {
throw new CloudRuntimeException("Detail settings are read from OVA, it cannot be changed by API call.");
}
}
long accountId = vmInstance.getAccountId();
if (isDisplayVm != null && isDisplayVm != vmInstance.isDisplay()) {

View File

@ -2968,6 +2968,8 @@
"message.move.acl.order.failed": "Failed to move ACL rule",
"message.move.acl.order.processing": "Moving ACL rule...",
"message.ncc.delete.confirm": "Please confirm you want to delete this NCC",
"message.network.acl.default.allow": "Warning: With this policy all traffic will be allowed through the firewall to this VPC tier. You should consider securing your network.",
"message.network.acl.default.deny": "Warning: With this policy all traffic will be denied through the firewall to this VPC tier. In order to allow traffic through you will need to change policies.",
"message.network.addvm.desc": "Please specify the network that you would like to add this VM to. A new NIC will be added for this network.",
"message.network.addvmnic": "Please confirm that you would like to add a new VM NIC for this network.",
"message.network.description": "Setup network and traffic",

View File

@ -80,11 +80,12 @@
slot="actions"
v-if="!disableSettings && 'updateTemplate' in $store.getters.apis &&
'updateVirtualMachine' in $store.getters.apis && isAdminOrOwner() && allowEditOfDetail(item.name)">
<tootip-button :tooltip="$t('label.cancel')" @click="hideEditDetail(index)" v-if="item.edit" iconType="close-circle" iconTwoToneColor="#f5222d" />
<tootip-button :tooltip="$t('label.ok')" @click="updateDetail(index)" v-if="item.edit" iconType="check-circle" iconTwoToneColor="#52c41a" />
<tooltip-button :tooltip="$t('label.cancel')" @click="hideEditDetail(index)" v-if="item.edit" iconType="close-circle" iconTwoToneColor="#f5222d" />
<tooltip-button :tooltip="$t('label.ok')" @click="updateDetail(index)" v-if="item.edit" iconType="check-circle" iconTwoToneColor="#52c41a" />
<tooltip-button
:tooltip="$t('label.edit')"
icon="edit"
:disabled="deployasistemplate === true"
v-if="!item.edit"
@click="showEditDetail(index)" />
</div>
@ -99,7 +100,7 @@
:cancelText="$t('label.no')"
placement="left"
>
<tooltip-button :tooltip="$t('label.delete')" type="danger" icon="delete" />
<tooltip-button :tooltip="$t('label.delete')" :disabled="deployasistemplate === true" type="danger" icon="delete" />
</a-popconfirm>
</div>
</a-list-item>
@ -130,6 +131,7 @@ export default {
newValue: '',
loading: false,
resourceType: 'UserVm',
deployasistemplate: false,
error: false
}
},
@ -163,6 +165,9 @@ export default {
this.detailOptions = json.listdetailoptionsresponse.detailoptions.details
})
this.disableSettings = (this.$route.meta.name === 'vm' && this.resource.state !== 'Stopped')
api('listTemplates', { templatefilter: 'all', id: this.resource.templateid }).then(json => {
this.deployasistemplate = json.listtemplatesresponse.template[0].deployasis
})
},
filterOrReadOnlyDetails () {
for (var i = 0; i < this.details.length; i++) {

View File

@ -176,7 +176,7 @@
<a-form-item :label="$t('label.aclid')">
<a-select v-decorator="['acl']">
<a-select-option v-for="item in networkAcls" :key="item.id" :value="item.id">
{{ item.name }}
<strong>{{ item.name }}</strong> ({{ item.description }})
</a-select-option>
</a-select>
</a-form-item>

View File

@ -204,12 +204,20 @@
v-decorator="['externalId']"></a-input>
</a-form-item>
<a-form-item :label="$t('label.aclid')">
<a-select v-decorator="['acl']">
<a-select
v-decorator="['acl',{rules: [{ required: true, message: `${$t('label.required')}` }]}]"
@change="val => { this.handleNetworkAclChange(val) }">
<a-select-option v-for="item in networkAclList" :key="item.id" :value="item.id">
{{ item.name }}
<strong>{{ item.name }}</strong> ({{ item.description }})
</a-select-option>
</a-select>
</a-form-item>
<a-alert v-if="this.selectedNetworkAcl.name==='default_allow'" type="warning" show-icon>
<span slot="message" v-html="$t('message.network.acl.default.allow')" />
</a-alert>
<a-alert v-else-if="this.selectedNetworkAcl.name==='default_deny'" type="warning" show-icon>
<span slot="message" v-html="$t('message.network.acl.default.deny')" />
</a-alert>
</a-form>
</a-spin>
</a-modal>
@ -293,6 +301,7 @@ export default {
showAddInternalLB: false,
networkOfferings: [],
networkAclList: [],
selectedNetworkAcl: {},
modalLoading: false,
internalLB: {},
LBPublicIPs: {},
@ -430,11 +439,7 @@ export default {
this.modalLoading = true
api('listNetworkACLLists', { vpcid: this.resource.id }).then(json => {
this.networkAclList = json.listnetworkacllistsresponse.networkacllist || []
this.$nextTick(function () {
this.form.setFieldsValue({
acl: this.networkAclList[0].id
})
})
this.handleNetworkAclChange(null)
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
@ -541,6 +546,13 @@ export default {
handleNetworkOfferingChange (networkOfferingId) {
this.selectedNetworkOffering = this.networkOfferings.filter(offering => offering.id === networkOfferingId)[0]
},
handleNetworkAclChange (aclId) {
if (aclId) {
this.selectedNetworkAcl = this.networkAclList.filter(acl => acl.id === aclId)[0]
} else {
this.selectedNetworkAcl = {}
}
},
closeModal () {
this.$emit('close-action')
},