|
| 1 | +<i18n> |
| 2 | +en: |
| 3 | + |
| 4 | +zh: |
| 5 | + ipip_mode: ipip_mode |
| 6 | + vxlan_mode: vxlan_mode |
| 7 | + backend: backend |
| 8 | + calico_mode: calico_mode |
| 9 | +</i18n> |
| 10 | + |
| 11 | + |
| 12 | +<template> |
| 13 | + <div> |
| 14 | + <FieldCommon :holder="vars" :prop="prop" fieldName="calico_mode" :placeholder="$t('calico_mode')" label-width="160px"> |
| 15 | + <template #view>{{ calico_mode }}</template> |
| 16 | + <template #edit> |
| 17 | + <el-radio-group v-model="calico_mode"> |
| 18 | + <el-radio-button label="IPIP">IPIP</el-radio-button> |
| 19 | + <el-radio-button label="VXLAN">VXLAN</el-radio-button> |
| 20 | + </el-radio-group> |
| 21 | + </template> |
| 22 | + </FieldCommon> |
| 23 | + <FieldCommon v-if="calico_mode === 'IPIP'" :holder="vars" :prop="prop" fieldName="calico_ipip_mode" :placeholder="$t('ipip_mode')" label-width="160px"> |
| 24 | + <template #view> |
| 25 | + <span>{{ ipip_mode }}</span> |
| 26 | + </template> |
| 27 | + <template #edit> |
| 28 | + <el-radio-group v-model="ipip_mode"> |
| 29 | + <el-radio label="Always">Always</el-radio> |
| 30 | + <el-radio label="CrossSubnet">CrossSubnet</el-radio> |
| 31 | + </el-radio-group> |
| 32 | + </template> |
| 33 | + </FieldCommon> |
| 34 | + <FieldCommon v-if="calico_mode === 'VXLAN'" :holder="vars" :prop="prop" fieldName="calico_vxlan_mode" :placeholder="$t('vxlan_mode')" label-width="160px"> |
| 35 | + <template #view> |
| 36 | + <span>{{ vxlan_mode }}</span> |
| 37 | + </template> |
| 38 | + <template #edit> |
| 39 | + <el-radio-group v-model="vxlan_mode"> |
| 40 | + <el-radio label="Always">Always</el-radio> |
| 41 | + <el-radio label="CrossSubnet">CrossSubnet</el-radio> |
| 42 | + </el-radio-group> |
| 43 | + </template> |
| 44 | + </FieldCommon> |
| 45 | + <FieldCommon :holder="vars" :prop="prop" fieldName="calico_network_backend" :placeholder="$t('backend')" label-width="160px"> |
| 46 | + <template #view> |
| 47 | + <span>{{ calico_network_backend }}</span> |
| 48 | + </template> |
| 49 | + <template #edit> |
| 50 | + <el-radio-group v-model="calico_network_backend"> |
| 51 | + <el-radio label="bird">bird</el-radio> |
| 52 | + <el-radio label="vxlan">vxlan</el-radio> |
| 53 | + <el-radio label="none">none</el-radio> |
| 54 | + </el-radio-group> |
| 55 | + </template> |
| 56 | + </FieldCommon> |
| 57 | + </div> |
| 58 | +</template> |
| 59 | + |
| 60 | +<script> |
| 61 | +import compareVersions from 'compare-versions' |
| 62 | +
|
| 63 | +export default { |
| 64 | + props: { |
| 65 | + cluster: { type: Object, required: true }, |
| 66 | + }, |
| 67 | + data() { |
| 68 | + return { |
| 69 | +
|
| 70 | + } |
| 71 | + }, |
| 72 | + computed: { |
| 73 | + vars: { |
| 74 | + get () { return this.cluster.inventory.all.children.target.children.k8s_cluster.vars }, |
| 75 | + set () {}, |
| 76 | + }, |
| 77 | + prop() { return 'all.children.target.children.k8s_cluster.vars' }, |
| 78 | + calico_mode: { |
| 79 | + get () { |
| 80 | + if (this.ipip_mode === 'Never') { |
| 81 | + return 'VXLAN' |
| 82 | + } |
| 83 | + if (this.vxlan_mode === 'Never') { |
| 84 | + return 'IPIP' |
| 85 | + } |
| 86 | + return '' |
| 87 | + }, |
| 88 | + set (v) { |
| 89 | + if (v === 'IPIP') { |
| 90 | + this.ipip_mode = 'Always' |
| 91 | + this.vxlan_mode = 'Never' |
| 92 | + } else if (v === 'VXLAN') { |
| 93 | + this.vxlan_mode = 'Always' |
| 94 | + this.ipip_mode = 'Never' |
| 95 | + } |
| 96 | + } |
| 97 | + }, |
| 98 | + ipip_mode: { |
| 99 | + get () { |
| 100 | + if (this.vars.calico_ipip_mode) { |
| 101 | + return this.vars.calico_ipip_mode |
| 102 | + } else { |
| 103 | + if (compareVersions(this.cluster.resourcePackage.data.kubernetes.kube_version, 'v1.24.0') < 0) { |
| 104 | + return 'Always' |
| 105 | + } else { |
| 106 | + return 'Never' |
| 107 | + } |
| 108 | + } |
| 109 | + }, |
| 110 | + set (v) { |
| 111 | + this.vars.calico_ipip_mode = v |
| 112 | + }, |
| 113 | + }, |
| 114 | + vxlan_mode: { |
| 115 | + get () { |
| 116 | + if (this.vars.calico_vxlan_mode) { |
| 117 | + return this.vars.calico_vxlan_mode |
| 118 | + } else { |
| 119 | + if (compareVersions(this.cluster.resourcePackage.data.kubernetes.kube_version, 'v1.24.0') < 0) { |
| 120 | + return 'Never' |
| 121 | + } else { |
| 122 | + return 'Always' |
| 123 | + } |
| 124 | + } |
| 125 | + }, |
| 126 | + set (v) { |
| 127 | + this.vars.calico_vxlan_mode = v |
| 128 | + }, |
| 129 | + }, |
| 130 | + calico_network_backend: { |
| 131 | + get () { |
| 132 | + if (this.vars.calico_network_backend) { |
| 133 | + return this.vars.calico_network_backend |
| 134 | + } else { |
| 135 | + return 'bird' |
| 136 | + } |
| 137 | + }, |
| 138 | + set (v) { |
| 139 | + this.vars.calico_network_backend = v |
| 140 | + } |
| 141 | + } |
| 142 | + }, |
| 143 | + components: { }, |
| 144 | + mounted () { |
| 145 | + }, |
| 146 | + methods: { |
| 147 | + compareVersions, |
| 148 | + } |
| 149 | +} |
| 150 | +</script> |
| 151 | + |
| 152 | +<style scoped lang="scss"> |
| 153 | +
|
| 154 | +</style> |
0 commit comments