Skip to content

Commit

Permalink
Merge pull request #956 from xxwjj/replication_cli
Browse files Browse the repository at this point in the history
change the replication cli format
  • Loading branch information
leonwanghui committed Jul 10, 2019
2 parents cbb8e25 + 7fb3192 commit 27e7a9a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
1 change: 0 additions & 1 deletion osdsctl/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func init() {
rootCommand.AddCommand(dockCommand)
rootCommand.AddCommand(poolCommand)
rootCommand.AddCommand(profileCommand)
rootCommand.AddCommand(replicationCommand)
rootCommand.AddCommand(fileShareCommand)
flags := rootCommand.PersistentFlags()
flags.BoolVar(&Debug, "debug", false, "shows debugging output.")
Expand Down
6 changes: 3 additions & 3 deletions osdsctl/cli/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ func init() {
flags := replicationCreateCommand.Flags()
flags.StringVarP(&replicationName, "name", "n", "", "the name of created replication")
flags.StringVarP(&replicationDesp, "description", "d", "", "the description of created replication")
flags.StringVarP(&primaryReplicationDriverData, "primary_driver_data", "p", "", "the primary replication driver data of created replication")
flags.StringVarP(&secondaryReplicationDriverData, "secondary_driver_data", "s", "", "the secondary replication driver data of created replication")
flags.StringVarP(&primaryReplicationDriverData, "primary_driver_data", "", "", "the primary replication driver data of created replication")
flags.StringVarP(&secondaryReplicationDriverData, "secondary_driver_data", "", "", "the secondary replication driver data of created replication")
flags.StringVarP(&replicationMode, "replication_mode", "m", model.ReplicationModeSync, "the replication mode of created replication, value can be sync/async")
flags.Int64VarP(&replicationPeriod, "replication_period", "t", 0, "the replication period(minute) of created replication, the value must greater than 0, only in sync replication mode should set this value (default 60)")
replicationUpdateCommand.Flags().StringVarP(&replicationName, "name", "n", "", "the name of updated replication")
replicationUpdateCommand.Flags().StringVarP(&replicationDesp, "description", "d", "", "the description of updated replication")
// TODO: Add some other update items, such as status, replicatoin_period ... etc.
// TODO: Add some other update items, such as status, replication_period ... etc.
replicationFailoverCommand.Flags().BoolVarP(&allowAttachedVolume, "allow_attached_volume", "a", false, "whether allow attached volume when failing over replication")
replicationFailoverCommand.Flags().StringVarP(&secondaryBackendId, "secondary_backend_id", "s", model.ReplicationDefaultBackendId, "the secondary backend id of failoverr replication")
replicationCommand.AddCommand(replicationShowCommand)
Expand Down
1 change: 1 addition & 0 deletions osdsctl/cli/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func init() {
volumeCommand.AddCommand(volumeSnapshotCommand)
volumeCommand.AddCommand(volumeAttachmentCommand)
volumeCommand.AddCommand(volumeGroupCommand)
volumeCommand.AddCommand(replicationCommand)
}

func volumeAction(cmd *cobra.Command, args []string) {
Expand Down
47 changes: 25 additions & 22 deletions osdsctl/completion/osdsctl.bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,40 @@ _osdsctl() {
local cur=${COMP_WORDS[COMP_CWORD]};
local pre=${COMP_WORDS[COMP_CWORD-1]};
case "$COMP_CWORD $pre" in
'1 osdsctl')
COMPREPLY=($(compgen -W 'dock pool profile version volume replication fileshare' -- $cur)) ;;
'2 dock')
"1 osdsctl")
COMPREPLY=($(compgen -W 'dock pool profile version volume fileshare' -- $cur)) ;;
"2 dock")
COMPREPLY=($(compgen -W 'list show' -- $cur)) ;;
'2 pool')
"2 pool")
COMPREPLY=($(compgen -W 'list show' -- $cur)) ;;
'2 profile')
"2 profile")
COMPREPLY=($(compgen -W 'create delete list show' -- $cur)) ;;
'2 version')
"2 version")
COMPREPLY=($(compgen -W 'list show' -- $cur)) ;;
'2 volume')
COMPREPLY=($(compgen -W 'attachment create delete list show extend snapshot update group' -- $cur)) ;;
'2 replication')
COMPREPLY=($(compgen -W 'create delete list show update enable disable failover' -- $cur)) ;;
'3 snapshot')
COMPREPLY=($(compgen -W 'create delete list show update' -- $cur)) ;;
'3 attachment')
COMPREPLY=($(compgen -W 'create delete list show update' -- $cur)) ;;
'3 group')
COMPREPLY=($(compgen -W 'create delete list show update' -- $cur)) ;;
'2 fileshare')
"2 volume")
COMPREPLY=($(compgen -W 'attachment create delete list show extend snapshot update group replication' -- $cur)) ;;
"2 fileshare")
COMPREPLY=($(compgen -W 'create delete list show acl snapshot' -- $cur)) ;;
'3 acl')
COMPREPLY=($(compgen -W 'create delete list show' -- $cur)) ;;
'*')
;;
esac

[ $COMP_CWORD == 1 ] && {
COMPREPLY=($(compgen -W 'dock pool profile version volume replication fileshare' -- $cur))
}
# differentiate volume and fileshare
if [[ $COMP_CWORD == 3 ]]; then
local ppre=${COMP_WORDS[COMP_CWORD-2]};
case "$ppre $pre" in
"volume replication")
COMPREPLY=($(compgen -W 'create delete list show update enable disable failover' -- $cur)) ;;
"volume snapshot" | "fileshare snapshot")
COMPREPLY=($(compgen -W 'create delete list show update' -- $cur)) ;;
"volume attachment")
COMPREPLY=($(compgen -W 'create delete list show update' -- $cur)) ;;
"volume group")
COMPREPLY=($(compgen -W 'create delete list show update' -- $cur)) ;;
"fileshare acl")
COMPREPLY=($(compgen -W 'create delete list show' -- $cur)) ;;
esac
fi
return 0
}
complete -o bashdefault -o default -F _osdsctl osdsctl

0 comments on commit 27e7a9a

Please sign in to comment.