harvester-ui-extension/extensions/harvester/1.9.0-rc2/plugin/harvester-1.9.0-rc2.umd.min.431.js

2 lines
38 KiB
JavaScript

"use strict";(("undefined"!==typeof self?self:this)["webpackChunkharvester_1_9_0_rc2"]=("undefined"!==typeof self?self:this)["webpackChunkharvester_1_9_0_rc2"]||[]).push([[431],{73975:function(e,t,s){s.d(t,{v6:function(){return u},wM:function(){return y}});var a=s(5159),i=s(20246),r=s.n(i),n=s(46343),o=s.n(n),c=s(76978),l=s(35664),m=s(2602),p=s(32766),d=s(66490),h=s(48249);const u={package_update:!0,packages:["qemu-guest-agent"],runcmd:[["systemctl","enable","--now","qemu-guest-agent.service"]]},g={default:"qemu-guest-agent.service"},y=[{bus:"usb",name:"tablet",type:"tablet"}],f={EXISTING_ALL:"EXISTING_ALL",EXISTING_ONLY_ANNOTATION:"EXISTING_ANNOTATION",EXISTING_ONLY_CLOUD:"EXISTING_CLOUD"};t.Ay={methods:{hasCloudConfigComment(e){const t=e?a.Ay.parseDocument(e):a.Ay.parseDocument({}),s=t?.contents?.items||[];let i=!1;return("cloud-config"===t?.comment||t?.comment?.includes("cloud-config\n"))&&(i=!0),("cloud-config"===t?.commentBefore||t?.commentBefore?.includes("cloud-config\n"))&&(i=!0),s.map(e=>{const t=e.key;("cloud-config"===t?.commentBefore||t?.commentBefore?.includes("cloud-config\n"))&&(i=!0)}),i},getSSHValue(e){const t=this.$store.getters["currentProduct"].inStore,s=this.$store.getters[`${t}/all`](p.rk.SSH)||[];return s.find(t=>t.id===e)?.spec?.publicKey||void 0},getOsType(e){return e.metadata?.labels?.[m.r.OS]},getMatchQGA(e){const t=(0,c.o8)(u);let s=!1;return h.OS.forEach(t=>{t.match&&(s=t.match.find(t=>t===e))}),t.runcmd[0][3]=s?g[e]:g["default"],t},getSimilarRuncmd(e){const t=(0,c.o8)(u);return t.runcmd[0][3]="openSUSE"===e?g["default"]:g["suse"],t.runcmd[0]},hasInstallAgent(e,t,s){let a={};const i=this.getMatchQGA(t);try{a=r().load(e)||{}}catch(n){return new Error("Function(hasInstallAgent) error"),s}return a?.packages?.includes("qemu-guest-agent")&&!!a?.runcmd?.find(e=>Array.isArray(e)&&e.join("-")===i.runcmd[0].join("-"))},isInstallUSBTablet(e){const t=e?.template?.spec?.domain?.devices?.inputs;return!!Array.isArray(t)&&!!t.find(e=>o()(e,y[0]))},isEfiEnabled(e){return!!e?.template?.spec?.domain?.firmware?.bootloader?.efi},isTpmEnabled(e){return!!e?.template?.spec?.domain?.devices?.tpm},isTPMPersistentStateEnabled(e){return!!e?.template?.spec?.domain?.devices?.tpm?.persistent},isEFIPersistentStateEnabled(e){return!!e?.template?.spec?.domain?.firmware?.bootloader?.efi?.persistent},isSecureBoot(e){return!!e?.template?.spec?.domain?.firmware?.bootloader?.efi?.secureBoot},isCpuPinning(e){return!!e?.template?.spec?.domain?.cpu?.dedicatedCpuPlacement},getCloudInitNoCloud(e){const t=this.getSecret(e);let s=t?.decodedData?.userdata,a=t?.decodedData?.networkdata;const i=e?.template?.spec?.volumes?.find(e=>"cloudinitdisk"===e.name)?.cloudInitNoCloud||{};return i?.userData&&(s=i.userData,this.saveUserDataAsClearText=!0),i?.networkData&&(a=i.networkData,this.saveNetworkDataAsClearText=!0),{userData:s,networkData:a}},getSecret(e){const t=e?.template?.spec?.volumes?.find(e=>"cloudinitdisk"===e.name)?.cloudInitNoCloud||{},s=this.$store.getters["currentProduct"].inStore,a=this.$store.getters[`${s}/all`](l.bB)||[],i=t?.secretRef?.name||t?.networkDataSecretRef?.name,r=a.find(e=>e.metadata.name===i);return r},getAccessCredentials(e){const t=this.$store.getters["currentProduct"].inStore,s=this.$store.getters[`${t}/all`](l.bB)||[],a=e?.template?.spec?.accessCredentials||[],i=JSON.parse(e.template.metadata?.annotations?.[m.r.DYNAMIC_SSHKEYS_NAMES]||"[]");return a.map(e=>{const t=e.userPassword?"userPassword":"sshPublicKey",a=e[t]?.source?.secret?.secretName,r=s.find(e=>e.metadata.name===a),n={source:t,username:"",newPassword:"",users:[],sshkeys:[],secretName:a,secretRef:r};if(r)if("userPassword"===t){const e=Object.keys(r?.data)[0],t=r.decodedData[e];n.username=e,n.newPassword=t}else{const s=e[t].propagationMethod.qemuGuestAgent.users,r=i?.[a];n.users=s,n.sshkeys=r}else n.secretRef=void 0;return n})},getRootImageId(e){const t=(0,d.v)(e);return t?.[0]?.metadata?.annotations?.[m.r.IMAGE_ID]||""},getSSHFromAnnotation(e){const t=e?.template?.metadata?.annotations?.[m.r.SSH_NAMES]||"[]";return JSON.parse(t)},convertToJson(e=""){let t={};try{t=r().load(e)}catch(s){new Error("Function(convertToJson) error")}return t},getSSHFromUserData(e){return this.convertToJson(e)?.ssh_authorized_keys||[]},getSysprepConfig(e){const t=e?.template?.spec?.volumes?.find(e=>"sysprep"===e.name&&e.sysprep?.secret);if(!t)return{secretName:"",xmlContent:""};const s=this.$store.getters["currentProduct"].inStore,a=this.value.metadata.namespace,i=t.sysprep.secret.name,r=this.$store.getters[`${s}/byId`](l.bB,`${a}/${i}`);return{secretName:`${a}/${i}`,xmlContent:r?.decodedData?.["autounattend.xml"]||""}},compareSSHValue(e="",t=""){const s=/(\r\n\t|\n|\r\t)|(\s*)/gm;return e.replace(s,"")===t.replace(s,"")},mergeAllSSHs(e){const t=this.getSSHFromAnnotation(e),{userScript:s}=this.getCloudInitNoCloud(e);if(!t?.length<0&&!s)return[];let a=[];const i=this.$store.getters["currentProduct"].inStore,r=this.$store.getters[`${i}/all`](p.rk.SSH)||[];a=(t||[]).map(e=>{const t=r.find(t=>t.id===e);return t?{id:t.id,data:t,type:f.EXISTING_ALL}:{id:e,data:e,type:f.EXISTING_ONLY_ANNOTATION}});const n=this.getSSHFromUserData(s);return n.map(e=>{const t=r.find(t=>this.compareSSHValue(e,t.spec?.publicKey));t&&!a.find(e=>e.id===t.id)?a.push({id:t.id,data:t,type:f.EXISTING_ALL}):t||a.push({id:"Unknown",data:e,type:f.EXISTING_ONLY_CLOUD})}),a}}}},48249:function(e,t,s){s.d(t,{OS:function(){return _},PO:function(){return D}});var a=s(5159),i=s(20246),r=s.n(i),n=s(46343),o=s.n(n),c=s(3514),l=s.n(c),m=s(88088),p=s.n(m),d=s(74302),h=s(76978),u=s(58434),g=s(88339),y=s(92043),f=s(4514),S=s(95799),v=s(14220),N=s(35664),A=s(2841),E=s(2602),T=s(68851),C=s(66905),M=s(50889),k=s(32766),I=s(66490),b=s(73975),w=s(84757),$=s(41837),P=s(4364);const O="longhorn-system/v2-data-engine",D="management Network",_=[{label:"Windows",value:"windows"},{label:"Linux",value:"linux"},{label:"SUSE Linux Enterprise",value:"SLEs"},{label:"Debian",value:"debian"},{label:"Fedora",value:"fedora"},{label:"Gentoo",value:"gentoo"},{label:"Oracle",value:"oracle"},{label:"Red Hat",match:["redhat","rhel"],value:"redhat"},{label:"openSUSE",value:"openSUSE"},{label:"Ubuntu",value:"ubuntu"},{label:"Other Linux",match:["centos"],value:"otherLinux"}],R="cd-rom",V="disk";t.Ay={mixins:[b.Ay],props:{value:{type:Object,required:!0},resourceType:{type:String,default:""}},async fetch(){const e=this.$store.getters["currentProduct"].inStore,t={pvs:this.$store.dispatch(`${e}/findAll`,{type:N.PV}),pvcs:this.$store.dispatch(`${e}/findAll`,{type:N.YH}),storageClasses:this.$store.dispatch(`${e}/findAll`,{type:N.fJ}),sshs:this.$store.dispatch(`${e}/findAll`,{type:k.rk.SSH}),settings:this.$store.dispatch(`${e}/findAll`,{type:k.rk.SETTING}),images:this.$store.dispatch(`${e}/findAll`,{type:k.rk.IMAGE}),versions:this.$store.dispatch(`${e}/findAll`,{type:k.rk.VM_VERSION}),templates:this.$store.dispatch(`${e}/findAll`,{type:k.rk.VM_TEMPLATE}),networkAttachment:this.$store.dispatch(`${e}/findAll`,{type:N.XG}),vmis:this.$store.dispatch(`${e}/findAll`,{type:k.rk.VMI}),vmims:this.$store.dispatch(`${e}/findAll`,{type:k.rk.VMIM}),vms:this.$store.dispatch(`${e}/findAll`,{type:k.rk.VM}),secrets:this.$store.dispatch(`${e}/findAll`,{type:N.bB}),configMaps:this.$store.dispatch(`${e}/findAll`,{type:N.K5}),serviceAccounts:this.$store.dispatch(`${e}/findAll`,{type:N.Sg}),addons:this.$store.dispatch(`${e}/findAll`,{type:k.rk.ADD_ONS}),longhornV2Engine:this.$store.dispatch(`${e}/find`,{type:N.oe.SETTINGS,id:O})};this.$store.getters[`${e}/schemaFor`](N.NW)&&(t.nodes=this.$store.dispatch(`${e}/findAll`,{type:N.NW})),this.$store.getters[`${e}/schemaFor`](k.rk.CLUSTER_NETWORK)&&(t.clusterNetworks=this.$store.dispatch(`${e}/findAll`,{type:k.rk.CLUSTER_NETWORK})),this.$store.getters[`${e}/schemaFor`](k.rk.VLAN_CONFIG)&&(t.clusterNetworks=this.$store.dispatch(`${e}/findAll`,{type:k.rk.VLAN_CONFIG})),this.$store.getters[`${e}/schemaFor`](N.oe.VOLUMES)&&(t.longhornVolumes=this.$store.dispatch(`${e}/findAll`,{type:N.oe.VOLUMES}));const s=await(0,g.kR)(t),a=!!this.$store.getters[`${e}/schemaFor`](k.rk.PCI_DEVICE),i=!!this.$store.getters[`${e}/schemaFor`](k.rk.SR_IOVGPU_DEVICE),r=s.addons.reduce((e,t)=>({...e,[t.name]:t.spec?.enabled}),{});this.enabledPCI=a&&r[C.Jo.PCI_DEVICE_CONTROLLER],this.enabledSriovgpu=i&&r[C.Jo.PCI_DEVICE_CONTROLLER]&&r[C.Jo.NVIDIA_DRIVER_TOOLKIT_CONTROLLER]},data(){const e=this.realMode===v.dT;return{OS:_,isClone:e,showYaml:!1,spec:null,osType:"linux",useTemplate:!1,sshKey:[],maintenanceStrategies:C.hg,maintenanceStrategy:"Migrate",runStrategies:C.vo,runStrategy:"RerunOnFailure",installAgent:!0,hasCreateVolumes:[],installUSBTablet:!0,networkScript:"",userScript:"",imageId:"",diskRows:[],networkRows:[],filesystemRows:[],machineType:"",machineTypes:[],secretName:"",secretNamePrefixUsed:"",sysprepSecretNamePrefixUsed:"",secretRef:null,showAdvanced:!1,deleteAgent:!0,memory:null,cpu:"",maxMemory:null,maxCpu:"",cpuMemoryHotplugEnabled:!1,reservedMemory:null,accessCredentials:[],efiEnabled:!1,tpmEnabled:!1,tpmPersistentStateEnabled:!1,efiPersistentStateEnabled:!1,secureBoot:!1,userDataTemplateId:"",saveUserDataAsClearText:!1,saveNetworkDataAsClearText:!1,enabledPCI:!1,enabledSriovgpu:!1,immutableMode:this.realMode===v.YQ?v.YQ:v.nW,terminationGracePeriodSeconds:"",cpuPinning:!1,cpuModel:"",sysprep:{secretName:"",xmlContent:""}}},computed:{inStore(){return this.$store.getters["currentProduct"].inStore},images(){return this.$store.getters[`${this.inStore}/all`](k.rk.IMAGE)},versions(){return this.$store.getters[`${this.inStore}/all`](k.rk.VM_VERSION)},templates(){return this.$store.getters[`${this.inStore}/all`](k.rk.VM_TEMPLATE)},pvcs(){return this.$store.getters[`${this.inStore}/all`](N.YH)},secrets(){return this.$store.getters[`${this.inStore}/all`](N.bB)},filteredNamespaces(){return this.$store.getters["harvester/all"](N.CU).filter(e=>!e.isSystem)},nodes(){return this.$store.getters["harvester/all"](N.NW)},nodesIdOptions(){const e=this.$store.getters[`${this.inStore}/all`](N.NW),t=this.networkRows.map(e=>e.networkName),s=this.$store.getters[`${this.inStore}/all`](N.XG),a=t.map(e=>s.find(t=>t.id===e)).filter(e=>e?.id),i=(0,T.sb)(a.map(e=>e.clusterNetworkResource?.id));return e.filter(e=>!e.isUnSchedulable&&"true"!==e.isEtcd).map(e=>{const t=[];let s=!0;return i.length>0&&i.map(e=>{t.push(`network.harvesterhci.io/${e}`)}),t.map(t=>{"true"!==e.metadata?.labels?.[t]&&(s=!1)}),{label:s?e.nameDisplay:`${e.nameDisplay} (${this.t("harvester.virtualMachine.scheduling.networkNotSupport")})`,value:e.id,disabled:!s}})},storageClassSetting(){try{const e=this.$store.getters[`${this.inStore}/all`](k.rk.SETTING).find(e=>e.id===M.EP.DEFAULT_STORAGE_CLASS)?.value;return JSON.parse(e)}catch(e){return{}}},customVolumeMode(){return this.storageClassSetting.volumeMode||$.vU.BLOCK},customAccessMode(){return this.storageClassSetting.accessModes||"ReadWriteMany"},isWindows(){return"windows"===this.osType},needNewSecret(){return!this.isCreate&&!this.showYaml&&this.resourceType===k.rk.VM_VERSION},defaultTerminationSetting(){const e=this.$store.getters[`${this.inStore}/all`](k.rk.SETTING).find(e=>e.id===M.EP.VM_TERMINATION_PERIOD)||{};return Number(e?.value||e?.default)},affinityLabels(){return{namespaceInputLabel:this.t("harvester.virtualMachine.affinity.namespaces.label"),namespaceSelectionLabels:[this.t("harvester.virtualMachine.affinity.thisPodNamespace"),this.t("workload.scheduling.affinity.allNamespaces"),this.t("harvester.virtualMachine.affinity.matchExpressions.inNamespaces")],addLabel:this.t("harvester.virtualMachine.affinity.addLabel"),topologyKeyPlaceholder:this.t("harvester.virtualMachine.affinity.topologyKey.placeholder")}}},async created(){if(await this.$store.dispatch(`${this.inStore}/findAll`,{type:N.bB}),this.value.vmMachineTypeAutoFeatureEnabled)this.machineTypes=[""];else try{const e=this.$store.getters["harvester-common/getHarvesterClusterUrl"]("v1/harvester/clusters/local?link=machineTypes"),t=await this.$store.dispatch("harvester/request",{url:e});this.machineTypes=t}catch(e){this.machineTypes=[""]}this.getInitConfig({value:this.value,init:this.isCreate})},methods:{getInitConfig(e){const{value:t,existUserData:s,fromTemplate:a=!1,init:i=!1}=e,r=this.resourceType===k.rk.VM?t:this.resourceType===k.rk.BACKUP?this.value.status?.source:t.spec.vm,n=this.resourceType===k.rk.BACKUP?this.value.status?.volumeBackups:null,o=r?.spec;if(!o)return;const c=o.template.spec.domain.resources;(!c?.limits||c?.limits&&!c?.limits?.memory&&null!==c?.limits?.memory)&&(o.template.spec.domain.resources={...o.template.spec.domain.resources,limits:{...o.template.spec.domain.resources.limits,memory:o.template.spec.domain.resources.requests.memory}}),r.metadata.labels||(r.metadata.labels={});const l=r.metadata.labels?.[E.r.VM_MAINTENANCE_MODE_STRATEGY]||"Migrate",m=o.runStrategy||"RerunOnFailure",p=o.template.spec.domain?.machine?.type||this.machineTypes[0],{cpu:d,memory:h,maxCpu:g,maxMemory:y,isHotplugEnabled:S}=(0,u.J)(r),v=S,N=r.metadata?.annotations?.[E.r.VM_RESERVED_MEMORY],A=o.template.spec?.terminationGracePeriodSeconds||this.defaultTerminationSetting,T=this.getSSHFromAnnotation(o)||[],C=this.getRootImageId(r)||"",M=this.getDiskRows(r,n),I=this.getNetworkRows(r,{fromTemplate:a,init:i}),b=this.getHasCreatedVolumes(o)||[];let{userData:w,networkData:$}=this.getCloudInitNoCloud(o);if(this.resourceType===k.rk.BACKUP){const e=this.value.status?.secretBackups;if(e){const t=e[0]?.data?.networkdata||"",s=e[0]?.data?.userdata||"";w=(0,f.u)(s),$=(0,f.u)(t)}}const P=this.getOsType(r)||"linux";w=!this.isCreate||s||this.isClone?w:this.getInitUserData({osType:P});const O=this.isInstallUSBTablet(o),D=this.hasInstallAgent(w,P,!0),_=this.isEfiEnabled(o),R=this.isTpmEnabled(o),V=this.isTPMPersistentStateEnabled(o),x=this.isEFIPersistentStateEnabled(o),U=this.isSecureBoot(o),L=this.isCpuPinning(o),G=o.template.spec.domain.cpu?.model||"",B=this.getSecret(o),H=this.getAccessCredentials(o);Object.prototype.hasOwnProperty.call(o,"running")&&(delete o.running,o.runStrategy="RerunOnFailure"),this["spec"]=o,this["maintenanceStrategy"]=l,this["runStrategy"]=m,this["secretRef"]=B,this["accessCredentials"]=H,this["userScript"]=w,this["networkScript"]=$,this["sshKey"]=T,this["osType"]=P,this["installAgent"]=D,this["cpu"]=d,this["memory"]=h,this["maxCpu"]=g,this["maxMemory"]=y,this["cpuMemoryHotplugEnabled"]=v,this["reservedMemory"]=N,this["machineType"]=p,this["terminationGracePeriodSeconds"]=A,this["installUSBTablet"]=O,this["efiEnabled"]=_,this["efiPersistentStateEnabled"]=x,this["tpmEnabled"]=R,this["tpmPersistentStateEnabled"]=V,this["secureBoot"]=U,this["cpuPinning"]=L,this["cpuModel"]=G,this["hasCreateVolumes"]=b,this["networkRows"]=I,this["imageId"]=C,this["diskRows"]=M,this["filesystemRows"]=this.getFilesystemRows(r);let Y={secretName:"",xmlContent:""};"windows"===P&&(Y=this.getSysprepConfig(o)),this["sysprep"]={secretName:Y.secretName||this.sysprep?.secretName||"",xmlContent:Y.xmlContent||this.sysprep?.xmlContent||""},this.refreshYamlEditor()},getDiskRows(e,t){const s=e.metadata.namespace,a=e.spec.template.spec.volumes||[],i=e.spec.template.spec.domain.devices.disks||[],r=(0,I.v)(e);let n=[];if(0===i.length){let e="virtio",s=V,a="10Gi";const i=this.images.find(e=>this.imageId===e.id),r=/iso$/i.test(i?.imageSuffix),o=Math.max(i?.status?.size,i?.status?.virtualSize),c=i?.isEncrypted||!1,l=t?.find(e=>"disk-0"===e.volumeName)||null;if(r&&(e="sata",s=R),o){let e=Math.ceil(o/1024/1024/1024);r||(e=Math.max(e,10)),a=`${e}${w.Wl}`}n.push({id:(0,y.vx)(5),source:C.xO.IMAGE,name:"disk-0",accessMode:"ReadWriteMany",bus:e,volumeName:"",size:a,type:s,storageClassName:"",image:this.imageId,volumeMode:$.vU.BLOCK,isEncrypted:c,volumeBackups:l})}else n=i.map((e,i)=>{const n=a.find(t=>t.name===e.name);let o="",c="",l="",m="",p="",d="",h="",u="",g="",f=!1,v=null;const A=e?.cdrom?R:e?.disk?V:"";if(A===R&&void 0===n)l=C.xO.IMAGE,c=I.K,o=`0${w.Wl}`;else if(n.containerDisk)l=C.xO.CONTAINER,p=n.containerDisk.image;else if(n.persistentVolumeClaim&&n.persistentVolumeClaim?.claimName){d=n.persistentVolumeClaim.claimName;const e=r.find(e=>e.metadata.name===d);if(m=d,e){void 0!==e.metadata?.annotations?.[E.r.IMAGE_ID]?(c=e.metadata?.annotations?.[E.r.IMAGE_ID],l=C.xO.IMAGE):l=C.xO.NEW;const t=e?.spec||{};u=t?.volumeMode,h=t?.accessModes?.[0],o=t?.resources?.requests?.storage||"10Gi",g=t?.storageClassName,v=t?.dataSource}else{const e=this.$store.getters["harvester/all"](N.YH),t=e.find(e=>e.id===`${s}/${n?.persistentVolumeClaim?.claimName}`);l=C.xO.ATTACH_VOLUME,h=t?.spec?.accessModes?.[0]||"ReadWriteMany",o=t?.spec?.resources?.requests?.storage||"10Gi",g=t?.spec?.storageClassName,u=t?.spec?.volumeMode||$.vU.BLOCK,d=t?.metadata?.name||""}f=n.persistentVolumeClaim.hotpluggable||!1}const T=e?.disk?.bus||e?.cdrom?.bus,M=e?.bootOrder?e?.bootOrder:i,k=(0,S.ao)(o),b=(0,S.Mo)(k,{increment:1024,addSuffix:!1,maxExponent:3,minExponent:3}),P=this.pvcs.find(e=>e.id===`${this.value.metadata.namespace}/${d}`),O=P?.relatedPV?.metadata?.annotations?.[E.r.VOLUME_ERROR],D=P?.isEncrypted||!1,_=t?.find(t=>t.volumeName===e.name)||null;return{id:(0,y.vx)(5),bootOrder:M,source:l,name:e.name,realName:m,bus:T,volumeName:d,container:p,accessMode:h,size:`${b}${w.Wl}`,volumeMode:u||this.customVolumeMode,image:c,type:A,storageClassName:g,hotpluggable:f,volumeStatus:O,dataSource:v,namespace:s,isEncrypted:D,volumeBackups:_}});return n=(0,d.Ul)(n,"bootOrder"),n.filter(e=>"cloudinitdisk"!==e.name&&"sysprep"!==e.name)},getNetworkRows(e,t){const{fromTemplate:s=!1,init:a=!1}=t,i=e.spec.template.spec.networks||[],r=e.spec.template.spec.domain.devices.interfaces||[],n=e.metadata?.annotations||{},o=`${E.r.STATIC_IP}/`,c=r.map((e,t)=>{const r=i.find(t=>e.name===t.name),c=e.sriov?"sriov":e.bridge?"bridge":"masquerade",l=!!r.pod;return{...e,index:t,type:c,isPod:l,newCreateId:!(!s&&!a)&&(0,y.vx)(10),model:e.model,networkName:l?D:r?.multus?.networkName,staticIp:n[`${o}${e.name}`]||""}});return c},parseVM(){this.userData=this.getUserData({osType:this.osType,installAgent:this.installAgent}),this.parseOther(),this.parseAccessCredentials(),this.parseNetworkRows(this.networkRows),this.parseDiskRows(this.diskRows),this.parseFilesystemRows()},getFilesystemRows(e){const t=e.spec.template.spec.domain.devices?.filesystems||[],s=e.spec.template.spec.volumes||[];return t.map(e=>{const t=s.find(t=>t.name===e.name);let a=$.tB.CONFIGMAP,i="";return t?.configMap?(a=$.tB.CONFIGMAP,i=t.configMap.name):t?.secret?(a=$.tB.SECRET,i=t.secret.secretName):t?.serviceAccount&&(a=$.tB.SERVICEACCOUNT,i=t.serviceAccount.serviceAccountName),{fsType:a,volumeName:e.name,resourceName:i}})},parseFilesystemRows(){const e=this.filesystemRows.filter(e=>e.fsType&&e.volumeName&&e.resourceName),t=e.map(e=>({name:e.volumeName,virtiofs:{}})),s=e.map(e=>e.fsType===$.tB.CONFIGMAP?{name:e.volumeName,configMap:{name:e.resourceName}}:e.fsType===$.tB.SECRET?{name:e.volumeName,secret:{secretName:e.resourceName}}:e.fsType===$.tB.SERVICEACCOUNT?{name:e.volumeName,serviceAccount:{serviceAccountName:e.resourceName}}:null).filter(Boolean);t.length>0?this.spec.template.spec.domain.devices["filesystems"]=t:delete this.spec.template.spec.domain.devices["filesystems"],s.length>0&&(this.spec.template.spec.volumes||(this.spec.template.spec["volumes"]=[]),this.spec.template.spec.volumes.push(...s))},parseOther(){this.spec.template.spec.domain.machine?this.spec.template.spec.domain.machine["type"]=this.machineType:this.spec.template.spec.domain["machine"]={type:this.machineType},this.setCPUAndMemory(),this.spec.template.spec.terminationGracePeriodSeconds=this.terminationGracePeriodSeconds;const e=this.resourceType===k.rk.VM?this.value:this.value.spec.vm;this.syncStaticIpAnnotations(e),this.reservedMemory?e.metadata.annotations[E.r.VM_RESERVED_MEMORY]=this.reservedMemory:delete e.metadata.annotations[E.r.VM_RESERVED_MEMORY],this.cpuMemoryHotplugEnabled?e.metadata.annotations[E.r.VM_CPU_MEMORY_HOTPLUG]=this.cpuMemoryHotplugEnabled.toString():delete e.metadata.annotations[E.r.VM_CPU_MEMORY_HOTPLUG],"Migrate"===this.maintenanceStrategy?delete e.metadata.labels[E.r.VM_MAINTENANCE_MODE_STRATEGY]:e.metadata.labels[E.r.VM_MAINTENANCE_MODE_STRATEGY]=this.maintenanceStrategy},syncStaticIpAnnotations(e){if(!e?.metadata)return;e.metadata.annotations||(e.metadata.annotations={});const t=`${E.r.STATIC_IP}/`;Object.keys(e.metadata.annotations).forEach(s=>{s.startsWith(t)&&delete e.metadata.annotations[s]}),this.networkRows.forEach(s=>{s.name&&s.staticIp&&(e.metadata.annotations[`${t}${s.name}`]=s.staticIp)})},setCPUAndMemory(){this.cpuMemoryHotplugEnabled?(this.spec.template.spec.domain.cpu.sockets=this.cpu,this.spec.template.spec.domain.cpu.cores=1,(0,h.hZ)(this.spec.template.spec,"domain.cpu.maxSockets",this.maxCpu),(0,h.hZ)(this.spec.template.spec,"domain.resources.limits.cpu",this.maxCpu?.toString()),(0,h.hZ)(this.spec.template.spec,"domain.memory.guest",this.memory),(0,h.hZ)(this.spec.template.spec,"domain.memory.maxGuest",this.maxMemory),(0,h.hZ)(this.spec.template.spec,"domain.resources.limits.memory",this.maxMemory)):(this.spec.template.spec.domain.cpu.sockets=1,this.spec.template.spec.domain.cpu.cores=this.cpu,this.spec.template.spec.domain.resources.limits.cpu=this.cpu?.toString(),this.spec.template.spec.domain.resources.limits.memory=this.memory,this.spec?.template?.spec?.domain?.memory?.maxGuest&&delete this.spec.template.spec.domain.memory.maxGuest)},needVolumeRelatedInfo(e){return e.source===C.xO.CONTAINER?[!0,!1]:e.source===C.xO.IMAGE&&e.image===I.K?[!1,!1]:[!0,!0]},parseDiskRows(e){const t=[],s=[],a=[];if(e.forEach((e,i)=>{const r=this.parseDisk(e,i);t.push(r);const n=this.value.metadata?.name||"",o=this.parseDataVolumeName(e,n),[c,l]=this.needVolumeRelatedInfo(e);if(c){const t=this.parseVolume(e,o);s.push(t)}if(l){const t=this.parseVolumeClaimTemplate(e,o);a.push(t)}}),(this.needNewSecret||!this.secretName||this.isCreate&&this.secretNamePrefixUsed!==this.secretNamePrefix)&&(this.secretName=this.generateSecretName(this.secretNamePrefix),this.secretNamePrefixUsed=this.secretNamePrefix),!t.find(e=>"sysprep"===e.name)&&this.isWindows){const e=!!this.sysprep.xmlContent?.trim?.(),a=!this.sysprep.secretName?.trim?.()||this.isCreate&&""!==this.sysprepSecretNamePrefixUsed&&this.sysprepSecretNamePrefixUsed!==this.secretNamePrefix;if(e&&a){const e=this.secretNamePrefix?`${this.secretNamePrefix}-windows-sysprep`:"windows-sysprep";this.sysprep.secretName=`${this.value.metadata.namespace}/${this.generateSecretName(e)}`,this.sysprepSecretNamePrefixUsed=this.secretNamePrefix}if(this.sysprep.secretName){t.push({name:"sysprep",cdrom:{bus:"sata"}});const e=this.sysprep.secretName.split("/")[1]||this.sysprep.secretName;s.push({name:"sysprep",sysprep:{secret:{name:e}}})}}if(!t.find(e=>"cloudinitdisk"===e.name)&&(this.userData||this.networkData)&&!this.isWindows){t.push({name:"cloudinitdisk",disk:{bus:"virtio"}});const e=this.getUserData({osType:this.osType,installAgent:this.installAgent}),a={name:"cloudinitdisk",cloudInitNoCloud:{}};this.saveUserDataAsClearText?a.cloudInitNoCloud.userData=e:a.cloudInitNoCloud.secretRef={name:this.secretName},this.saveNetworkDataAsClearText?a.cloudInitNoCloud.networkData=this.networkScript:a.cloudInitNoCloud.networkDataSecretRef={name:this.secretName},s.push(a)}const i=this.spec?.template?.spec?.domain?.devices?.disks,r=this.mergeDeviceList(i,t);let n={...this.spec,runStrategy:this.runStrategy,template:{...this.spec.template,metadata:{...this.spec?.template?.metadata,annotations:{...this.spec?.template?.metadata?.annotations,[E.r.SSH_NAMES]:JSON.stringify(this.sshKey)},labels:{...this.spec?.template?.metadata?.labels,[E.r.VM_NAME]:this.value?.metadata?.name}},spec:{...this.spec.template?.spec,domain:{...this.spec.template?.spec?.domain,devices:{...this.spec.template?.spec?.domain?.devices,disks:r}},volumes:s}}};0===s.length&&delete n.template.spec.volumes,this.resourceType===k.rk.VM?(this.isSingle||(n=this.multiVMScheduler(n)),this.value.metadata["annotations"]={...this.value.metadata.annotations,[E.r.VOLUME_CLAIM_TEMPLATE]:JSON.stringify(a),[E.r.NETWORK_IPS]:JSON.stringify(this.value.networkIps)},this.value.metadata["labels"]={...this.value.metadata.labels,[E.r.CREATOR]:"harvester",[E.r.OS]:this.osType},this.value["spec"]=n,this["spec"]=n):this.resourceType===k.rk.VM_VERSION&&(this.value.spec.vm["spec"]=n,this.value.spec.vm.metadata["annotations"]={...this.value.spec.vm.metadata.annotations,[E.r.VOLUME_CLAIM_TEMPLATE]:JSON.stringify(a)},this.value.spec.vm.metadata["labels"]={...this.value.spec.vm.metadata.labels,[E.r.OS]:this.osType},this["spec"]=n)},removeTrailingHyphen(e){while(e.endsWith("-"))e=e.slice(0,-1);return e},multiVMScheduler(e){const t=this.removeTrailingHyphen(this.namePrefix);e.template.metadata.labels[E.r.VM_NAME_PREFIX]=t;const s={weight:1,podAffinityTerm:{topologyKey:A.yA,labelSelector:{matchLabels:{[E.r.VM_NAME_PREFIX]:t}}}};return{...e,template:{...e.template,spec:{...e.template.spec,affinity:{...e.template.spec.affinity,podAntiAffinity:{...e.template.spec?.affinity?.podAntiAffinity,preferredDuringSchedulingIgnoredDuringExecution:[...e.template.spec?.affinity?.podAntiAffinity?.preferredDuringSchedulingIgnoredDuringExecution||[],s]}}}}}},parseNetworkRows(e){const t=[],s=[];e.forEach(e=>{const a=this.parseNetwork(e),i=this.parseInterface(e);t.push(a),s.push(i)});const a=this.spec?.template?.spec?.domain?.devices?.interfaces,i=this.mergeInterfaceList(a,s),r={...this.spec.template.spec.domain.devices,interfaces:i};this.isEdit&&0===e.length?r.autoattachPodInterface=!1:delete r.autoattachPodInterface;const n={...this.spec.template.spec,domain:{...this.spec.template.spec.domain,devices:r},networks:t};this.spec.template["spec"]=n},parseAccessCredentials(){const e=[],t={},s=JSON.parse(this.spec?.template?.metadata?.annotations?.[E.r.DYNAMIC_SSHKEYS_USERS]||"[]");for(const a of this.accessCredentials)this.needNewSecret&&(a.secretName=this.generateSecretName(this.secretNamePrefix)),a.source===C.cI.RESET_PWD&&(s.push(a.username),e.push({userPassword:{source:{secret:{secretName:a.secretName}},propagationMethod:{qemuGuestAgent:{}}}})),a.source===C.cI.INJECT_SSH&&(s.push(...a.users),t[a.secretName]=a.sshkeys,e.push({sshPublicKey:{source:{secret:{secretName:a.secretName}},propagationMethod:{qemuGuestAgent:{users:a.users}}}}));0===e.length&&!1===!!this.spec.template.spec.accessCredentials?delete this.spec.template.spec.accessCredentials:this.spec.template.spec.accessCredentials=e,0!==s.length&&(this.spec.template.metadata.annotations[E.r.DYNAMIC_SSHKEYS_USERS]=JSON.stringify(Array.from(new Set(s))),this.spec.template.metadata.annotations[E.r.DYNAMIC_SSHKEYS_NAMES]=JSON.stringify(t))},getMaintenanceStrategyOptionLabel(e){return this.t(`harvester.virtualMachine.maintenanceStrategy.options.${e.label||e}`)},getInitUserData(e){const t=this.getMatchQGA(e.osType),s=r().dump(t);return`#cloud-config\n${s}`},getUserData(e){try{let t=this.userScript?a.Ay.parseDocument(this.userScript):a.Ay.parseDocument({});const s=this.mergeSSHAuthorizedKeys(this.userScript);s.length>0?t.setIn(["ssh_authorized_keys"],s):a.Ay.isCollection(t.getIn("ssh_authorized_keys"))&&t.deleteIn(["ssh_authorized_keys"]),t=e.installAgent?this.mergeQGA({userDataDoc:t,...e}):this.deleteQGA({userDataDoc:t,...e});const i=t.toString();if("{}\n"===i)return;const r=this.hasCloudConfigComment(i);return r?i:`#cloud-config\n${i}`}catch(t){return P.error("Error: Unable to parse yaml document",t),this.userScript}},updateSSHKey(e){this["sshKey"]=e},updateCpuMemory(e,t,s="",a=null,i=!1){this["cpu"]=e,this["memory"]=t,this["maxCpu"]=s,this["maxMemory"]=a,this["cpuMemoryHotplugEnabled"]=i},parseDataVolumeName(e,t){let s="";return s=e.source===C.xO.ATTACH_VOLUME?e.volumeName:this.isClone||!this.hasCreateVolumes.includes(e.realName)?`${t}-${e.name}-${(0,y.vx)(5).toLowerCase()}`:e.realName,s},parseDisk(e,t){const s={name:e.name};return e.type===V?s.disk={bus:e.bus}:e.type===R&&(s.cdrom={bus:e.bus}),s.bootOrder=t+1,s},parseVolume(e,t){const s={name:e.name};return e.source===C.xO.CONTAINER?s.containerDisk={image:e.container}:e.source!==C.xO.IMAGE&&e.source!==C.xO.NEW&&e.source!==C.xO.ATTACH_VOLUME||(s.persistentVolumeClaim={claimName:t},e.hotpluggable&&(s.persistentVolumeClaim.hotpluggable=!0)),s},parseVolumeClaimTemplate(e,t){const s=String(e.size);s.includes("Gi")||s.includes("Ti")||!e.size||(e.size=`${e.size}${w.Wl}`);const a={metadata:{name:t},spec:{accessModes:[e.accessMode],resources:{requests:{storage:e.size}},volumeMode:e.volumeMode}};switch(e.dataSource&&(a.spec.dataSource=e.dataSource),e.source){case C.xO.ATTACH_VOLUME:a.spec.storageClassName=e.storageClassName;break;case C.xO.NEW:a.spec.storageClassName=e.storageClassName;break;case C.xO.IMAGE:{const t=this.images.find(t=>e.image===t.id);t?(a.spec.storageClassName=t.storageClassName,a.metadata.annotations={[E.r.IMAGE_ID]:t.id}):a.metadata.annotations={[E.r.IMAGE_ID]:""};break}}return a},getSSHListValue(e){return e.map(e=>this.getSSHValue(e)).filter(e=>void 0!==e)},parseInterface(e){const t={},s=e.type;return t[s]={},e.macAddress&&(t.macAddress=e.macAddress),t.model=e.model,t.name=e.name,t},parseNetwork(e){const t={name:e.name};return e.isPod?t.pod={}:t.multus={networkName:e.networkName},t},updateUserData(e){this.userScript=e},updateNetworkData(e){this.networkScript=e},mergeSSHAuthorizedKeys(e){try{const t=a.Ay.parseDocument(e).get("ssh_authorized_keys")?.toJSON()||[],s=this.getSSHListValue(this.sshKey);return t.length?[...new Set([...s,...t])]:s}catch(t){return[]}},deleteYamlDocProp(e,t){try{const s=e.getIn([])?.items[0],a=s?.key,i=!!a?.commentBefore?.includes("cloud-config"),r=a.source===t[t.length-1];a&&i&&r||e.deleteIn(t)}catch(s){}},mergeQGA(e){const{osType:t,userDataDoc:s}=e,i=this.getMatchQGA(t),r=s.toString(),n=a.Ay.parse(r);let o=n?.packages||[],c=n?.runcmd||[];if(s.setIn(["package_update"],!0),Array.isArray(o)?o.includes("qemu-guest-agent")||o.push("qemu-guest-agent"):o=b.v6.packages,Array.isArray(c)){let e=-1;const s=c.find(e=>Array.isArray(e)&&e.join("-")===i.runcmd[0].join("-")),a=c.find((s,a)=>!(!Array.isArray(s)||s.join("-")!==this.getSimilarRuncmd(t).join("-"))&&(e=a,!0));a?c[e]=i.runcmd[0]:s||c.push(i.runcmd[0])}else c=i.runcmd;return o.length>0?s.setIn(["packages"],o):(s.setIn(["packages"],[]),this.deleteYamlDocProp(s,["packages"]),this.deleteYamlDocProp(s,["package_update"])),c.length>0?s.setIn(["runcmd"],c):this.deleteYamlDocProp(s,["runcmd"]),s},deleteQGA(e){const{osType:t,userDataDoc:s,deletePackage:i=!1}=e,r=this.$store.getters["harvester/byId"](N.K5,this.userDataTemplateId)?.data?.cloudInit||"",n=s.toString(),o=a.Ay.parse(n),c=o?.packages||[],l=o?.runcmd||[];if(Array.isArray(c)&&i){const e=this.convertToJson(r);for(let t=0;t<c.length;t++)"qemu-guest-agent"===c[t]&&(Array.isArray(e?.packages)&&e.packages.includes("qemu-guest-agent")||c.splice(t,1))}if(Array.isArray(l)){const e=this.getMatchQGA(t);for(let t=0;t<l.length;t++)Array.isArray(l[t])&&l[t].join("-")===e.runcmd[0].join("-")&&l.splice(t,1)}return c.length>0?s.setIn(["packages"],c):(s.setIn(["packages"],[]),this.deleteYamlDocProp(s,["packages"]),this.deleteYamlDocProp(s,["package_update"])),l.length>0?s.setIn(["runcmd"],l):this.deleteYamlDocProp(s,["runcmd"]),s},generateSecretName(e){return e?`${e}-${(0,y.vx)(5).toLowerCase()}`:void 0},getOwnerReferencesFromVM(e){const t=e.metadata.name,s=e.kind,a=this.resourceType===k.rk.VM?"kubevirt.io/v1":"harvesterhci.io/v1beta1",i=e?.metadata?.uid;return[{name:t,kind:s,uid:i,apiVersion:a}]},async saveSecret(e){if(!e?.spec||!this.secretName||this.isWindows)return!0;let t=this.getSecret(e.spec);!t&&this.isEdit&&this.secretRef&&(t=this.secretRef),t&&!this.needNewSecret||(t=await this.$store.dispatch("harvester/create",{metadata:{name:this.secretName,namespace:this.value.metadata.namespace,labels:{[E.r.CLOUD_INIT]:"harvester"},ownerReferences:this.getOwnerReferencesFromVM(e)},type:N.bB}));try{t&&(this.saveUserDataAsClearText&&this.saveNetworkDataAsClearText||(t.setData("userdata",this.userData||""),t.setData("networkdata",this.networkScript||""),await t.save()))}catch(s){return Promise.reject(s)}},async saveAccessCredentials(e){if(!e?.spec)return!0;const t=[];for(const a of this.accessCredentials){let s=a.secretRef;if(s&&!this.needNewSecret||(s=await this.$store.dispatch("harvester/create",{metadata:{name:a.secretName,namespace:e.metadata.namespace,labels:{[E.r.CLOUD_INIT]:"harvester"},ownerReferences:this.getOwnerReferencesFromVM(e)},type:N.bB})),a.source===C.cI.RESET_PWD&&s.setData(a.username,a.newPassword),a.source===C.cI.INJECT_SSH)for(const e of a.sshkeys){const t=(this.$store.getters["harvester/all"](k.rk.SSH)||[]).find(t=>t.id===e);s.setData(`${t.metadata.namespace}-${t.metadata.name}`,t.spec.publicKey)}t.push(s)}try{for(const e of t)await e.save()}catch(s){return Promise.reject(s)}},async saveSysprepConfig(e){if(!this.isWindows)return;if(!this.sysprep.secretName?.trim?.()&&!this.sysprep.xmlContent?.trim?.())return;const t=this.sysprep.secretName.split("/")[1]||this.sysprep.secretName,s=e.metadata.namespace,a=`${s}/${t}`;let i;try{i=await this.$store.dispatch("harvester/find",{type:N.bB,id:a})}catch(r){if(404!==r?.status)throw r;i=await this.$store.dispatch("harvester/create",{type:N.bB,metadata:{name:t,namespace:s,labels:{[E.r.WINDOWS_SYSPREP]:"true"}}})}i.setData("autounattend.xml",this.sysprep.xmlContent),await i.save()},getAccessCredentialsValidation(){const e=[];for(let t=0;t<this.accessCredentials.length;t++){const s=this.accessCredentials[t],a=s.source;if(a===C.cI.RESET_PWD){if(!s.username){const t=this.t("harvester.virtualMachine.input.username"),s=this.t("validation.required",{key:t});e.push(s)}if(!s.newPassword){const t=this.t("harvester.virtualMachine.input.password"),s=this.t("validation.required",{key:t});e.push(s)}if(s.newPassword&&s.newPassword.length<6){const t=this.t("harvester.virtualMachine.input.password"),s=this.t("validation.number.min",{key:t,val:"6"});e.push(s)}}else{if(!s.users||0===s.users.length){const t=this.t("harvester.virtualMachine.input.username"),s=this.t("validation.required",{key:t});e.push(s)}if(!s.sshkeys||0===s.sshkeys.length){const t=this.t("harvester.virtualMachine.input.sshKeyValue"),s=this.t("validation.required",{key:t});e.push(s)}}if(e.length>0)break}return e},getHasCreatedVolumes(e){const t=[];return e.template.spec.volumes&&e.template.spec.volumes.forEach(e=>{e?.persistentVolumeClaim?.claimName&&t.push(e.persistentVolumeClaim.claimName)}),t},handlerUSBTablet(e){const t=this.isInstallUSBTablet(this.spec),s=this.spec.template.spec.domain.devices?.inputs||[];if(e&&!t)s.length>0?s.push(b.wM[0]):Object.assign(this.spec.template.spec.domain.devices,{inputs:[b.wM[0]]});else if(!e){const e=s.findIndex(e=>o()(e,b.wM[0]));t&&1===s.length?delete this.spec.template.spec.domain.devices["inputs"]:t&&(s.splice(e,1),this.spec.template.spec.domain.devices["inputs"]=s)}},setBootMethod(e={efi:!1,secureBoot:!1,efiPersistentStateEnabled:!1}){if(!e.efi)return delete this.spec.template.spec.domain["firmware"],void delete this.spec.template.spec.domain.features["smm"];if((0,h.hZ)(this.spec.template.spec.domain,"firmware.bootloader.efi.secureBoot",e.secureBoot),e.secureBoot)(0,h.hZ)(this.spec.template.spec.domain,"features.smm.enabled",!0);else try{delete this.spec.template.spec.domain.features.smm["enabled"];const e=0===Object.keys(this.spec.template.spec.domain.features.smm).length;e&&delete this.spec.template.spec.domain.features["smm"]}catch(t){}e.efiPersistentStateEnabled?(0,h.hZ)(this.spec.template.spec.domain,"firmware.bootloader.efi.persistent",!0):delete this.spec.template.spec.domain.firmware.bootloader.efi["persistent"]},setCpuPinning(e){e?(0,h.hZ)(this.spec.template.spec.domain.cpu,"dedicatedCpuPlacement",!0):delete this.spec.template.spec.domain.cpu["dedicatedCpuPlacement"]},setTPM({tpmEnabled:e=!1,tpmPersistentStateEnabled:t=!1}={}){e?(0,h.hZ)(this.spec.template.spec.domain.devices,"tpm",t?{persistent:!0}:{}):delete this.spec.template.spec.domain.devices["tpm"]},deleteSSHFromUserData(e=[]){const t=this.getSSHFromUserData(this.userScript);e.map(e=>{const s=t.findIndex(t=>t===this.getSSHValue(e));s>=0&&t.splice(s,1)});const s=this.convertToJson(this.userScript);s.ssh_authorized_keys=t,0===t.length&&delete s.ssh_authorized_keys,l()(s)?this["userScript"]=void 0:this["userScript"]=r().dump(s),this.refreshYamlEditor()},mergeInterfaceList(e,t){if(!e||0===e.length)return t;const s=new Map(e.map(e=>[e.name,e]));return t.map(e=>{const t=s.get(e.name);if(t){const s={...t,...e};return e["bridge"]?delete s["masquerade"]:delete s["bridge"],s}return e})},mergeDeviceList(e,t){if(!e||0===e.length)return t;const s=new Map(e.map(e=>[e.name,e]));return t.map(e=>{const t=s.get(e.name);if(t){const s={...t,...e},a=e?.cdrom?R:e?.disk?V:"";return a===R?delete s.disk:a===V&&delete s.cdrom,s}return e})},refreshYamlEditor(){this.$nextTick(()=>{this.$refs.yamlEditor?.updateValue()})},toggleAdvanced(){this.showAdvanced=!this.showAdvanced},updateAgent(e){e||(this.deletePackage=!0)},updateDataTemplateId(e,t){if("user"===e){const e=this.installAgent;this.userDataTemplateId=t,this.$nextTick(()=>{e&&(this.installAgent=e)})}},updateReserved(e={}){const{memory:t}=e;this["reservedMemory"]=t},updateTerminationGracePeriodSeconds(e){this["terminationGracePeriodSeconds"]=e}},watch:{networkRows:{handler(){const e=this.resourceType===k.rk.VM?this.value:this.value?.spec?.vm;this.syncStaticIpAnnotations(e)},deep:!0},diskRows:{handler(e,t){if(Array.isArray(e)){const s=e[0]?.image,a=this.images.find(e=>s===e.id),i=a?.imageOSType,r=t[0]?.image;this.isCreate&&r!==s&&s&&i&&(this.osType=i)}}},secretRef:{handler(e){e&&this.resourceType!==k.rk.BACKUP&&!this.useTemplate&&(this.secretName=e?.metadata.name)},immediate:!0,deep:!0},isWindows(e){e&&(this["sshKey"]=[],this["userScript"]=void 0,this["networkScript"]=void 0,this["installAgent"]=!1)},installUSBTablet(e){this.handlerUSBTablet(e)},efiEnabled(e){this.setBootMethod({efi:e,secureBoot:this.secureBoot,efiPersistentStateEnabled:this.efiPersistentStateEnabled})},secureBoot(e){this.setBootMethod({efi:this.efiEnabled,secureBoot:e,efiPersistentStateEnabled:this.efiPersistentStateEnabled})},efiPersistentStateEnabled(e){this.setBootMethod({efi:this.efiEnabled,secureBoot:this.secureBoot,efiPersistentStateEnabled:e})},cpuPinning(e){this.setCpuPinning(e)},tpmEnabled(e){this.setTPM({tpmEnabled:e,tpmPersistentStateEnabled:this.tpmPersistentStateEnabled})},tpmPersistentStateEnabled(e){this.setTPM({tpmEnabled:this.tpmEnabled,tpmPersistentStateEnabled:e})},installAgent:{handler(e){this.deleteAgent&&(this["userScript"]=this.getUserData({installAgent:e,osType:this.osType,deletePackage:this.deletePackage}),this.refreshYamlEditor()),this.deleteAgent=!0,this.deletePackage=!1}},osType(e,t){this.installAgent="windows"===t||this.installAgent;const s="windows"===t?this.getInitUserData({osType:e}):this.getUserData({installAgent:this.installAgent,osType:e});this["userScript"]=s,this.refreshYamlEditor()},userScript(e,t){const s=this.hasInstallAgent(e,this.osType,this.installAgent);s!==this.installAgent&&(this.deleteAgent=!1,this.installAgent=s)},sshKey(e,t){const s=p()(t,e);s.length>0&&this.isCreate&&this.deleteSSHFromUserData(s),this.userScript=this.getUserData({installAgent:this.installAgent,osType:this.osType}),this.refreshYamlEditor()}}}}}]);
//# sourceMappingURL=harvester-1.9.0-rc2.umd.min.431.js.map