Skip to content

Commit 06ddb1a

Browse files
rp-Imvedansh
authored andcommitted
Auto update the host status
1 parent 8ce34ad commit 06ddb1a

File tree

4 files changed

+58
-33
lines changed

4 files changed

+58
-33
lines changed

plugins/storage/volume/linstor/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to Linstor CloudStack plugin will be documented in this file
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2025-02-21]
9+
10+
### Fixed
11+
12+
- Always try to delete cs-...-rst resource before doing a snapshot backup
13+
814
## [2025-01-27]
915

1016
### Fixed

plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,8 @@ private String restoreResourceFromSnapshot(
11171117
String snapshotName,
11181118
String restoredName) throws ApiException {
11191119
final String rscGrp = getRscGrp(storagePoolVO);
1120+
// try to delete -rst resource, could happen if the copy failed and noone deleted it.
1121+
deleteResourceDefinition(storagePoolVO, restoredName);
11201122
ResourceDefinitionCreate rdc = createResourceDefinitionCreate(restoredName, rscGrp);
11211123
api.resourceDefinitionCreate(rdc);
11221124

@@ -1259,19 +1261,22 @@ private Answer copyFromTemporaryResource(
12591261
throws ApiException {
12601262
Answer answer;
12611263
String restoreName = rscName + "-rst";
1262-
String devName = restoreResourceFromSnapshot(api, pool, rscName, snapshotName, restoreName);
1263-
1264-
Optional<RemoteHostEndPoint> optEPAny = getLinstorEP(api, restoreName);
1265-
if (optEPAny.isPresent()) {
1266-
// patch the src device path to the temporary linstor resource
1267-
snapshotObject.setPath(devName);
1268-
origCmd.setSrcTO(snapshotObject.getTO());
1269-
answer = optEPAny.get().sendMessage(origCmd);
1270-
} else{
1271-
answer = new Answer(origCmd, false, "Unable to get matching Linstor endpoint.");
1264+
try {
1265+
String devName = restoreResourceFromSnapshot(api, pool, rscName, snapshotName, restoreName);
1266+
1267+
Optional<RemoteHostEndPoint> optEPAny = getLinstorEP(api, restoreName);
1268+
if (optEPAny.isPresent()) {
1269+
// patch the src device path to the temporary linstor resource
1270+
snapshotObject.setPath(devName);
1271+
origCmd.setSrcTO(snapshotObject.getTO());
1272+
answer = optEPAny.get().sendMessage(origCmd);
1273+
} else{
1274+
answer = new Answer(origCmd, false, "Unable to get matching Linstor endpoint.");
1275+
}
1276+
} finally {
1277+
// delete the temporary resource, noop if already gone
1278+
api.resourceDefinitionDelete(restoreName);
12721279
}
1273-
// delete the temporary resource, noop if already gone
1274-
api.resourceDefinitionDelete(restoreName);
12751280
return answer;
12761281
}
12771282

ui/src/config/section/infra/hosts.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ export default {
113113
dataView: true,
114114
show: (record) => { return record.resourcestate === 'Enabled' },
115115
popup: true,
116-
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable')))
116+
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable'))),
117+
events: {
118+
'refresh-data': () => {
119+
store.dispatch('refreshCurrentPage')
120+
}
121+
}
117122
},
118123
{
119124
api: 'updateHost',
@@ -123,7 +128,12 @@ export default {
123128
dataView: true,
124129
show: (record) => { return record.resourcestate === 'Disabled' },
125130
popup: true,
126-
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable')))
131+
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable'))),
132+
events: {
133+
'refresh-data': () => {
134+
store.dispatch('refreshCurrentPage')
135+
}
136+
}
127137
},
128138
{
129139
api: 'prepareHostForMaintenance',

ui/src/views/infra/HostEnableDisable.vue

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<template>
1919
<div class="form-layout">
2020
<a-form
21-
:ref="formRef"
21+
ref="formRef"
2222
:model="form"
2323
:rules="rules"
2424
@finish="handleSubmit"
@@ -54,7 +54,7 @@
5454
</template>
5555

5656
<script>
57-
import { ref, reactive, toRaw } from 'vue'
57+
import { reactive, toRaw } from 'vue'
5858
import { api } from '@/api'
5959
6060
export default {
@@ -78,11 +78,8 @@ export default {
7878
this.resourcestate = this.resource.resourcestate
7979
this.allocationstate = this.resourcestate === 'Enabled' ? 'Disable' : 'Enable'
8080
},
81-
beforeCreate () {
82-
},
8381
methods: {
8482
initForm () {
85-
this.formRef = ref()
8683
this.form = reactive({})
8784
this.rules = reactive({})
8885
},
@@ -97,37 +94,44 @@ export default {
9794
})
9895
},
9996
handleSubmit (e) {
100-
e.preventDefault()
101-
this.formRef.value.validate().then(() => {
97+
if (e) {
98+
e.preventDefault()
99+
}
100+
this.$refs.formRef.validate().then(() => {
102101
const values = toRaw(this.form)
103-
104-
var data = {
102+
const data = {
105103
allocationstate: this.allocationstate,
106104
id: this.resource.id
107105
}
108106
if (values.reason) {
109107
data.annotation = values.reason
110108
}
111-
api('updateHost', data).then(_ => {
112-
this.$emit('close-action')
113-
})
109+
api('updateHost', data)
110+
.then(response => {
111+
this.$emit('refresh-data')
112+
this.$emit('close-action')
113+
})
114+
.catch(error => {
115+
console.error('Error updating host:', error)
116+
this.$emit('close-action')
117+
})
118+
}).catch(error => {
119+
console.error('Validation failed:', error)
114120
})
115121
}
116122
}
117123
}
118-
119124
</script>
120125

121126
<style scoped>
122127
.reason {
123-
padding-top: 20px
128+
padding-top: 20px;
124129
}
125130
126131
.form-layout {
127-
width: 30vw;
128-
129-
@media (min-width: 500px) {
130-
width: 450px;
131-
}
132+
width: 30vw;
133+
@media (min-width: 500px) {
134+
width: 450px;
132135
}
136+
}
133137
</style>

0 commit comments

Comments
 (0)