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 @@ -46,7 +46,6 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd {
@Parameter(name = ApiConstants.GATEWAY_ID,
type = CommandType.UUID,
entityType = PrivateGatewayResponse.class,
required = true,
description = "The gateway ID we are creating static route for. Mutually exclusive with the nexthop parameter")
private Long gatewayId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,8 @@ public void prepareAllNicsForMigration(final VirtualMachineProfile vm, final Dep
for (final NetworkElement element : networkElements) {
if (providersToImplement.contains(element.getProvider())) {
if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) {
throw new CloudRuntimeException(String.format("Service provider %s either doesn't exist or is not enabled in physical network: %s", element.getProvider().getName(), _physicalNetworkDao.findById(network.getPhysicalNetworkId())));
throw new CloudRuntimeException(String.format("Service provider %s either doesn't exist or is not enabled in physical network: %s",
element.getProvider().getName(), _physicalNetworkDao.findById(network.getPhysicalNetworkId())));
}
if (element instanceof NetworkMigrationResponder) {
if (!((NetworkMigrationResponder) element).prepareMigration(profile, network, vm, dest, context)) {
Expand Down Expand Up @@ -2633,6 +2634,10 @@ && isDhcpAccrossMultipleSubnetsSupported(dhcpServiceProvider)) {

final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
guru.deallocate(network, profile, vm);
if (nic.getReservationStrategy() == Nic.ReservationStrategy.Create) {
applyProfileToNicForRelease(nic, profile);
_nicDao.update(nic.getId(), nic);
}
if (BooleanUtils.isNotTrue(preserveNics)) {
_nicDao.remove(nic.getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
--;
-- Schema upgrade cleanup from 4.22.0.0 to 4.22.1.0
--;

DROP VIEW IF EXISTS `cloud`.`account_netstats_view`;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ select
`data_center`.`id` AS `data_center_id`,
`data_center`.`uuid` AS `data_center_uuid`,
`data_center`.`name` AS `data_center_name`,
`account_netstats_view`.`bytesReceived` AS `bytesReceived`,
`account_netstats_view`.`bytesSent` AS `bytesSent`,
`account_netstats`.`bytesReceived` AS `bytesReceived`,
`account_netstats`.`bytesSent` AS `bytesSent`,
`vmlimit`.`max` AS `vmLimit`,
`vmcount`.`count` AS `vmTotal`,
`runningvm`.`vmcount` AS `runningVms`,
Expand Down Expand Up @@ -89,8 +89,15 @@ from
`cloud`.`domain` ON account.domain_id = domain.id
left join
`cloud`.`data_center` ON account.default_zone_id = data_center.id
left join
`cloud`.`account_netstats_view` ON account.id = account_netstats_view.account_id
left join lateral (
select
coalesce(sum(`user_statistics`.`net_bytes_received` + `user_statistics`.`current_bytes_received`), 0) AS `bytesReceived`,
coalesce(sum(`user_statistics`.`net_bytes_sent` + `user_statistics`.`current_bytes_sent`), 0) AS `bytesSent`
from
`cloud`.`user_statistics`
where
`user_statistics`.`account_id` = `account`.`id`
) AS `account_netstats` ON TRUE
left join
`cloud`.`resource_limit` vmlimit ON account.id = vmlimit.account_id
and vmlimit.type = 'user_vm' and vmlimit.tag IS NULL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ public void prepareForMaintenanceAndCancelFromMaintenanceState() {
spy.prepareForMaintenance("static", false);
});

Mockito.when(msHost.getState()).thenReturn(ManagementServerHost.State.Maintenance);
Mockito.doNothing().when(jobManagerMock).enableAsyncJobs();
spy.cancelMaintenance();
Mockito.verify(jobManagerMock).enableAsyncJobs();
Expand All @@ -339,7 +338,6 @@ public void prepareForMaintenanceAndCancelFromPreparingForMaintenanceState() {
spy.prepareForMaintenance("static", false);
});

Mockito.when(msHost.getState()).thenReturn(ManagementServerHost.State.PreparingForMaintenance);
Mockito.doNothing().when(jobManagerMock).enableAsyncJobs();
spy.cancelMaintenance();
Mockito.verify(jobManagerMock).enableAsyncJobs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,9 @@ private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {

@Override
public TemplateType validateTemplateType(BaseCmd cmd, boolean isAdmin, boolean isCrossZones, HypervisorType hypervisorType) {
if (cmd instanceof GetUploadParamsForIsoCmd) {
return TemplateType.USER;
}
if (!(cmd instanceof UpdateTemplateCmd) && !(cmd instanceof RegisterTemplateCmd) && !(cmd instanceof GetUploadParamsForTemplateCmd)) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -4408,7 +4408,7 @@ private UserVm getUncheckedUserVmResource(DataCenter zone, String hostName, Stri
}
}

if (template.getTemplateType().equals(TemplateType.SYSTEM) && !CKS_NODE.equals(vmType) && !SHAREDFSVM.equals(vmType)) {
if (TemplateType.SYSTEM.equals(template.getTemplateType()) && !CKS_NODE.equals(vmType) && !SHAREDFSVM.equals(vmType)) {
throw new InvalidParameterValueException(String.format("Unable to use system template %s to deploy a user vm", template));
}

Expand Down
6 changes: 6 additions & 0 deletions ui/src/views/compute/DeployVM.vue
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@
:value="securitygroupids"
:loading="loading.networks"
:preFillContent="dataPreFill"
:domainId="owner.domainid"
:account="owner.account"
:projectId="owner.projectid"
@select-security-group-item="($event) => updateSecurityGroups($event)"></security-group-selection>
</template>
</a-step>
Expand Down Expand Up @@ -1501,6 +1504,9 @@ export default {
return tabList
},
showSecurityGroupSection () {
if (this.zone && this.zone.networktype === 'Basic') {
return true
}
if (this.networks.length < 1) {
return false
}
Expand Down
114 changes: 66 additions & 48 deletions ui/src/views/compute/wizard/MultiNetworkSelection.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE
file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this
file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // //
Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on
an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the
// specific language governing permissions and limitations // under the License.

<template>
<div>
<a-table
:loading="loading"
:columns="columns"
:dataSource="tableSource"
:rowKey="record => record.id"
:rowKey="(record) => record.id"
:pagination="false"
:rowSelection="rowSelection"
:scroll="{ y: 225 }" >

:scroll="{ y: 225 }"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'name'">
<span>{{ record.displaytext || record.name }}</span>
Expand All @@ -48,16 +39,20 @@
style="width: 100%"
v-if="validNetworks[record.id] && validNetworks[record.id].length > 0"
:defaultValue="getDefaultNetwork(record)"
@change="val => handleNetworkChange(record, val)"
@change="(val) => handleNetworkChange(record, val)"
showSearch
optionFilterProp="label"
:filterOption="(input, option) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}" >
:filterOption="
(input, option) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
>
<a-select-option
v-for="network in hypervisor !== 'KVM' ? validNetworks[record.id] : networks"
:key="network.id"
:label="network.displaytext + (network.broadcasturi ? ' (' + network.broadcasturi + ')' : '')">
:label="network.displaytext + (network.broadcasturi ? ' (' + network.broadcasturi + ')' : '')"
>
<div>{{ network.displaytext + (network.broadcasturi ? ' (' + network.broadcasturi + ')' : '') }}</div>
</a-select-option>
</a-select>
Expand All @@ -72,8 +67,9 @@
:checkBoxLabel="$t('label.auto.assign.random.ip')"
:defaultCheckBoxValue="true"
:reversed="true"
:visible="(indexNum > 0 && ipAddressesEnabled[record.id])"
@handle-checkinputpair-change="setIpAddress" />
:visible="indexNum > 0 && ipAddressesEnabled[record.id]"
@handle-checkinputpair-change="setIpAddress"
/>
</template>
</template>
</a-table>
Expand Down Expand Up @@ -107,6 +103,10 @@ export default {
type: String,
default: ''
},
projectid: {
type: String,
default: ''
},
selectionEnabled: {
type: Boolean,
default: true
Expand Down Expand Up @@ -158,7 +158,7 @@ export default {
},
computed: {
tableSource () {
return this.items.map(item => {
return this.items.map((item) => {
var nic = { ...item, disabled: this.validNetworks[item.id] && this.validNetworks[item.id].length === 0 }
nic.name = item.displaytext || item.name
return nic
Expand All @@ -169,7 +169,7 @@ export default {
return {
type: 'checkbox',
selectedRowKeys: this.selectedRowKeys,
getCheckboxProps: record => ({
getCheckboxProps: (record) => ({
props: {
disabled: record.disabled
}
Expand Down Expand Up @@ -201,6 +201,9 @@ export default {
this.fetchNetworks()
}
}, 750)
},
projectid () {
this.fetchNetworks()
}
},
created () {
Expand All @@ -221,28 +224,37 @@ export default {
params.domainid = this.domainid
params.account = this.account
}
getAPI('listNetworks', params).then(response => {
this.networks = response.listnetworksresponse.network || []
}).catch(() => {
this.networks = []
}).finally(() => {
this.orderNetworks()
this.loading = false
})
if (this.projectid) {
params.projectid = this.projectid
}
getAPI('listNetworks', params)
.then((response) => {
this.networks = response.listnetworksresponse.network || []
})
.catch(() => {
this.networks = []
})
.finally(() => {
this.orderNetworks()
this.loading = false
})
},
orderNetworks () {
this.loading = true
this.validNetworks = {}
for (const item of this.items) {
this.validNetworks[item.id] = this.networks
if (this.filterUnimplementedNetworks) {
this.validNetworks[item.id] = this.validNetworks[item.id].filter(x => (x.state === 'Implemented' || (x.state === 'Setup' && ['Shared', 'L2'].includes(x.type))))
this.validNetworks[item.id] = this.validNetworks[item.id].filter(
(x) => x.state === 'Implemented' || (x.state === 'Setup' && ['Shared', 'L2'].includes(x.type))
)
}
if (this.filterMatchKey) {
const filtered = this.networks.filter(x => x[this.filterMatchKey] === item[this.filterMatchKey])
const filtered = this.networks.filter((x) => x[this.filterMatchKey] === item[this.filterMatchKey])
if (this.hypervisor === 'KVM') {
this.unableToMatch = filtered.length === 0
this.validNetworks[item.id] = filtered.length === 0 ? this.networks : filtered.concat(this.networks.filter(x => filtered.includes(x)))
this.validNetworks[item.id] =
filtered.length === 0 ? this.networks : filtered.concat(this.networks.filter((x) => filtered.includes(x)))
} else {
this.validNetworks[item.id] = filtered
}
Expand All @@ -253,7 +265,7 @@ export default {
},
setIpAddressEnabled (nic, network) {
this.ipAddressesEnabled[nic.id] = network && network.type !== 'L2'
this.ipAddresses[nic.id] = (!network || network.type === 'L2') ? null : 'auto'
this.ipAddresses[nic.id] = !network || network.type === 'L2' ? null : 'auto'
this.values[nic.id] = network ? network.id : null
this.indexNum = (this.indexNum % 2) + 1
},
Expand All @@ -267,7 +279,7 @@ export default {
for (const item of this.items) {
let network = null
if (item.vlanid && item.vlanid !== -1) {
const matched = this.validNetworks[item.id].filter(x => Number(x.vlan) === item.vlanid)
const matched = this.validNetworks[item.id].filter((x) => Number(x.vlan) === item.vlanid)
if (matched.length > 0) {
network = matched[0]
}
Expand All @@ -276,16 +288,22 @@ export default {
network = this.validNetworks[item.id]?.[0] || null
}
this.values[item.id] = network ? network.id : ''
this.ipAddresses[item.id] = (!network || network.type === 'L2') ? null : 'auto'
this.ipAddresses[item.id] = !network || network.type === 'L2' ? null : 'auto'
this.setIpAddressEnabled(item, network)
}
this.sendValuesTimed()
},
handleNetworkChange (nic, networkId) {
if (this.hypervisor === 'KVM') {
this.setIpAddressEnabled(nic, _.find(this.networks, (option) => option.id === networkId))
this.setIpAddressEnabled(
nic,
_.find(this.networks, (option) => option.id === networkId)
)
} else {
this.setIpAddressEnabled(nic, _.find(this.validNetworks[nic.id], (option) => option.id === networkId))
this.setIpAddressEnabled(
nic,
_.find(this.validNetworks[nic.id], (option) => option.id === networkId)
)
}
this.sendValuesTimed()
},
Expand All @@ -301,7 +319,7 @@ export default {
sendValues () {
const data = {}
if (this.selectionEnabled) {
this.selectedRowKeys.map(x => {
this.selectedRowKeys.map((x) => {
var d = { network: this.values[x] }
if (this.ipAddresses[x]) {
d.ipAddress = this.ipAddresses[x]
Expand All @@ -324,7 +342,7 @@ export default {
</script>

<style lang="less" scoped>
.ant-table-wrapper {
margin: 2rem 0;
}
.ant-table-wrapper {
margin: 2rem 0;
}
</style>
Loading
Loading