Skip to content

Commit f9451fc

Browse files
vishesh92harikrishna-patnalaDaanHoogland
authored
Notify users when upgrades are available or restart is required for network or VPC (#7610)
Co-authored-by: Harikrishna <harikrishna.patnala@gmail.com> Co-authored-by: dahn <daan.hoogland@gmail.com>
1 parent 3915232 commit f9451fc

File tree

11 files changed

+138
-7
lines changed

11 files changed

+138
-7
lines changed

ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"npm-check-updates": "^6.0.1",
6161
"nprogress": "^0.2.0",
6262
"qrious": "^4.0.2",
63+
"semver": "^7.6.3",
6364
"vue": "^3.2.31",
6465
"vue-chartjs": "^4.0.7",
6566
"vue-clipboard2": "^0.3.1",

ui/public/locales/en.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@
14461446
"label.network.offering": "Network offering",
14471447
"label.network.offerings": "Network offerings",
14481448
"label.network.policy": "Network Policy",
1449+
"label.network.restart.required": "Network restart required",
14491450
"label.network.route.table": "Network route table",
14501451
"label.network.routing.policy": "Network routing policy",
14511452
"label.network.permissions": "Network permissions",
@@ -1476,6 +1477,7 @@
14761477
"label.new.secondaryip.description": "Enter new secondary IP address",
14771478
"label.new.tag": "New tag",
14781479
"label.new.vm": "New Instance",
1480+
"label.new.version.available": "New version available",
14791481
"label.newdiskoffering": "New offering",
14801482
"label.newinstance": "New Instance",
14811483
"label.newname": "New name",
@@ -2463,6 +2465,7 @@
24632465
"label.vpc.id": "VPC ID",
24642466
"label.vpc.offerings": "VPC offerings",
24652467
"label.vpc.virtual.router": "VPC virtual router",
2468+
"label.vpc.restart.required": "VPC restart required",
24662469
"label.vpcid": "VPC",
24672470
"label.vpclimit": "VPC limits",
24682471
"label.vpcname": "VPC",
@@ -3185,13 +3188,15 @@
31853188
"message.network.offering.mac.learning.warning": "WARNING: In order to use MAC Learning you must ensure your hypervisor hosts are running ESXi 6.7+ and the Network uses distributed vSwitch 6.6.0+.",
31863189
"message.network.offering.promiscuous.mode": "Applicable for guest Networks on VMware hypervisor only.\nReject - The switch drops any outbound frame from a virtual machine adapter with a source MAC address that is different from the one in the .vmx configuration file.\nAccept - The switch does not perform filtering, and permits all outbound frames.\nNone - Default to value from global setting.",
31873190
"message.network.removenic": "Please confirm that want to remove this NIC, which will also remove the associated Network from the Instance.",
3191+
"message.network.restart.required": "Restart is required for network(s). Click here to view network(s) which require restart.",
31883192
"message.network.secondaryip": "Please confirm that you would like to acquire a new secondary IP for this NIC. \n NOTE: You need to manually configure the newly-acquired secondary IP inside the virtual machine.",
31893193
"message.network.selection": "Choose one or more Networks to attach the Instance to.",
31903194
"message.network.selection.new.network": "A new Network can also be created here.",
31913195
"message.network.updateip": "Please confirm that you would like to change the IP address for this NIC on the Instance.",
31923196
"message.network.usage.info.data.points": "Each data point represents the difference in data traffic since the last data point.",
31933197
"message.network.usage.info.sum.of.vnics": "The Network usage shown is made up of the sum of data traffic from all the vNICs in the Instance.",
31943198
"message.nfs.mount.options.description": "Comma separated list of NFS mount options for KVM hosts. Supported options : vers=[3,4.0,4.1,4.2], nconnect=[1...16]",
3199+
"message.new.version.available": "A new version of CloudStack is available. Click here to check the details",
31953200
"message.no.data.to.show.for.period": "No data to show for the selected period.",
31963201
"message.no.description": "No description entered.",
31973202
"message.offering.internet.protocol.warning": "WARNING: IPv6 supported Networks use static routing and will require upstream routes to be configured manually.",
@@ -3526,6 +3531,7 @@
35263531
"message.volume.state.primary.storage.suitability": "The suitability of a primary storage for a volume depends on the disk offering of the volume and on the virtual machine allocation (if the volume is attached to a virtual machine).",
35273532
"message.volumes.managed": "Volumes controlled by CloudStack.",
35283533
"message.volumes.unmanaged": "Volumes not controlled by CloudStack.",
3534+
"message.vpc.restart.required": "Restart is required for VPC(s). Click here to view VPC(s) which require restart.",
35293535
"message.vr.alert.upon.network.offering.creation.l2": "As virtual routers are not created for L2 Networks, the compute offering will not be used.",
35303536
"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.",
35313537
"message.warn.change.primary.storage.scope": "This feature is tested and supported for the following configurations:<br>KVM - NFS/Ceph - DefaultPrimary<br>VMware - NFS - DefaultPrimary<br>*There might be extra steps involved to make it work for other configurations.",

ui/src/components/header/HeaderNotice.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@
4747
</a-avatar>
4848
</template>
4949
<template #description>
50-
<span v-if="getResourceName(notice.description, 'name') && notice.path">
51-
<router-link :to="{ path: notice.path}"> {{ getResourceName(notice.description, "name") + ' - ' }}</router-link>
50+
<span v-if="getResourceName(notice.description, 'name') && notice.path && !['VPC_RESTART_REQUIRED', 'NETWORK_RESTART_REQUIRED'].includes(notice.key)">
51+
<router-link :to="{ path: notice.path}">{{ getResourceName(notice.description, "name") + ' - ' }}</router-link>
52+
{{ getResourceName(notice.description, "msg") }}</span>
53+
<span v-else-if="notice.path && ['VPC_RESTART_REQUIRED', 'NETWORK_RESTART_REQUIRED'].includes(notice.key)">
54+
<router-link :to="{ path: notice.path, query: notice.query }">{{ notice.description }}</router-link>
5255
</span>
53-
<span v-if="getResourceName(notice.description, 'name') && notice.path"> {{ getResourceName(notice.description, "msg") }}</span>
5456
<span v-else>{{ notice.description }}</span>
5557
</template>
5658
</a-list-item-meta>

ui/src/components/page/GlobalFooter.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
</div>
2323
<div class="line" v-if="$store.getters.userInfo.roletype === 'Admin'">
2424
CloudStack {{ $store.getters.features.cloudstackversion }}
25+
<span v-if="showVersionUpdate()">
26+
<a-divider type="vertical" />
27+
<a
28+
:href="'https://github.com/apache/cloudstack/releases/tag/' + $store.getters.latestVersion.version"
29+
target="_blank">
30+
<info-circle-outlined />
31+
{{ $t('label.new.version.available') + ': ' + $store.getters.latestVersion.version }}
32+
</a>
33+
</span>
2534
<a-divider type="vertical" />
2635
<a href="https://github.com/apache/cloudstack/discussions" target="_blank">
2736
<github-outlined />
@@ -32,11 +41,24 @@
3241
</template>
3342

3443
<script>
44+
import semver from 'semver'
45+
import { getParsedVersion } from '@/utils/util'
46+
3547
export default {
3648
name: 'LayoutFooter',
3749
data () {
3850
return {
3951
}
52+
},
53+
methods: {
54+
showVersionUpdate () {
55+
if (this.$store.getters?.features?.cloudstackversion && this.$store.getters?.latestVersion?.version) {
56+
const currentVersion = getParsedVersion(this.$store.getters?.features?.cloudstackversion)
57+
const latestVersion = getParsedVersion(this.$store.getters?.latestVersion?.version)
58+
return semver.valid(currentVersion) && semver.valid(latestVersion) && semver.gt(latestVersion, currentVersion)
59+
}
60+
return false
61+
}
4062
}
4163
}
4264
</script>

ui/src/components/view/ListView.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@
9090
<span v-else>
9191
<router-link :to="{ path: $route.path + '/' + record.id }" v-if="record.id">{{ text }}</router-link>
9292
<router-link :to="{ path: $route.path + '/' + record.name }" v-else>{{ text }}</router-link>
93+
<span v-if="['guestnetwork','vpc'].includes($route.path.split('/')[1]) && record.restartrequired && !record.vpcid">
94+
&nbsp;
95+
<a-tooltip>
96+
<template #title>{{ $t('label.restartrequired') }}</template>
97+
<warning-outlined style="color: #f5222d"/>
98+
</a-tooltip>
99+
</span>
93100
</span>
94101
</span>
95102
</template>

ui/src/components/view/SearchView.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export default {
303303
}
304304
if (['zoneid', 'domainid', 'imagestoreid', 'storageid', 'state', 'account', 'hypervisor', 'level',
305305
'clusterid', 'podid', 'groupid', 'entitytype', 'accounttype', 'systemvmtype', 'scope', 'provider',
306-
'type', 'scope', 'managementserverid', 'serviceofferingid', 'diskofferingid', 'usagetype'].includes(item)
306+
'type', 'scope', 'managementserverid', 'serviceofferingid', 'diskofferingid', 'usagetype', 'restartrequired'].includes(item)
307307
) {
308308
type = 'list'
309309
} else if (item === 'tags') {
@@ -395,6 +395,16 @@ export default {
395395
this.fields[providerIndex].loading = false
396396
}
397397
398+
if (arrayField.includes('restartrequired')) {
399+
const restartRequiredIndex = this.fields.findIndex(item => item.name === 'restartrequired')
400+
this.fields[restartRequiredIndex].loading = true
401+
this.fields[restartRequiredIndex].opts = [
402+
{ id: 'true', name: 'label.yes' },
403+
{ id: 'false', name: 'label.no' }
404+
]
405+
this.fields[restartRequiredIndex].loading = false
406+
}
407+
398408
if (arrayField.includes('resourcetype')) {
399409
const resourceTypeIndex = this.fields.findIndex(item => item.name === 'resourcetype')
400410
this.fields[resourceTypeIndex].loading = true

ui/src/config/section/network.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default {
5454
return fields
5555
},
5656
filters: ['all', 'account', 'domainpath', 'shared'],
57-
searchFilters: ['keyword', 'zoneid', 'domainid', 'account', 'type', 'tags'],
57+
searchFilters: ['keyword', 'zoneid', 'domainid', 'account', 'type', 'restartrequired', 'tags'],
5858
related: [{
5959
name: 'vm',
6060
title: 'label.instances',
@@ -218,7 +218,7 @@ export default {
218218
return fields
219219
},
220220
details: ['name', 'id', 'displaytext', 'cidr', 'networkdomain', 'ip6routes', 'ispersistent', 'redundantvpcrouter', 'restartrequired', 'zonename', 'account', 'domain', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2', 'publicmtu'],
221-
searchFilters: ['name', 'zoneid', 'domainid', 'account', 'tags'],
221+
searchFilters: ['name', 'zoneid', 'domainid', 'account', 'restartrequired', 'tags'],
222222
related: [{
223223
name: 'vm',
224224
title: 'label.instances',

ui/src/store/getters.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const getters = {
2828
apis: state => state.user.apis,
2929
features: state => state.user.features,
3030
userInfo: state => state.user.info,
31+
latestVersion: state => state.user.latestVersion,
3132
addRouters: state => state.permission.addRouters,
3233
multiTab: state => state.app.multiTab,
3334
listAllProjects: state => state.app.listAllProjects,

ui/src/store/modules/user.js

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
import Cookies from 'js-cookie'
1919
import message from 'ant-design-vue/es/message'
2020
import notification from 'ant-design-vue/es/notification'
21+
import semver from 'semver'
2122

2223
import { vueProps } from '@/vue-app'
2324
import router from '@/router'
2425
import store from '@/store'
2526
import { oauthlogin, login, logout, api } from '@/api'
2627
import { i18n } from '@/locales'
28+
import { axios } from '../../utils/request'
29+
import { getParsedVersion } from '@/utils/util'
2730

2831
import {
2932
ACCESS_TOKEN,
@@ -38,7 +41,8 @@ import {
3841
DARK_MODE,
3942
CUSTOM_COLUMNS,
4043
OAUTH_DOMAIN,
41-
OAUTH_PROVIDER
44+
OAUTH_PROVIDER,
45+
LATEST_CS_VERSION
4246
} from '@/store/mutation-types'
4347

4448
const user = {
@@ -167,6 +171,12 @@ const user = {
167171
},
168172
SET_OAUTH_PROVIDER_USED_TO_LOGIN: (state, provider) => {
169173
vueProps.$localStorage.set(OAUTH_PROVIDER, provider)
174+
},
175+
SET_LATEST_VERSION: (state, version) => {
176+
if (version?.fetchedTs > 0) {
177+
vueProps.$localStorage.set(LATEST_CS_VERSION, version)
178+
state.latestVersion = version
179+
}
170180
}
171181
},
172182

@@ -212,6 +222,8 @@ const user = {
212222
commit('SET_2FA_PROVIDER', result.providerfor2fa)
213223
commit('SET_2FA_ISSUER', result.issuerfor2fa)
214224
commit('SET_LOGIN_FLAG', false)
225+
const latestVersion = vueProps.$localStorage.get(LATEST_CS_VERSION, { version: '', fetchedTs: 0 })
226+
commit('SET_LATEST_VERSION', latestVersion)
215227
notification.destroy()
216228

217229
resolve()
@@ -259,6 +271,8 @@ const user = {
259271
commit('SET_2FA_PROVIDER', result.providerfor2fa)
260272
commit('SET_2FA_ISSUER', result.issuerfor2fa)
261273
commit('SET_LOGIN_FLAG', false)
274+
const latestVersion = vueProps.$localStorage.get(LATEST_CS_VERSION, { version: '', fetchedTs: 0 })
275+
commit('SET_LATEST_VERSION', latestVersion)
262276
notification.destroy()
263277

264278
resolve()
@@ -277,10 +291,12 @@ const user = {
277291
const cachedCustomColumns = vueProps.$localStorage.get(CUSTOM_COLUMNS, {})
278292
const domainStore = vueProps.$localStorage.get(DOMAIN_STORE, {})
279293
const darkMode = vueProps.$localStorage.get(DARK_MODE, false)
294+
const latestVersion = vueProps.$localStorage.get(LATEST_CS_VERSION, { version: '', fetchedTs: 0 })
280295
const hasAuth = Object.keys(cachedApis).length > 0
281296

282297
commit('SET_DOMAIN_STORE', domainStore)
283298
commit('SET_DARK_MODE', darkMode)
299+
commit('SET_LATEST_VERSION', latestVersion)
284300
if (hasAuth) {
285301
console.log('Login detected, using cached APIs')
286302
commit('SET_ZONES', cachedZones)
@@ -294,6 +310,7 @@ const user = {
294310
const result = response.listusersresponse.user[0]
295311
commit('SET_INFO', result)
296312
commit('SET_NAME', result.firstname + ' ' + result.lastname)
313+
store.dispatch('SetCsLatestVersion', result.rolename)
297314
resolve(cachedApis)
298315
}).catch(error => {
299316
reject(error)
@@ -332,12 +349,41 @@ const user = {
332349
}).catch(error => {
333350
reject(error)
334351
})
352+
353+
api('listNetworks', { restartrequired: true, forvpc: false }).then(response => {
354+
if (response.listnetworksresponse.count > 0) {
355+
store.dispatch('AddHeaderNotice', {
356+
key: 'NETWORK_RESTART_REQUIRED',
357+
title: i18n.global.t('label.network.restart.required'),
358+
description: i18n.global.t('message.network.restart.required'),
359+
path: '/guestnetwork/',
360+
query: { restartrequired: true, forvpc: false },
361+
status: 'done',
362+
timestamp: new Date()
363+
})
364+
}
365+
}).catch(ignored => {})
366+
367+
api('listVPCs', { restartrequired: true }).then(response => {
368+
if (response.listvpcsresponse.count > 0) {
369+
store.dispatch('AddHeaderNotice', {
370+
key: 'VPC_RESTART_REQUIRED',
371+
title: i18n.global.t('label.vpc.restart.required'),
372+
description: i18n.global.t('message.vpc.restart.required'),
373+
path: '/vpc/',
374+
query: { restartrequired: true },
375+
status: 'done',
376+
timestamp: new Date()
377+
})
378+
}
379+
}).catch(ignored => {})
335380
}
336381

337382
api('listUsers', { username: Cookies.get('username') }).then(response => {
338383
const result = response.listusersresponse.user[0]
339384
commit('SET_INFO', result)
340385
commit('SET_NAME', result.firstname + ' ' + result.lastname)
386+
store.dispatch('SetCsLatestVersion', result.rolename)
341387
}).catch(error => {
342388
reject(error)
343389
})
@@ -367,6 +413,8 @@ const user = {
367413
commit('SET_CLOUDIAN', cloudian)
368414
}).catch(ignored => {
369415
})
416+
}).catch(error => {
417+
console.error(error)
370418
})
371419
},
372420

@@ -488,6 +536,29 @@ const user = {
488536
SetDomainStore ({ commit }, domainStore) {
489537
commit('SET_DOMAIN_STORE', domainStore)
490538
},
539+
SetCsLatestVersion ({ commit }, rolename) {
540+
const lastFetchTs = store.getters.latestVersion?.fetchedTs ? store.getters.latestVersion.fetchedTs : 0
541+
if (rolename === 'Root Admin' && (+new Date() - lastFetchTs) > 24 * 60 * 60 * 1000) {
542+
axios.get(
543+
'https://api.github.com/repos/apache/cloudstack/releases'
544+
).then(response => {
545+
let latestReleaseVersion = getParsedVersion(response[0].tag_name)
546+
let latestTag = response[0].tag_name
547+
548+
for (const release of response) {
549+
if (release.tag_name.toLowerCase().includes('rc')) {
550+
continue
551+
}
552+
const parsedVersion = getParsedVersion(release.tag_name)
553+
if (semver.gte(parsedVersion, latestReleaseVersion)) {
554+
latestReleaseVersion = parsedVersion
555+
latestTag = release.tag_name
556+
commit('SET_LATEST_VERSION', { version: latestTag, fetchedTs: (+new Date()) })
557+
}
558+
}
559+
}).catch(ignored => {})
560+
}
561+
},
491562
SetDarkMode ({ commit }, darkMode) {
492563
commit('SET_DARK_MODE', darkMode)
493564
},

ui/src/store/mutation-types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const USE_BROWSER_TIMEZONE = 'USE_BROWSER_TIMEZONE'
3535
export const SERVER_MANAGER = 'SERVER_MANAGER'
3636
export const DOMAIN_STORE = 'DOMAIN_STORE'
3737
export const DARK_MODE = 'DARK_MODE'
38+
export const LATEST_CS_VERSION = 'LATEST_CS_VERSION'
3839
export const VUE_VERSION = 'VUE_VERSION'
3940
export const CUSTOM_COLUMNS = 'CUSTOM_COLUMNS'
4041
export const RELOAD_ALL_PROJECTS = 'RELOAD_ALL_PROJECTS'

0 commit comments

Comments
 (0)