2 # org.onap.vnfrqts/requirements
3 # ============LICENSE_START====================================================
4 # Copyright © 2018 AT&T Intellectual Property. All rights reserved.
6 # Unless otherwise specified, all software contained herein is licensed
7 # under the Apache License, Version 2.0 (the "License");
8 # you may not use this software except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
19 # Unless otherwise specified, all documentation contained herein is licensed
20 # under the Creative Commons License, Attribution 4.0 Intl. (the "License");
21 # you may not use this documentation except in compliance with the License.
22 # You may obtain a copy of the License at
24 # https://creativecommons.org/licenses/by/4.0/
26 # Unless required by applicable law or agreed to in writing, documentation
27 # distributed under the License is distributed on an "AS IS" BASIS,
28 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29 # See the License for the specific language governing permissions and
30 # limitations under the License.
32 # ============LICENSE_END============================================
40 REQUIREMENTS_FILE = "https://nexus.onap.org/content/sites/raw/org.onap.vnfrqts.requirements/master/needs.json"
42 def get_current_requirements():
43 """Read the current ONAP requirements from ONAP doc site"""
45 r = requests.get(REQUIREMENTS_FILE)
46 if r.headers.get('content-type') == 'application/json':
48 return json.loads(data)
50 warnings.warning("Unexpected content-type ({}) encountered downloading requirements.json, using last saved copy".format(r.headers.get('content-type')))
51 except requests.exceptions.RequestException as e:
52 warnings.warn("Error downloading latest JSON, using last saved copy.")
53 warnings.warn(UserWarning(e))
57 data = get_current_requirements()
59 for version in data["versions"]:
60 result.update(data["versions"][version]["needs"].keys())
64 """Generates a stream of unique requirement IDs"""
65 all_ids = load_all_ids()
67 new_id = "R-{:0>5d}".format(random.randint(0, 999999))
69 continue # skip this one and generate another one
74 if __name__ == "__main__":
75 parser = argparse.ArgumentParser(
77 Generate random, unique requirement IDs for use when adding new requirements
78 to the RST documentation.
81 parser.add_argument("num_ids", action="store", nargs="?", type=int, default=1,
82 help="Number of IDs to generate")
83 args = parser.parse_args()
84 for req_id in itertools.islice(generate_ids(), args.num_ids):