-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f822ddc
commit 5878ffa
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/Charlie-Root/smcli/host" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// Parent ACL command (no direct functionality) | ||
var AclCmd = &cobra.Command{ | ||
Use: "acl", | ||
Short: "Manage ACL settings", | ||
} | ||
|
||
// Subcommand to enable ACL on the host | ||
var EnableAclCmd = &cobra.Command{ | ||
Use: "enable <host>", | ||
Short: "Enable ACL on the specified host", | ||
Args: cobra.ExactArgs(1), // Expect exactly one argument for the host | ||
Run: func(cmd *cobra.Command, args []string) { | ||
hostName := args[0] | ||
host.SelectHost(hostName) | ||
host.ServerEnableACL() // Call to enable ACL on the host | ||
}, | ||
} | ||
|
||
// Subcommand to add an ACL entry | ||
var AddAclCmd = &cobra.Command{ | ||
Use: "add <address> <prefix> <policy> <host>", | ||
Short: "Add new ACL entry", | ||
Args: cobra.ExactArgs(4), // Expect address, prefix, policy, and host as arguments | ||
Run: func(cmd *cobra.Command, args []string) { | ||
address := args[0] | ||
prefix := args[1] | ||
policy := args[2] | ||
hostName := args[3] | ||
|
||
host.SelectHost(hostName) | ||
host.ServerCreateACL(address, prefix, policy) // Call to add ACL entry | ||
}, | ||
} | ||
|
||
func init() { | ||
// Register subcommands under the acl command | ||
AclCmd.AddCommand(EnableAclCmd) | ||
AclCmd.AddCommand(AddAclCmd) | ||
|
||
// Register acl command to the root command (assuming RootCmd is the root cobra command) | ||
RootCmd.AddCommand(AclCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters