Skip to content
Merged
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 @@ -4329,7 +4329,9 @@ public NicProfile createNicForVm(final Network network, final NicProfile request
if (nic == null || vmProfile.getType() == VirtualMachine.Type.User) {
final int deviceId = _nicDao.getFreeDeviceId(vm.getId());

nic = allocateNic(requested, network, false, deviceId, vmProfile).first();
boolean isDefaultNic = getNicProfileDefaultNic(requested);

nic = allocateNic(requested, network, isDefaultNic, deviceId, vmProfile).first();

if (nic == null) {
throw new CloudRuntimeException("Failed to allocate nic for vm " + vm + " in network " + network);
Expand Down Expand Up @@ -4357,6 +4359,16 @@ public NicProfile createNicForVm(final Network network, final NicProfile request
return nic;
}

private boolean getNicProfileDefaultNic(NicProfile nicProfile) {
if (nicProfile != null) {
s_logger.debug(String.format("Using requested nic profile isDefaultNic value [%s].", nicProfile.isDefaultNic()));
return nicProfile.isDefaultNic();
}

s_logger.debug("Using isDefaultNic default value [false] as requested nic profile is null.");
return false;
}

@Override
public List<NicProfile> getNicProfiles(final VirtualMachine vm) {
final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
Expand Down
14 changes: 14 additions & 0 deletions server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,8 @@ public UserVm addNicToVirtualMachine(AddNicToVMCmd cmd) throws InvalidParameterV
}
}

setNicAsDefaultIfNeeded(vmInstance, profile);

NicProfile guestNic = null;
boolean cleanUp = true;

Expand Down Expand Up @@ -1453,6 +1455,18 @@ public UserVm addNicToVirtualMachine(AddNicToVMCmd cmd) throws InvalidParameterV
return _vmDao.findById(vmInstance.getId());
}

/**
* Set NIC as default if VM has no default NIC
* @param vmInstance VM instance to be checked
* @param nicProfile NIC profile to be updated
*/
public void setNicAsDefaultIfNeeded(UserVmVO vmInstance, NicProfile nicProfile) {
if (_networkModel.getDefaultNic(vmInstance.getId()) == null) {
s_logger.debug(String.format("Setting NIC %s as default as VM %s has no default NIC.", nicProfile.getName(), vmInstance.getName()));
nicProfile.setDefaultNic(true);
}
}

/**
* duplicated in {@see VirtualMachineManagerImpl} for a {@see VMInstanceVO}
*/
Expand Down
1 change: 1 addition & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3071,6 +3071,7 @@
"message.vr.alert.upon.network.offering.creation.l2": "As virtual routers are not created for L2 networks, the compute offering will not be used.",
"message.vr.alert.upon.network.offering.creation.others": "As none of the obligatory services for creating a virtual router (VPN, DHCP, DNS, Firewall, LB, UserData, SourceNat, StaticNat, PortForwarding) are enabled, the virtual router will not be created and the compute offering will not be used.",
"message.warn.filetype": "jpg, jpeg, png, bmp and svg are the only supported image formats.",
"message.warn.importing.instance.without.nic": "WARNING: this instance is being imported without NICs and many network resources will not be available. Consider creating a NIC via VCenter before importing or as soon as the instance is imported.",
"message.warn.zone.mtu.update": "Please note that this limit won't affect pre-existing network’s MTU settings",
"message.zone.creation.complete": "Zone creation complete.",
"message.zone.detail.description": "Populate zone details.",
Expand Down
1 change: 1 addition & 0 deletions ui/public/locales/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,7 @@
"message.vr.alert.upon.network.offering.creation.l2": "Como VRs não são criados para redes do tipo L2, a oferta de computação não será utilizada.",
"message.vr.alert.upon.network.offering.creation.others": "Como nenhum dos serviços obrigatórios para criação do VR (VPN, DHCP, DNS, Firewall, LB, UserData, SourceNat, StaticNat, PortForwarding) foram habilitados, o VR não será criado e a oferta de computação não será usada.",
"message.warn.filetype": "jpg, jpeg, png, bmp e svg s\u00e3o os \u00fanicos formatos de imagem suportados",
"message.warn.importing.instance.without.nic": "AVISO: essa instância está sendo importada sem NICs e muitos recursos de rede não estarão disponíveis. Considere criar uma NIC antes de importar via VCenter ou assim que a instância for importada.",
"message.zone.creation.complete": "Cria\u00e7\u00e3o de zona completa",
"message.zone.detail.description": "Preencha os detalhes da zona",
"message.zone.detail.hint": "Uma zona \u00e9 a maior unidade organizacional no CloudStack, e normalmente corresponde a um \u00fanico datacenter. As zonas proporcionam isolamento f\u00edsico e redund\u00e2ncia. Uma zona consiste em um ou mais pods (cada um contendo hosts e servidores de armazenamento prim\u00e1rio) e um servidor de armazenamento secund\u00e1rio que \u00e9 compartilhado por todos os pods da zona.",
Expand Down
7 changes: 7 additions & 0 deletions ui/src/views/tools/ImportUnmanagedInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@
filterMatchKey="broadcasturi"
@select-multi-network="updateMultiNetworkOffering" />
</div>
<a-row v-else style="margin: 12px 0">
<a-alert type="warning">
<template #message>
<div v-html="$t('message.warn.importing.instance.without.nic')"></div>
</template>
</a-alert>
</a-row>
<a-row :gutter="12">
<a-col :md="24" :lg="12">
<a-form-item name="migrateallowed" ref="migrateallowed">
Expand Down