-
Notifications
You must be signed in to change notification settings - Fork 128
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
fixed local-repo rerun defect #2508
Draft
Nagachandan-P
wants to merge
2
commits into
dell:pub/new_architecture
Choose a base branch
from
Nagachandan-P:pub/new_architecture
base: pub/new_architecture
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
#!/usr/bin/python | ||
from ansible.module_utils.basic import AnsibleModule | ||
from ansible.module_utils.standard_logger import setup_standard_logger | ||
|
@@ -20,6 +20,7 @@ | |
get_software_names, | ||
check_csv_existence, | ||
get_failed_software, | ||
get_csv_software, | ||
process_software, | ||
load_json, | ||
load_yaml, | ||
|
@@ -34,16 +35,16 @@ | |
import json | ||
import os | ||
import re | ||
|
||
def main(): | ||
""" | ||
The main function that prepares package lists and processes software. | ||
|
||
This function initializes the module arguments and sets up the logger. | ||
It loads the user data from a JSON file and the repository configuration | ||
data from a YAML file. It retrieves the cluster OS type and version, and | ||
the list of software names. It also sets up the version variables. | ||
|
||
The function then prepares the package lists and processes the software. | ||
For each software, it checks if it needs a fresh installation. If not, | ||
it skips the software. For each software, it retrieves the JSON and CSV | ||
|
@@ -52,91 +53,111 @@ def main(): | |
and skips it if necessary. It processes the software and stores the tasks | ||
in the software dictionary. Finally, it transforms the package dictionary | ||
and parses the repository URLs. | ||
|
||
Parameters: | ||
None | ||
|
||
Returns: | ||
None | ||
|
||
Raises: | ||
Exception: If an error occurs during the processing. | ||
|
||
""" | ||
module_args = dict( | ||
csv_file_path=dict(type="str", required=False, default="/tmp/status_results_table.csv"), | ||
user_json_file=dict(type="str", required=False, default=""), | ||
local_repo_config_path=dict(type="str", required=False, default=""), | ||
log_dir=dict(type="str", required=False, default="/tmp/thread_logs"), | ||
) | ||
|
||
module = AnsibleModule(argument_spec=module_args) | ||
|
||
# versions = module.params['versions'] | ||
log_dir = module.params["log_dir"] | ||
user_json_file = module.params['user_json_file'] | ||
local_repo_config_path = module.params['local_repo_config_path'] | ||
csv_file_path = module.params['csv_file_path'] | ||
|
||
logger = setup_standard_logger(log_dir) | ||
start_time = datetime.now().strftime("%I:%M:%S %p") | ||
logger.info(f"Start execution time: {start_time}") | ||
|
||
try: | ||
user_data = load_json(user_json_file) | ||
repo_config_data = load_yaml(local_repo_config_path) | ||
|
||
cluster_os_type = user_data['cluster_os_type'] | ||
cluster_os_version = user_data['cluster_os_version'] | ||
|
||
|
||
csv_file_path = os.path.join(csv_file_path, "software.csv") | ||
|
||
software_list = get_software_names(user_json_file) | ||
|
||
logger.info(f"software_list from software_config: {software_list}") | ||
|
||
fresh_installation = 1 if not check_csv_existence(csv_file_path) else 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. user True or False. move this to seperate file |
||
logger.info(f"Fresh install: {fresh_installation}") | ||
|
||
csv_softwares = [] | ||
if not fresh_installation: | ||
csv_softwares = get_csv_software(csv_file_path) | ||
logger.info(f"software from software.csv: {csv_softwares}") | ||
new_software = [software for software in software_list if software not in csv_softwares] | ||
logger.info(f"new software list : {new_software}") | ||
logger.info(f"Final software_list: {software_list}") | ||
# Build a dictionary of software_name -> subgroup_list if exists | ||
|
||
subgroup_dict , software_names = get_subgroup_dict(user_data) | ||
|
||
version_variables = set_version_variables(user_data, software_names, cluster_os_version) | ||
software_dict = {} | ||
|
||
logger.info("Preparing package lists...") | ||
|
||
#csv_file_path = os.path.join(csv_file_path, "software.csv") | ||
for software in software_list: | ||
logger.info(f"Processing software: {software}") | ||
fresh_installation = 1 if not check_csv_existence(software, csv_file_path) else 0 | ||
|
||
logger.info(f"csv_file_path software: {csv_file_path}") | ||
#fresh_installation = 1 if not check_csv_existence(software, csv_file_path) else 0 | ||
|
||
json_path = get_json_file_path(software, cluster_os_type, cluster_os_version, user_json_file) | ||
csv_path = get_csv_file_path(software, log_dir) | ||
logger.info(f"csv_path: {csv_path}") | ||
|
||
if not json_path: | ||
logger.warning(f"Skipping {software}: JSON path does not exist.") | ||
continue | ||
|
||
|
||
if software in new_software: | ||
fresh_installation = 1 | ||
|
||
logger.info(f"{software}: JSON Path: {json_path}, CSV Path: {csv_path}, Fresh Install: {fresh_installation}") | ||
logger.info(f"Subgroup Data: {subgroup_dict.get(software, None)}") | ||
logger.info(f"Whole Subgroup Data: {subgroup_dict}") | ||
|
||
failed_softwares = get_failed_software(csv_file_path) | ||
logger.info(f"failed_softwares : {failed_softwares}") | ||
if not fresh_installation and software not in failed_softwares: | ||
continue | ||
# Ensure we pass None for subgroup_list when not present | ||
logger.info(f"json_path: {json_path}") | ||
logger.info(f"csv_path: {csv_path}") | ||
tasks = process_software(software, fresh_installation, json_path, csv_path, subgroup_dict.get(software, None)) | ||
tasks ,failed_packages = process_software(software, fresh_installation, json_path, csv_path, subgroup_dict.get(software, None)) | ||
logger.info(f"tasks: {tasks}") | ||
|
||
logger.info(f"failed_packages for software:{software} are {failed_packages}") | ||
failed_packages = get_failed_software(csv_path) | ||
logger.info(f"failed_packages: {failed_packages}") | ||
|
||
software_dict[software] = tasks | ||
|
||
software_dict=transform_package_dict(software_dict) | ||
local_config = parse_repo_urls(local_repo_config_path , version_variables) | ||
|
||
module.exit_json(changed=False, software_dict=software_dict , local_config=local_config) | ||
logger.info(f"Package processing completed: {software_dict}") | ||
|
||
except Exception as e: | ||
logger.error(f"Error occurred: {str(e)}") | ||
module.fail_json(msg=str(e)) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move all the file paths to separate file