def test_get_projects(self, tmpdir): """Verify that we can retrieve projects.""" p = tmpdir.mkdir('test') path = str(p) repo = Repo.init(path) file = p / 'test1.yml' file.write_text(u"""--- tempest_git_repo: https://git.openstack.org/openstack/tempest tempest_git_install_branch: 1493c7f0ba49bfccb9ff8516b10a65d949d7462e tempest_git_project_group: utility_all """, encoding='utf-8') file = p / 'test2.yml' file.write_text(u"""--- novncproxy_git_repo: https://github.com/kanaka/novnc novncproxy_git_install_branch: da82b3426c27bf1a79f671c5825d68ab8c0c5d9f novncproxy_git_project_group: nova_console """, encoding='utf-8') repo.index.add(['test1.yml', 'test2.yml']) repo.index.commit("Test") projects = osa_differ.get_projects(path, 'HEAD') assert isinstance(projects, list)
def run_rpc_differ(): """The script starts here.""" args = parse_arguments() # Create the storage directory if it doesn't exist already. try: storage_directory = osa_differ.prepare_storage_dir(args.directory) except OSError: print("ERROR: Couldn't create the storage directory {0}. " "Please create it manually.".format(args.directory)) sys.exit(1) # Assemble some variables for the RPC repository. rpc_old_commit = args.old_commit[0] rpc_new_commit = args.new_commit[0] rpc_repo_dir = "{0}/rpc-openstack".format(storage_directory) # Generate RPC report header. report_rst = make_rpc_report(rpc_repo_dir, rpc_old_commit, rpc_new_commit, args) # Get the list of RPC roles from the newer and older commits. role_yaml = osa_differ.get_roles(rpc_repo_dir, rpc_old_commit) role_yaml_latest = osa_differ.get_roles(rpc_repo_dir, rpc_new_commit) # Generate the role report. report_rst += ("RPC-OpenStack Roles\n" "-------------------") report_rst += osa_differ.make_report(storage_directory, role_yaml, role_yaml_latest, args.update) report_rst += "\n" # Generate OpenStack-Ansible report. osa_old_commit, osa_new_commit = get_osa_commits(rpc_repo_dir, rpc_old_commit, rpc_new_commit) osa_repo_dir = "{0}/openstack-ansible".format(storage_directory) report_rst += osa_differ.make_osa_report(osa_repo_dir, osa_old_commit, osa_new_commit, args) # Get the list of OpenStack-Ansible roles from the newer and older commits. role_yaml = osa_differ.get_roles(osa_repo_dir, osa_old_commit) role_yaml_latest = osa_differ.get_roles(osa_repo_dir, osa_new_commit) # Generate the role report. report_rst += ("OpenStack-Ansible Roles\n" "-----------------------") report_rst += osa_differ.make_report(storage_directory, role_yaml, role_yaml_latest, args.update) # Get the list of OpenStack projects from newer commit and older commit. yaml_files = [ 'playbooks/defaults/repo_packages/openstack_services.yml', 'playbooks/defaults/repo_packages/openstack_other.yml' ] project_yaml = osa_differ.get_projects(osa_repo_dir, yaml_files, osa_old_commit) project_yaml_latest = osa_differ.get_projects(osa_repo_dir, yaml_files, osa_new_commit) # Generate the project report. report_rst += ("OpenStack-Ansible Projects\n" "--------------------------") report_rst += osa_differ.make_report(storage_directory, project_yaml, project_yaml_latest, args.update) # Publish report according to the user's request. output = publish_report(report_rst, args, rpc_old_commit, rpc_new_commit) print(output)
def run_rpc_differ(): """The script starts here.""" args = parse_arguments() # Set up DEBUG logging if needed if args.debug: log.setLevel(logging.DEBUG) elif args.verbose: log.setLevel(logging.INFO) # Create the storage directory if it doesn't exist already. try: storage_directory = osa_differ.prepare_storage_dir(args.directory) except OSError: print("ERROR: Couldn't create the storage directory {0}. " "Please create it manually.".format(args.directory)) sys.exit(1) # Assemble some variables for the RPC repository. rpc_old_commit = args.old_commit[0] rpc_new_commit = args.new_commit[0] rpc_repo_dir = "{0}/rpc-openstack".format(storage_directory) # Generate RPC report header. report_rst = make_rpc_report(rpc_repo_dir, rpc_old_commit, rpc_new_commit, args) # Get the list of RPC roles from the newer and older commits. role_yaml = osa_differ.get_roles(rpc_repo_dir, rpc_old_commit) role_yaml_latest = osa_differ.get_roles(rpc_repo_dir, rpc_new_commit) # Generate the role report. report_rst += ("\nRPC-OpenStack Roles\n" "-------------------") report_rst += osa_differ.make_report(storage_directory, role_yaml, role_yaml_latest, args.update) report_rst += "\n" # Generate OpenStack-Ansible report. repo = Repo(rpc_repo_dir) osa_old_commit = get_osa_commit(repo, rpc_old_commit) osa_new_commit = get_osa_commit(repo, rpc_new_commit) log.debug("OSA Commits old:{old} new:{new}".format(old=osa_old_commit, new=osa_new_commit)) osa_repo_dir = "{0}/openstack-ansible".format(storage_directory) # NOTE: # An exception is thrown by osa_differ if these two commits # are the the same, but it is sometimes necessary to compare # two RPC tags that have the same OSA SHA. For example, # comparing two tags that only have differences between the # two RPCO commit, but no differences between the OSA SHAs # that correspond to those two commits. # To handle this case, the exception will be caught and flow # of execution will continue normally. try: report_rst += osa_differ.make_osa_report(osa_repo_dir, osa_old_commit, osa_new_commit, args) except exceptions.InvalidCommitRangeException: pass # Get the list of OpenStack-Ansible roles from the newer and older commits. role_yaml = osa_differ.get_roles(osa_repo_dir, osa_old_commit) role_yaml_latest = osa_differ.get_roles(osa_repo_dir, osa_new_commit) # Generate the role report. report_rst += ("\nOpenStack-Ansible Roles\n" "-----------------------") report_rst += osa_differ.make_report(storage_directory, role_yaml, role_yaml_latest, args.update) project_yaml = osa_differ.get_projects(osa_repo_dir, osa_old_commit) project_yaml_latest = osa_differ.get_projects(osa_repo_dir, osa_new_commit) # Generate the project report. report_rst += ("OpenStack-Ansible Projects\n" "--------------------------") report_rst += osa_differ.make_report(storage_directory, project_yaml, project_yaml_latest, args.update) # Publish report according to the user's request. output = publish_report(report_rst, args, rpc_old_commit, rpc_new_commit) print(output)