There has been a persistent issue I've been dealing with for some time now. The problem lies in the fact that vm_res
is undefined within the async update_vm_raw_device
function despite the function running smoothly. As a result, the value being updated ends with
/mnt/tank/ds/test_file_test_VM_undefined
. Pay close attention to the "undefined" at the end.
async customSubmit(value) {
const path = `${value.raw_file_directory}/${value.raw_filename}_${value.name}`;
const payload = {}
const vm_payload = {}
......SNIP..........
this.ws.call('vm.get_sharefs').subscribe((get_sharefs)=>{
if(!get_sharefs){
this.ws.call('vm.activate_sharefs').subscribe((sharefs)=>{
this.ws.call('vm.create', [vm_payload]).toPromise().then(vm_res => {
// Despite assignment happening here, this.vm_res remains undefined in the async update_vm_raw_device function.
this.vm_res = vm_res;
});
}
)
}
else {
this.ws.call('vm.create', [vm_payload]).toPromise().then(vm_res => {
this.vm_res = vm_res;
});
}
},)
await this.update_vm_raw_device(vm_payload, this.vm_res);
}
async update_vm_raw_device(vm_payload: any, vm_res: number) {
vm_payload.path = `${vm_payload.path}_${this.vm_res}`
await this.ws.call('datastore.update'[vm_payload])])).toPromise().then(
res=>{});}