Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64
Your IP : 18.219.44.171
import{d as s,r as y,A as V,j as a,aG as T,f as j,q as m,aH as A,L as w,l as L,n as R,aI as h,G as _}from"./index-13b2882d.js";import{F as g}from"./FormMenuItem-c8a1a121.js";import{u as I}from"./updateMaxHeight-325b3cd4.js";import{Y as H}from"./instanceValidation-45cfba9a.js";import{g as M,C as b}from"./ConfigurationTable-1a9d4d6f.js";import{f as E}from"./networks-5caac489.js";import{s as B}from"./settings-c23f9009.js";import{A as U}from"./AutoExpandingTextArea-3a779a81.js";const F="Main configuration",P="Bridge",C="DNS",S="IPv4",f="IPv6",D="YAML configuration",q=({active:e,setActive:n,formik:l})=>{var u;const t=s.useNotify(),[i,r]=y.useState(!l.values.isCreating),p={active:e,setActive:n},o=l.values.name.length>0?void 0:"Please enter a network name to enable this section",v=()=>{I("form-navigation","p-bottom-controls")};return y.useEffect(v,[(u=t.notification)==null?void 0:u.message]),V("resize",v),a.jsx("div",{className:"p-side-navigation--accordion form-navigation",children:a.jsx("nav",{"aria-label":"Network form navigation",children:a.jsxs("ul",{className:"p-side-navigation__list",children:[a.jsx(g,{label:F,...p}),a.jsxs("li",{className:"p-side-navigation__item",children:[a.jsx(s.Button,{type:"button",className:"p-side-navigation__accordion-button","aria-expanded":i?"true":"false",onClick:()=>r(!i),disabled:!!o,title:o,children:"Advanced"}),a.jsxs("ul",{className:"p-side-navigation__list","aria-expanded":i?"true":"false",children:[a.jsx(g,{label:P,...p,disableReason:o}),a.jsx(g,{label:C,...p,disableReason:o}),l.values.ipv4_address!=="none"&&a.jsx(g,{label:S,...p,disableReason:o}),l.values.ipv6_address!=="none"&&a.jsx(g,{label:f,...p,disableReason:o})]})]}),a.jsx(g,{label:D,...p,disableReason:o})]})})})},N=({id:e,address:n,setAddress:l})=>{const t=n!=="none"&&n!=="auto";return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"ip-address-selector",children:[a.jsx(s.RadioInput,{label:"auto",checked:n==="auto",onChange:()=>l("auto")}),a.jsx(s.RadioInput,{label:"off",checked:n==="none",onChange:()=>l("none")})]}),a.jsxs("div",{className:"ip-address-selector ip-address-custom",children:[a.jsx(s.RadioInput,{label:"",checked:t,onChange:()=>l("")}),a.jsx(s.Input,{id:e,name:e,type:"text",placeholder:"Enter address",className:"u-no-margin--bottom",onChange:i=>l(i.target.value),value:t&&n?n:"",disabled:!t})]})]})},d=({formik:e,name:n,label:l,children:t,defaultValue:i,disabled:r=!1,help:p})=>{const o=e.values[n],v=o!==void 0,[u,c]=[T(n),"LXD"],O=e.values.readOnly;return M({formik:e,name:n,label:l,children:t,defaultValue:i,disabled:r,help:p,isOverridden:v,inheritedValue:u,inheritSource:c,isReadOnly:O,value:o,overrideValue:o===""?"-":o})},Y=["bridge","physical"],z=({isDisabled:e,project:n,props:l})=>{var v,u;const{data:t=[],isLoading:i}=j({queryKey:[m.networks,"default"],queryFn:()=>E("default")}),{data:r,isLoading:p}=j({queryKey:[m.projects,n],queryFn:()=>A(n)}),o=(((u=(v=r==null?void 0:r.config)==null?void 0:v["restricted.networks.uplinks"])==null?void 0:u.split(","))||t.filter(c=>Y.includes(c.type)).map(c=>c.name)).map(c=>({label:c,value:c}));return o.unshift({label:t.length===0?"No networks available":"Select option",value:""}),i||p?a.jsx(w,{}):a.jsx(s.Select,{label:"Uplink",help:"Uplink network to use for external network access",disabled:e,options:o,required:!0,...l})},G=({formik:e})=>{const n=L(),{data:l,isLoading:t}=R(),i=B(l);return t?a.jsx(w,{}):a.jsx(s.Select,{id:"type",name:"type",label:"Type",help:i?void 0:a.jsxs(a.Fragment,{children:["OVN needs to be configured."," ",a.jsx("a",{href:`${n}/howto/network_ovn_setup/#set-up-a-lxd-cluster-on-ovn`,target:"_blank",rel:"noreferrer",children:"Learn how to set up OVN"})]}),required:!0,options:[{label:"Bridge",value:"bridge"},{label:i?"OVN":"OVN (not configured)",value:"ovn",disabled:!i}],onChange:r=>{r.target.value==="bridge"&&(e.setFieldValue("type","bridge"),e.setFieldValue("network",void 0),e.setFieldValue("ipv4_l3only",void 0),e.setFieldValue("ipv6_l3only",void 0)),r.target.value==="ovn"&&(e.setFieldValue("type","ovn"),e.setFieldValue("bridge_driver",void 0),e.setFieldValue("dns_mode",void 0),e.setFieldValue("ipv4_dhcp_expiry",void 0),e.setFieldValue("ipv4_dhcp_ranges",void 0),e.setFieldValue("ipv4_ovn_ranges",void 0),e.setFieldValue("ipv6_dhcp_expiry",void 0),e.setFieldValue("ipv6_dhcp_ranges",void 0),e.setFieldValue("ipv6_ovn_ranges",void 0))},value:e.values.type,disabled:e.values.readOnly})},K=({formik:e,project:n})=>{const l=t=>({id:t,name:t,onBlur:e.handleBlur,onChange:e.handleChange,value:e.values[t]??"",error:e.touched[t]?e.errors[t]:null,placeholder:`Enter ${t.replaceAll("_"," ")}`});return a.jsxs(a.Fragment,{children:[a.jsx(s.Row,{children:a.jsxs(s.Col,{size:8,children:[a.jsx(G,{formik:e}),a.jsx(s.Input,{...l("name"),type:"text",label:"Name",required:!0,disabled:e.values.readOnly||!e.values.isCreating,help:e.values.isCreating?void 0:"Click the name in the header to rename the network"}),a.jsx(U,{...l("description"),label:"Description",disabled:e.values.readOnly,dynamicHeight:!0}),e.values.type==="ovn"&&a.jsx(z,{props:l("network"),project:n,isDisabled:e.values.readOnly})]})}),a.jsx(b,{rows:[d({formik:e,name:"ipv4_address",label:"IPv4 address",defaultValue:"auto",children:a.jsx(N,{id:"ipv4_address",address:e.values.ipv4_address,setAddress:t=>{e.setFieldValue("ipv4_address",t),t==="none"&&["ipv4_nat","ipv4_dhcp","ipv4_dhcp_expiry","ipv4_dhcp_ranges"].forEach(r=>void e.setFieldValue(r,void 0))}})}),...e.values.ipv4_address!=="none"?[d({formik:e,name:"ipv4_nat",label:"IPv4 NAT",defaultValue:"",children:a.jsx(s.Select,{options:h})})]:[],d({formik:e,name:"ipv6_address",label:"IPv6 address",defaultValue:"auto",children:a.jsx(N,{id:"ipv6_address",address:e.values.ipv6_address,setAddress:t=>{e.setFieldValue("ipv6_address",t),t==="none"&&["ipv6_nat","ipv6_dhcp","ipv6_dhcp_expiry","ipv6_dhcp_ranges","ipv6_dhcp_stateful","ipv6_ovn_ranges"].forEach(r=>void e.setFieldValue(r,void 0))}})}),...e.values.ipv6_address!=="none"?[d({formik:e,name:"ipv6_nat",label:"IPv6 NAT",defaultValue:"",children:a.jsx(s.Select,{options:h})})]:[]]})]})},W=({formik:e})=>a.jsx(b,{rows:[d({formik:e,name:"bridge_mtu",label:"MTU",help:"Bridge MTU (default varies if tunnel or fan setup)",defaultValue:"",children:a.jsx(s.Input,{type:"text"})}),d({formik:e,name:"bridge_hwaddr",label:"Hardware address",help:"MAC address for the bridge",defaultValue:"",children:a.jsx(s.Input,{type:"text"})}),...e.values.type==="bridge"?[d({formik:e,name:"bridge_driver",label:"Bridge driver",help:"Native or openvswitch",defaultValue:"",children:a.jsx(s.Select,{options:[{label:"Select option",value:"",disabled:!0},{label:"Native",value:"native"},{label:"Openvswitch",value:"openvswitch"}]})})]:[]]}),$=({formik:e})=>a.jsx(b,{rows:[d({formik:e,name:"dns_domain",label:"DNS domain",help:"Domain to advertise to DHCP clients and use for DNS resolution",defaultValue:"",children:a.jsx(s.Input,{type:"text"})}),...e.values.type==="bridge"?[d({formik:e,name:"dns_mode",label:"DNS mode",defaultValue:"",children:a.jsx(s.Select,{options:[{label:"Select option",value:"",disabled:!0},{label:"None",value:"none"},{label:"Managed",value:"managed"},{label:"Dynamic",value:"dynamic"}]})})]:[],d({formik:e,name:"dns_search",label:"DNS search",help:"Full comma-separated domain search list, defaulting to DNS domain value",defaultValue:"",children:a.jsx(s.Textarea,{})})]}),Q=({formik:e})=>{const n=e.values.ipv4_dhcp!=="false";return a.jsx(b,{rows:[d({formik:e,name:"ipv4_dhcp",label:"IPv4 DHCP",defaultValue:"",children:a.jsx(s.Select,{options:h})}),...e.values.type!=="ovn"&&n?[d({formik:e,name:"ipv4_dhcp_expiry",label:"IPv4 DHCP expiry",help:"When to expire DHCP leases",defaultValue:"",children:a.jsx(s.Input,{type:"text"})}),d({formik:e,name:"ipv4_dhcp_ranges",label:"IPv4 DHCP ranges",help:"Comma-separated list of IP ranges to use for DHCP (FIRST-LAST format)",defaultValue:"",children:a.jsx(s.Textarea,{})})]:[],...e.values.type==="ovn"?[d({formik:e,name:"ipv4_l3only",label:"IPv4 L3 only",defaultValue:"",children:a.jsx(s.Select,{options:h})})]:[],...e.values.type!=="ovn"?[d({formik:e,name:"ipv4_ovn_ranges",label:"IPv4 OVN ranges",help:"Comma-separated list of IPv4 ranges to use for child OVN network routers (FIRST-LAST format)",defaultValue:"",children:a.jsx(s.Textarea,{})})]:[]]})},X=({formik:e})=>{const n=e.values.ipv6_dhcp!=="false";return a.jsx(b,{rows:[d({formik:e,name:"ipv6_dhcp",label:"IPv6 DHCP",defaultValue:"",children:a.jsx(s.Select,{options:h})}),...n&&e.values.type!=="ovn"?[d({formik:e,name:"ipv6_dhcp_expiry",label:"IPv6 DHCP expiry",help:"When to expire DHCP leases",defaultValue:"",children:a.jsx(s.Input,{type:"text"})}),d({formik:e,name:"ipv6_dhcp_ranges",label:"IPv6 DHCP ranges",help:"Comma-separated list of IPv6 ranges to use for DHCP (FIRST-LAST format)",defaultValue:"",children:a.jsx(s.Textarea,{})})]:[],...n?[d({formik:e,name:"ipv6_dhcp_stateful",label:"IPv6 DHCP stateful",defaultValue:"",children:a.jsx(s.Select,{options:h})})]:[],...e.values.type==="ovn"?[d({formik:e,name:"ipv6_l3only",label:"IPv6 L3 only",defaultValue:"",children:a.jsx(s.Select,{options:h})})]:[],...e.values.type!=="ovn"?[d({formik:e,name:"ipv6_ovn_ranges",label:"IPv6 OVN ranges",help:"Comma-separated list of IPv6 ranges to use for child OVN network routers (FIRST-LAST format)",defaultValue:"",children:a.jsx(s.Textarea,{})})]:[]]})},de=e=>({name:e.name,description:e.description,type:e.type,config:{"bridge.driver":e.bridge_driver,"bridge.hwaddr":e.bridge_hwaddr,"bridge.mtu":e.bridge_mtu,"dns.domain":e.dns_domain,"dns.mode":e.dns_mode,"dns.search":e.dns_search,"ipv4.address":e.ipv4_address,"ipv4.dhcp":e.ipv4_dhcp,"ipv4.dhcp.expiry":e.ipv4_dhcp_expiry,"ipv4.dhcp.ranges":e.ipv4_dhcp_ranges,"ipv4.l3only":e.ipv4_l3only,"ipv4.nat":e.ipv4_nat,"ipv4.nat.address":e.ipv4_nat_address,"ipv4.ovn.ranges":e.ipv4_ovn_ranges,"ipv6.address":e.ipv6_address,"ipv6.dhcp":e.ipv6_dhcp,"ipv6.dhcp.expiry":e.ipv6_dhcp_expiry,"ipv6.dhcp.ranges":e.ipv6_dhcp_ranges,"ipv6.dhcp.stateful":e.ipv6_dhcp_stateful,"ipv6.l3only":e.ipv6_l3only,"ipv6.nat":e.ipv6_nat,"ipv6.nat.address":e.ipv6_nat_address,"ipv6.ovn.ranges":e.ipv6_ovn_ranges,network:e.network}}),ie=({formik:e,getYaml:n,project:l,section:t,setSection:i})=>{var x;const r=s.useNotify(),p=()=>{I("form-contents","p-bottom-controls")};return y.useEffect(p,[(x=r.notification)==null?void 0:x.message,t]),V("resize",p),a.jsxs(s.Form,{className:"form network-form",onSubmit:e.handleSubmit,children:[a.jsx(s.Input,{type:"submit",hidden:!0}),a.jsx(q,{active:t,setActive:i,formik:e}),a.jsx(s.Row,{className:"form-contents",children:a.jsxs(s.Col,{size:12,children:[t===_(F)&&a.jsx(K,{formik:e,project:l}),t===_(P)&&a.jsx(W,{formik:e}),t===_(C)&&a.jsx($,{formik:e}),t===_(S)&&a.jsx(Q,{formik:e}),t===_(f)&&a.jsx(X,{formik:e}),t===_(D)&&a.jsx(H,{yaml:n(),setYaml:o=>void e.setFieldValue("yaml",o),isReadOnly:e.values.readOnly,children:a.jsx(s.Notification,{severity:"caution",title:"Before you edit the YAML",children:"Changes will be discarded, when switching back to the guided forms."})})]})},t)]})};export{F as M,ie as N,de as t};
|