Skip to content

Commit 18eefd2

Browse files
[JIRA SONIC-61743] Use usb:/ as help string for dir, ls and delete command
- Mention usb:/ in the help text but allow the user to enter usb1:/ as well. In majority of the cases users will be using usb:/ and having that in the help text keeps it uniform compared to the other available options. Change-Id: I4576c5f671866e27595b6909ff786467007e4296
1 parent f123a8e commit 18eefd2

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

CLI/actioner/sonic_cli_file_mgmt.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ def get_user_pass(url):
103103

104104
return False, ""
105105

106+
def fixup_usb_path(input_filepath):
107+
res = re.search('usb:/(\d+):/*', input_filepath)
108+
if res:
109+
usb_dev = res.group(1)
110+
new_filepath = "usb{}:/{}".format(usb_dev, input_filepath[len(res.group(0)):])
111+
return new_filepath
112+
return input_filepath
113+
106114
def process_args(args):
107115
count = 0
108116
input_dict = {}
@@ -236,9 +244,11 @@ def handle_del(cmd, args, input_dict):
236244
print("%Error: Invalid input")
237245
return -1
238246

239-
msg = ("Proceed to delete " + args[0] + "?")
247+
filename = fixup_usb_path(input_dict.get("filename"))
248+
msg = ("Proceed to delete " + filename + "?")
240249
prpt = prompt(msg)
241250
if prpt == True:
251+
input_dict["filename"] = filename
242252
keypath, body = get_keypath(cmd,args, input_dict)
243253
try:
244254
api_response = api_client.post(keypath, body)
@@ -276,6 +286,8 @@ def handle_dir(args,input_dict):
276286
print("%Error: Invalid input")
277287
return -1
278288

289+
folder_name = fixup_usb_path(input_dict.get("folder-name"))
290+
input_dict["folder-name"] = folder_name
279291
keypath, body = get_keypath('dir', args, input_dict)
280292
try:
281293
api_response = api_client.post(keypath, body)

CLI/clitree/cli-xml/sonic_types.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,8 +1923,8 @@ limitations under the License.
19231923
<PTYPE
19241924
name="FOLDER_NAME"
19251925
method="regexp_select"
1926-
ext_pattern="config:/ coredump:/ event-profile:/ home:/ log:/ tech-support:/ usb"
1927-
ext_help="(Folder containing config files) (Folder containing core dump files) (Folder containing event-profile files) (Home folder of the user) (Folder containing log files) (Folder containing the tech support files) (Folder containing usb media files - usb:/)"
1926+
ext_pattern="config:/ coredump:/ event-profile:/ home:/ log:/ tech-support:/ usb:/"
1927+
ext_help="(Folder containing config files) (Folder containing core dump files) (Folder containing event-profile files) (Home folder of the user) (Folder containing log files) (Folder containing the tech support files) (Folder containing usb media files)"
19281928
pattern="^(config|coredump|event-profile|home|log|tech-support|usb[0-7]?):/[ a-zA-Z_0-9\\/.+-]{0,256}"
19291929
help="Folder names"
19301930
/>
@@ -1933,7 +1933,7 @@ limitations under the License.
19331933
<PTYPE
19341934
name="DELETE_FOLDER_NAME"
19351935
method="regexp_select"
1936-
ext_pattern="config:/ coredump:/ event-profile:/ home:/ tech-support:/ usb"
1936+
ext_pattern="config:/ coredump:/ event-profile:/ home:/ tech-support:/ usb:/"
19371937
ext_help="(Delete from &CONFIG_URL;) (Delete from &CORE_URL;) (Delete from &EVENT_PROF_URL;) (Delete from &HOME_URL;) (Delete from &SUPPORT_URL;) (Delete from &USB_URL;)"
19381938
pattern="^(config|coredump|event-profile|home|tech-support|usb[0-7]?):/[a-zA-Z_0-9\\/.+-]{1,256}"
19391939
help="File to be deleted"

0 commit comments

Comments
 (0)