forked from TrueCloudLab/frostfs-node
[#976] adm: Allow to remove all chains by target
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
11fde3cde4
commit
bf70d77844
2 changed files with 18 additions and 7 deletions
|
@ -36,4 +36,5 @@ const (
|
||||||
HomomorphicHashDisabledInitFlag = "network.homomorphic_hash_disabled"
|
HomomorphicHashDisabledInitFlag = "network.homomorphic_hash_disabled"
|
||||||
CustomZoneFlag = "domain"
|
CustomZoneFlag = "domain"
|
||||||
AlphabetSizeFlag = "size"
|
AlphabetSizeFlag = "size"
|
||||||
|
AllFlag = "all"
|
||||||
)
|
)
|
||||||
|
|
|
@ -114,8 +114,9 @@ func initRemoveRuleChainCmd() {
|
||||||
removeRuleChainCmd.Flags().String(targetNameFlag, "", targetNameDesc)
|
removeRuleChainCmd.Flags().String(targetNameFlag, "", targetNameDesc)
|
||||||
_ = removeRuleChainCmd.MarkFlagRequired(targetNameFlag)
|
_ = removeRuleChainCmd.MarkFlagRequired(targetNameFlag)
|
||||||
removeRuleChainCmd.Flags().String(chainIDFlag, "", chainIDDesc)
|
removeRuleChainCmd.Flags().String(chainIDFlag, "", chainIDDesc)
|
||||||
_ = removeRuleChainCmd.MarkFlagRequired(chainIDFlag)
|
|
||||||
removeRuleChainCmd.Flags().String(chainNameFlag, ingress, chainNameFlagDesc)
|
removeRuleChainCmd.Flags().String(chainNameFlag, ingress, chainNameFlagDesc)
|
||||||
|
removeRuleChainCmd.Flags().Bool(commonflags.AllFlag, false, "Remove all chains for target")
|
||||||
|
removeRuleChainCmd.MarkFlagsMutuallyExclusive(commonflags.AllFlag, chainIDFlag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initListRuleChainsCmd() {
|
func initListRuleChainsCmd() {
|
||||||
|
@ -157,14 +158,23 @@ func addRuleChain(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeRuleChain(cmd *cobra.Command, _ []string) {
|
func removeRuleChain(cmd *cobra.Command, _ []string) {
|
||||||
chainID := parseChainID(cmd)
|
|
||||||
target := parseTarget(cmd)
|
target := parseTarget(cmd)
|
||||||
pci, ac := newPolicyContractInterface(cmd)
|
pci, ac := newPolicyContractInterface(cmd)
|
||||||
h, vub, err := pci.RemoveMorphRuleChain(parseChainName(cmd), target, chainID)
|
removeAll, _ := cmd.Flags().GetBool(commonflags.AllFlag)
|
||||||
cmd.Println("Waiting for transaction to persist...")
|
if removeAll {
|
||||||
_, err = ac.Wait(h, vub, err)
|
h, vub, err := pci.RemoveMorphRuleChainsByTarget(parseChainName(cmd), target)
|
||||||
commonCmd.ExitOnErr(cmd, "remove rule chain error: %w", err)
|
cmd.Println("Waiting for transaction to persist...")
|
||||||
cmd.Println("Rule chain removed successfully")
|
_, err = ac.Wait(h, vub, err)
|
||||||
|
commonCmd.ExitOnErr(cmd, "remove rule chain error: %w", err)
|
||||||
|
cmd.Println("All chains for target removed successfully")
|
||||||
|
} else {
|
||||||
|
chainID := parseChainID(cmd)
|
||||||
|
h, vub, err := pci.RemoveMorphRuleChain(parseChainName(cmd), target, chainID)
|
||||||
|
cmd.Println("Waiting for transaction to persist...")
|
||||||
|
_, err = ac.Wait(h, vub, err)
|
||||||
|
commonCmd.ExitOnErr(cmd, "remove rule chain error: %w", err)
|
||||||
|
cmd.Println("Rule chain removed successfully")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func listRuleChains(cmd *cobra.Command, _ []string) {
|
func listRuleChains(cmd *cobra.Command, _ []string) {
|
||||||
|
|
Loading…
Reference in a new issue