Your IP : 216.73.216.189


Current Path : /proc/thread-self/root/snap/lxd/39313/share/lxd-ui/assets/
Upload File :
Current File : //proc/thread-self/root/snap/lxd/39313/share/lxd-ui/assets/useStoragePools-qBtKr1j9.js

import{j,E as U,cz as N,bk as D,R as g,az as y,cp as E,cq as B,cB as W,u as R,ae as F,w as h}from"./index-BFGypnt-.js";import{u as L}from"./useClusterMembers-B29_ixY7.js";const b="dir",P="btrfs",v="lvm",w="zfs",m="ceph",_="cephfs",f="cephobject",S="powerflex",x="powerstore",C="pure",O="alletra",H={[b]:"Directory",[P]:"Btrfs",[v]:"LVM",[w]:"ZFS",[m]:"Ceph",[_]:"CephFS",[S]:"Dell PowerFlex",[x]:"Dell PowerStore",[C]:"Pure Storage",[f]:"Ceph Object",[O]:"HPE Alletra"},M={[O]:"HPE Alletra block storage",[P]:"Copy-on-Write filesystem with native subvolumes and snapshots",[m]:"Distributed Ceph RBD block storage",[_]:"Distributed Ceph filesystem",[f]:"S3-compatible Ceph object storage via RADOS gateway",[b]:"Basic local directory (no native snapshots or quotas)",[v]:"Logical volume-backed block storage with thin provisioning",[S]:"Dell PowerFlex software-defined block storage",[x]:"Purpose-built all-flash block and file storage appliance",[C]:"Pure Storage FlashArray block storage",[w]:"Advanced Copy-on-Write filesystem with datasets and zvols (recommended)"},G=[f],J=[m,_],te=e=>G.includes(e),se=e=>J.includes(e),V=e=>{const r=e?.environment?.storage_supported_drivers||[],t=[];for(const s of r){const a=H[s.Name],c=M[s.Name];a&&t.push({value:s.Name,text:a,label:j.jsxs("div",{className:"storage-driver-label",children:[j.jsx("span",{className:"storage-driver-name",children:a}),c&&j.jsx("span",{className:"storage-driver-description u-text--muted",children:c})]})})}return t.sort((s,a)=>s.text.localeCompare(a.text))},oe=e=>new Set(V(e).map(r=>r.value)),z={btrfs:"Optional, path to an existing block device, loop file or Btrfs subvolume",dir:"Optional, path to an existing directory",lvm:"Optional, path to an existing block device, loop file or LVM volume group",zfs:"Optional, path to an existing block device, loop file or ZFS dataset/pool",ceph:"Optional, OSD pool name",cephfs:"Optional, Existing CephFS file system or file system path to use"},ae=e=>Object.keys(z).includes(e)?z[e]:"Not available",ne=[w,v,m,C,f],ce=e=>[m,_,f,S,x].includes(e),u={ceph_cluster_name:"ceph.cluster_name",ceph_osd_pg_num:"ceph.osd.pg_num",ceph_osd_pool_name:"ceph.osd.pool_name",ceph_rbd_clone_copy:"ceph.rbd.clone_copy",ceph_rbd_du:"ceph.rbd.du",ceph_user_name:"ceph.user.name",ceph_rbd_features:"ceph.rbd.features",cephfs_cluster_name:"cephfs.cluster_name",cephfs_create_missing:"cephfs.create_missing",cephfs_fscache:"cephfs.fscache",cephfs_osd_pg_num:"cephfs.osd_pg_num",cephfs_path:"cephfs.path",cephfs_user_name:"cephfs.user.name",cephobject_radosgw_endpoint:"cephobject.radosgw.endpoint",cephobject_cluster_name:"cephobject.cluster_name",cephobject_user_name:"cephobject.user.name",cephobject_bucket_name_prefix:"cephobject.bucket.name_prefix",powerflex_clone_copy:"powerflex.clone_copy",powerflex_domain:"powerflex.domain",powerflex_gateway:"powerflex.gateway",powerflex_gateway_verify:"powerflex.gateway.verify",powerflex_mode:"powerflex.mode",powerflex_pool:"powerflex.pool",powerflex_sdt:"powerflex.sdt",powerflex_user_name:"powerflex.user.name",powerflex_user_password:"powerflex.user.password",powerstore_gateway:"powerstore.gateway",powerstore_gateway_verify:"powerstore.gateway.verify",powerstore_mode:"powerstore.mode",powerstore_user_name:"powerstore.user.name",powerstore_user_password:"powerstore.user.password",pure_api_token:"pure.api.token",pure_gateway:"pure.gateway",pure_gateway_verify:"pure.gateway.verify",pure_mode:"pure.mode",pure_target:"pure.target",zfs_clone_copy:"zfs.clone_copy",zfs_export:"zfs.export",zfs_pool_name:"zfs.pool_name",alletra_target:"alletra.target",alletra_wsapi:"alletra.wsapi",alletra_user_name:"alletra.user.name",alletra_user_password:"alletra.user.password",alletra_wsapi_verify:"alletra.wsapi.verify",alletra_cpg:"alletra.cpg",alletra_mode:"alletra.mode"},le=e=>[P,b,v,w].includes(e),ie=e=>{if(!(e in u))throw new Error(`Could not find ${e} in storagePoolFormFieldToPayloadName`);return u[e]},pe=()=>Object.keys(u).filter(e=>e.startsWith("ceph_")),ue=()=>Object.keys(u).filter(e=>e.startsWith("cephobject_")),de=()=>Object.keys(u).filter(e=>e.startsWith("powerflex_")),me=()=>Object.keys(u).filter(e=>e.startsWith("powerstore_")),he=()=>Object.keys(u).filter(e=>e.startsWith("pure_")),ge=()=>Object.keys(u).filter(e=>e.startsWith("zfs_")),_e=()=>Object.keys(u).filter(e=>e.startsWith("alletra_")),$={[b]:"storage-dir",[P]:"storage-btrfs",[v]:"storage-lvm",[w]:"storage-zfs",[m]:"storage-ceph",[_]:"storage-cephfs",[S]:"storage-powerflex",[x]:"storage-powerstore",[C]:"storage-pure",[f]:"storage-cephobject",[O]:"storage-alletra"},fe=e=>{if(!(e in $))throw new Error(`Could not find ${e} in storagePoolDriverToOptionKey`);return $[e]},ye=(e,r)=>["deduplicate","A storage pool with this name already exists",async t=>U(t,e,r,"storage-pools")],ve=e=>e.values.driver===S&&(!e.values.powerflex_pool||!e.values.powerflex_gateway||!e.values.powerflex_user_password),we=e=>e.values.driver===x&&(!e.values.powerstore_gateway||!e.values.powerstore_user_name||!e.values.powerstore_user_password),be=e=>e.values.driver===C&&(!e.values.pure_gateway||!e.values.pure_api_token),Pe=e=>e.values.driver===O&&(!e.values.alletra_wsapi||!e.values.alletra_user_name||!e.values.alletra_user_password||!e.values.alletra_cpg),Se=e=>e.values.driver===f&&!e.values.cephobject_radosgw_endpoint,xe=e=>e.driver===m,Ce=e=>e.driver===_,De=(e,r)=>{const t=[P,b,v,w];return r&&(t.push(m),t.push(_)),t.includes(e)},A=["can_edit","can_delete"],q=async(e,r,t)=>{const s=new URLSearchParams;return s.set("recursion","1"),D(s,t),E(s,r,A),fetch(`${g}/1.0/storage-pools/${encodeURIComponent(e)}?${s.toString()}`).then(B).then(a=>a)},Z=async e=>{const r=new URLSearchParams;return r.set("recursion","1"),E(r,e,A),fetch(`${g}/1.0/storage-pools?${r.toString()}`).then(y).then(t=>t.metadata)},Q=async(e,r)=>{const t=new URLSearchParams;return D(t,r),fetch(`${g}/1.0/storage-pools/${encodeURIComponent(e)}/resources?${t.toString()}`).then(y).then(s=>s.metadata)},X=async(e,r)=>new Promise((t,s)=>{Promise.allSettled(r.map(async a=>Q(e,a.server_name))).then(a=>{const c=[];for(let l=0;l<r.length;l++){const n=r[l].server_name,d=a[l];if(d.status==="rejected"&&s(W(d,n)),d.status==="fulfilled"){const p=a[l];c.push({...p.value,memberName:n})}}t(c)}).catch(s)}),k=async(e,r)=>{const t=new URLSearchParams;return D(t,r),fetch(`${g}/1.0/storage-pools?${t.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(y).then(s=>s)},K=e=>{const r=new Set(["source","size","zfs.pool_name","lvm.thinpool_name","lvm.vg_name","volatile.initial_source"]),t=Object.keys(e.config||{}),s={},a={};for(const n of t)r.has(n)?s[n]=e.config?.[n]:a[n]=e.config?.[n];const c={...e,config:a},l={...e,config:s};return{clusterPoolPayload:c,memberPoolPayload:l}},Fe=async(e,r,t,s,a,c)=>{const{memberPoolPayload:l,clusterPoolPayload:n}=K(e),p=(await Promise.allSettled(r.map(async o=>{const i={...l,config:{...l.config,source:s?.[o.server_name],size:c?.[o.server_name],"zfs.pool_name":a?.[o.server_name]}};return{operation:await k(i,o.server_name),member:o.server_name}}))).map(o=>{if(o.status==="rejected")throw o?.reason;return o.value});return t&&await Promise.all(p.map(async({operation:o,member:i})=>{await N(o.metadata.id,i)})),k(n)},T=async(e,r)=>{const t=new URLSearchParams;return D(t,r),fetch(`${g}/1.0/storage-pools/${encodeURIComponent(e.name)}?${t.toString()}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(y).then(s=>s)},Oe=async(e,r,t,s,a,c)=>{const{memberPoolPayload:l,clusterPoolPayload:n}=K(e),p=(await Promise.allSettled(r.map(async o=>{const i={...l,config:{...l.config}};return c?.[o.server_name]&&(i.config.size=c[o.server_name]),s?.[o.server_name]&&(i.config.source=s[o.server_name]),a?.[o.server_name]&&(i.config["zfs.pool_name"]=a[o.server_name]),{operation:await T(i,o.server_name),member:o.server_name}}))).map(o=>{if(o.status==="rejected")throw o?.reason;return o.value});return t&&await Promise.all(p.map(async({operation:o,member:i})=>{await N(o.metadata.id,i)})),T(n)},je=async(e,r)=>fetch(`${g}/1.0/storage-pools/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r})}).then(y).then(t=>t),Re=async e=>fetch(`${g}/1.0/storage-pools/${encodeURIComponent(e)}`,{method:"DELETE"}).then(y).then(r=>r),Y=async(e,r,t)=>new Promise((s,a)=>{Promise.allSettled(r.map(async c=>q(e,t,c.server_name))).then(c=>{const l=[];for(let n=0;n<r.length;n++){const d=r[n].server_name,p=c[n];if(p.status==="rejected"&&a(W(p,d)),p.status==="fulfilled"){const o=c[n];l.push({...o.value,memberName:d})}}s(l)}).catch(a)}),ze=(e,r,t)=>{const{isFineGrained:s}=R();return F({queryKey:[h.storage,e,r],queryFn:async()=>q(e,s,r),enabled:(t??!0)&&s!==null})},$e=e=>{const{isFineGrained:r}=R();return F({queryKey:[h.storage],queryFn:async()=>Z(r),enabled:r!==null})},ke=e=>{const{isFineGrained:r}=R(),{data:t=[]}=L();return F({queryKey:[h.storage,e,h.cluster],queryFn:async()=>Y(e,t,r),enabled:r!==null&&t.length>0})},Te=(e,r,t=!0)=>{const{data:s=[]}=L(),a=r?[r]:s;return F({queryKey:[h.storage,e,h.cluster,h.resources,a],queryFn:async()=>X(e??"",a),enabled:t&&!!e&&a.length>0})};export{ae as A,V as B,H as C,O as D,C as E,pe as F,ue as G,de as H,x as I,me as J,he as K,ge as L,_e as M,De as N,oe as O,xe as P,Ce as Q,Re as R,te as S,je as T,ke as U,Oe as V,T as W,ce as X,k as a,we as b,Fe as c,be as d,Pe as e,Se as f,ie as g,ze as h,ve as i,b as j,P as k,le as l,ne as m,f as n,Z as o,S as p,Te as q,Q as r,fe as s,ye as t,$e as u,v,m as w,_ as x,se as y,w as z};