feat: 云同步支持设置策略关系、支持不匹配不符合策略的资产 (#3592)

This commit is contained in:
jiangweidong
2023-12-14 11:31:23 +08:00
committed by GitHub
parent ad7b2c4e8f
commit e6a1039387
10 changed files with 54 additions and 18 deletions

View File

@@ -7,10 +7,10 @@
v-bind="data.attrs"
>
<template v-if="data.helpTips" #label>
<el-tooltip placement="bottom" effect="light" popper-class="help-tips">
<el-tooltip placement="top" effect="light" popper-class="help-tips">
<div slot="content" v-html="data.helpTips" />
<el-button style="padding: 0">
<i class="fa fa-info-circle" />
<i class="fa fa-question-circle" />
</el-button>
</el-tooltip>
{{ data.label }}

View File

@@ -16,6 +16,7 @@ export const attrMatchOptions = [
{ label: i18n.t('common.NotEqual'), value: 'not' },
{ label: i18n.t('common.MatchIn'), value: 'in' },
{ label: i18n.t('common.Contains'), value: 'contains' },
{ label: i18n.t('common.Exclude'), value: 'exclude' },
{ label: i18n.t('common.Startswith'), value: 'startswith' },
{ label: i18n.t('common.Endswith'), value: 'endswith' },
{ label: i18n.t('common.Regex'), value: 'regex' },

View File

@@ -512,6 +512,8 @@
"StrategyUpdate": "Update strategy",
"StrategyDetail": "Strategy detail",
"Rule": "Rule",
"RuleRelation": "Rule relation",
"RuleRelationHelpTips": "And: The action is performed only when all conditions are met; Or: If a condition is met, the action will be performed",
"RuleCount": "Number of conditions",
"ActionCount": "Number of actions",
"PolicyName": "Policy name",
@@ -905,6 +907,7 @@
"Regex": "Regex",
"AttrValue": "Attribute Value",
"Contains": "Contains",
"Exclude": "Exclude",
"Match": "Match",
"Spec": "Specific",
"All": "All",
@@ -2232,7 +2235,8 @@
"SCP": "SCP",
"ApsaraStack": "Apsara Stack",
"HostnameStrategy": "Used to produce the asset hostname. For example, 1. Instance name (instanceDemo)2. Instance name and Partial IP (instanceDemo-250.1)",
"IsAlwaysUpdate": "Asset info is kept up-to-date",
"IsAlwaysUpdate": "Keep assets up to date",
"FullySynchronous": "Assets fully synchronized",
"AccountCreate": "Create account",
"AccountList": "Account list",
"AccountUpdate": "Update account",
@@ -2242,7 +2246,9 @@
"Provider": "Provider",
"Validity": "Validity",
"SyncStrategy": "Synchronisation strategy",
"IsAlwaysUpdateHelpTips": "Whether the asset information, including Hostname, IP, Platform, and AdminUser, is updated synchronously each time a synchronization task is performed",
"IsAlwaysUpdateHelpTips": "Whether to synchronize asset information, including host name, IP address, system platform, network domain, and node information, each time a synchronization task is executed",
"FullySynchronousHelpTips": "Whether to continue synchronizing assets when the asset conditions do not meet the matching policy rules",
"StrategyHelpTips": "A unique asset attribute (such as platform) is determined based on the policy priority. If multiple asset attributes (such as nodes) can be configured, all policy actions are executed",
"SyncInstanceTaskCreate": "Create sync task",
"SyncInstanceTaskList": "Sync task list",
"SyncInstanceTaskDetail": "Sync task detail",

View File

@@ -511,6 +511,8 @@
"StrategyUpdate": "ポリシーを更新します",
"StrategyDetail": "戦略の詳細です",
"Rule": "ルール",
"RuleRelation": "条件関係です",
"RuleRelationHelpTips": "且つ: すべての条件が満たされて初めて動作が実行されます; もしくは: 動作が実行されるという条件が満たされます",
"RuleCount": "条件数です",
"ActionCount": "アクション数",
"PolicyName": "ポリシーの名前です",
@@ -898,6 +900,7 @@
"Regex": "正規表現",
"AttrValue": "属性値",
"Contains": "含む",
"Exclude": "含まない",
"Match": "一致する",
"Spec": "指定する",
"All": "すべて",
@@ -2217,7 +2220,8 @@
"SCP": "SCP",
"ApsaraStack": "Apsara Stack",
"HostnameStrategy": "資産を生成するためにホスト名。例: 1. インスタンス名 (instanceDemo) 2.インスタンス名と一部IP (下位2桁) (instanceDemo-250.1)",
"IsAlwaysUpdate": "資産情報を最新の状態に保つ",
"IsAlwaysUpdate": "資産は常に最新です",
"FullySynchronous": "資産完全にシンクロします",
"AccountCreate": "アカウントの作成",
"AccountList": "アカウントリスト",
"AccountUpdate": "アカウントの更新",
@@ -2227,7 +2231,9 @@
"Provider": "クラウドサービス業者",
"Validity": "有効",
"SyncStrategy": "同調戦略です",
"IsAlwaysUpdateHelpTips": "同期タスク実行るたびに、ホスト名、IP、システムプラットフォーム、管理ユーザーなど、アセットの情報を同期更新しますか?",
"IsAlwaysUpdateHelpTips": "同期タスク実行されるたびに、アセットの情報が同期更新されるかどうかです。ホスト名、IP、システムプラットフォーム、ドメイン、ードなどの情報が含まれます",
"FullySynchronousHelpTips": "アセット条件が適合ポリシールールを満たさない場合、このようなアセットを同期させ続けるかどうかです",
"StrategyHelpTips": "プラットフォームのようなアセットの固有の属性がポリシーの優先順位に基づいて決定され、ノードのようなアセットの属性が複数構成されると、すべてのポリシーのアクションが実行されます",
"SyncInstanceTaskCreate": "同期タスクを作成します",
"SyncInstanceTaskList": "同期タスクリストです",
"SyncInstanceTaskDetail": "同期任務詳細です",

View File

@@ -512,6 +512,8 @@
"StrategyUpdate": "更新策略",
"StrategyDetail": "策略详情",
"Rule": "条件",
"RuleRelation": "条件关系",
"RuleRelationHelpTips": "且:当所有条件都满足时,才会执行动作;或:有一个条件满足,就会执行动作",
"RuleCount": "条件数量",
"ActionCount": "动作数量",
"PolicyName": "策略名称",
@@ -543,6 +545,7 @@
"NotEqual": "不等于",
"MatchIn": "在...中",
"Contains": "包含",
"Exclude": "不包含",
"Startswith": "以...开头",
"Endswith": "以...结尾",
"Regex": "正则表达式",
@@ -2148,7 +2151,8 @@
"SCP": "深信服云平台",
"ApsaraStack": "阿里云专有云",
"HostnameStrategy": "用于生成资产主机名。例如1. 实例名称 (instanceDemo)2. 实例名称和部分IP(后两位) (instanceDemo-250.1)",
"IsAlwaysUpdate": "资产信息保持最新",
"IsAlwaysUpdate": "资产保持最新",
"FullySynchronous": "资产完全同步",
"AccountCreate": "创建账户",
"AccountList": "云账号",
"AccountUpdate": "更新账户",
@@ -2158,7 +2162,9 @@
"Provider": "云服务商",
"Validity": "有效",
"SyncStrategy": "同步策略",
"IsAlwaysUpdateHelpTips": "每次执行同步任务时是否同步更新资产的信息包括主机名、IP、系统平台、管理用户",
"IsAlwaysUpdateHelpTips": "每次执行同步任务时是否同步更新资产的信息包括主机名、IP、系统平台、网域、节点等信息",
"FullySynchronousHelpTips": "当资产条件不满足匹配策略规则时,是否继续同步此类资产",
"StrategyHelpTips": "根据策略优先级确定资产的唯一属性(如平台),当资产属性(如节点)可配置多个的时候,所有策略的动作都会被执行",
"SyncInstanceTaskCreate": "创建同步任务",
"SyncInstanceTaskList": "同步任务列表",
"SyncInstanceTaskDetail": "同步任务详情",

View File

@@ -17,13 +17,18 @@ export default {
url: '/api/v1/xpack/cloud/strategies/',
fields: [
[this.$t('common.Basic'), ['name', 'priority']],
[this.$t('common.Strategy'), ['strategy_rules', 'strategy_actions']],
[this.$t('common.RuleSetting'), ['rule_relation', 'strategy_rules']],
[this.$t('common.ActionSetting'), ['strategy_actions']],
[this.$t('common.Other'), ['comment']]
],
fieldsMeta: {
name: {
rules: [RequiredChange, specialEmojiCheck]
},
rule_relation: {
label: this.$t('common.RuleRelation'),
helpTips: this.$t('common.RuleRelationHelpTips')
},
strategy_rules: {
component: RuleInput
},

View File

@@ -21,7 +21,7 @@ export default {
},
columns: [
'name', 'priority', 'strategy_rules',
'strategy_actions', 'actions', 'user_actions'
'strategy_actions', 'actions', 'rule_relation'
],
columnsMeta: {
name: {

View File

@@ -56,7 +56,8 @@ export default {
multiple: false,
clearable: false,
options: attrMatchOptions.filter((option) => {
if (strMatchValues.indexOf(option.value) !== -1 && option.value !== 'in') {
const matchValues = strMatchValues.concat('exclude')
if (matchValues.indexOf(option.value) !== -1 && option.value !== 'in') {
return option
}
})

View File

@@ -26,9 +26,9 @@ export default {
[this.$t('xpack.Cloud.CloudSource'), ['account', 'regions']],
[this.$t('xpack.Cloud.SaveSetting'), [
'hostname_strategy', 'ip_network_segment_group',
'sync_ip_type', 'is_always_update'
'sync_ip_type', 'is_always_update', 'fully_synchronous'
]],
[this.$t('common.Actions'), ['strategy']],
[this.$t('xpack.Cloud.SyncStrategy'), ['strategy']],
[this.$t('xpack.Timer'), ['is_periodic', 'crontab', 'interval']],
[this.$t('common.Other'), ['comment']]
],
@@ -56,13 +56,18 @@ export default {
},
hostname_strategy: {
rules: [rules.RequiredChange],
helpText: this.$t('xpack.Cloud.HostnameStrategy')
helpTips: this.$t('xpack.Cloud.HostnameStrategy')
},
is_always_update: {
type: 'switch',
label: this.$t('xpack.Cloud.IsAlwaysUpdate'),
helpTips: this.$t('xpack.Cloud.IsAlwaysUpdateHelpTips')
},
fully_synchronous: {
type: 'switch',
label: this.$t('xpack.Cloud.FullySynchronous'),
helpTips: this.$t('xpack.Cloud.FullySynchronousHelpTips')
},
regions: {
component: Select2,
el: {
@@ -101,7 +106,8 @@ export default {
},
strategy: {
label: this.$t('common.Strategy'),
component: SyncInstanceTaskStrategy
component: SyncInstanceTaskStrategy,
helpTips: this.$t('xpack.Cloud.StrategyHelpTips')
}
},
updateSuccessNextRoute: { name: 'CloudCenter' },

View File

@@ -27,7 +27,7 @@ export default {
props: {
value: {
type: Object,
default: () => ({ name: '', priority: 50, strategy_rules: [], strategy_actions: [] })
default: () => ({ name: '', priority: 50, rule_relation: 'and', strategy_rules: [], strategy_actions: [] })
},
tableConfig: {
type: Object,
@@ -39,10 +39,14 @@ export default {
object: this.getObject(),
fields: [
[this.$t('common.BasicSetting'), ['name', 'priority']],
[this.$t('common.RuleSetting'), ['strategy_rules']],
[this.$t('common.RuleSetting'), ['rule_relation', 'strategy_rules']],
[this.$t('common.ActionSetting'), ['strategy_actions']]
],
fieldsMeta: {
rule_relation: {
label: this.$t('common.RuleRelation'),
helpTips: this.$t('common.RuleRelationHelpTips')
},
strategy_rules: {
label: this.$t('common.Rule'),
component: RuleInput
@@ -77,7 +81,8 @@ export default {
if (this.value?.id) {
return {
id: this.value.id, name: this.value.name, priority: this.value.priority,
strategy_rules: this.value.strategy_rules, strategy_actions: this.value.strategy_actions
strategy_rules: this.value.strategy_rules, strategy_actions: this.value.strategy_actions,
rule_relation: this.value.rule_relation
}
}
return {}