Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add script to upload packages to web server #1

Closed
wants to merge 3 commits into from

Conversation

orenreiss
Copy link
Owner

@orenreiss orenreiss commented Dec 20, 2022

Signed-off-by: oreiss oreiss@nvidia.com

Why I did it

The flow of SONiC reproducible build assumes that web packages (retrieved by curl and wget) are located in a single web file.
server. Currently there is no way to easily download the packages from the various file servers where they are currently deployed.
In this change we offer a utility to download all relevant packages and upload them to a specific file server.

How I did it

We implemented python script that parse the various version files (generated by SONIC reproducible build compilation) and identify all relevant packages.
Later the script downloads the file and then upload them to the destination server pointed by the user.

How to verify it

Script was verified manually

Which release branch to backport (provide reason below if selected)

Feature will be added to master only

Description for the changelog

URL to be added

Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.

Link to config_db schema for YANG module changes

no changes in DB or object module

A picture of a cute animal (not mandatory but encouraged)

:)

Signed-off-by: oreiss <oreiss@nvidia.com>
if PRINT_LEVEL_LUT[g_current_print_level] >= PRINT_LEVEL_LUT[PRINT_LEVEL_INFO]:
print(msg)

def info_print_in_place(msg):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use info_print with an additional optional parameter rather than writing a new function?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I will change it accordingly

if PRINT_LEVEL_LUT[g_current_print_level] >= PRINT_LEVEL_LUT[PRINT_LEVEL_WARN]:
print(msg)

def error_print(msg):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have one API to encapsulate the logging logic and then list of APIs which call based on level? Example below. In this way in future if we want to extend how we log we can just modify in one place
def log(level, msg):
if PRINT_LEVEL_LUT[g_current_print_level] >= PRINT_LEVEL_LUT[level]:
print(msg)
def error_print(msg):
log(PRINT_LEVEL_ERROR, mst)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I will change it accordingly


for subdir, dirs, files in os.walk(serach_path):
for file in files:
if False == filter_out_dir(subdir) and RESOURCES_FILE_NAME == file:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are the version-web files going to be maintained? Will it be populated manually? Can you please provide some insights?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version-web are generated as part of the flow of first "SONiC reproducible build". Later they are being used on any compilation. The script is only parsing the existing files in the specified path

@@ -1,3 +1,5 @@
#!/usr/bin/python3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#!/usr/bin/env python3

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def verbose_print(msg):
if PRINT_LEVEL_LUT[g_current_print_level] >= PRINT_LEVEL_LUT[PRINT_LEVEL_VERBOSE]:
print(msg)
def print_msg(print_level, msg, print_in_place):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can have default value for print_in_place=False. In the invocations below other than when it needs to be true, you can ignore this parameter.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def create_dir_if_not_exist(dir):
if not os.path.exists(dir):
try:
os.mkdir(dir)
except:
warn_print("Cannot create directory " + dir)
print_msg(PRINT_LEVEL_WARN, "Cannot create directory " + dir, False)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove False after setting the default value. Applies to other changes below

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dgsudharsan
Copy link

@orenreiss The changes look good. However I wanted to understand how possible is it to add UT to the changes?

@orenreiss orenreiss closed this Jan 24, 2023
@orenreiss
Copy link
Owner Author

Internal PR was approved. CI passed. Now raising external PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants