onapsdk.utils package¶
Submodules¶
onapsdk.utils.configuration module¶
Configuration package.
-
onapsdk.utils.configuration.
components_needing_distribution
()¶ Return the list of components needing distribution.
onapsdk.utils.headers_creator module¶
Header creator package.
-
onapsdk.utils.headers_creator.
headers_aai_creator
(base_header)¶ Create the right headers for AAI creator type.
-
onapsdk.utils.headers_creator.
headers_clamp_creator
(base_header)¶ Create the right headers for CLAMP generic type.
base_header (Dict[str, str]): the base header to use data (str): payload data used to create an md5 content header
-
onapsdk.utils.headers_creator.
headers_msb_creator
(base_header)¶ Create the right headers for MSB.
-
onapsdk.utils.headers_creator.
headers_sdc_artifact_upload
(base_header, data)¶ Create the right headers for sdc artifact upload.
-
onapsdk.utils.headers_creator.
headers_sdc_creator
(base_header, user='cs0008', authorization=None)¶ Create the right headers for SDC creator type.
-
onapsdk.utils.headers_creator.
headers_sdc_generic
(base_header, user, authorization=None)¶ Create the right headers for SDC generic type.
-
onapsdk.utils.headers_creator.
headers_sdc_governor
(base_header, user='gv0001', authorization=None)¶ Create the right headers for SDC governor type.
-
onapsdk.utils.headers_creator.
headers_sdc_operator
(base_header, user='op0001', authorization=None)¶ Create the right headers for SDC operator type.
-
onapsdk.utils.headers_creator.
headers_sdc_tester
(base_header, user='jm0007', authorization=None)¶ Create the right headers for SDC tester type.
-
onapsdk.utils.headers_creator.
headers_sdnc_creator
(base_header)¶ Create the right headers for SDNC.
-
onapsdk.utils.headers_creator.
headers_so_catelog_db_creator
(base_header)¶ Create the right headers for SO creator type.
onapsdk.utils.jinja module¶
Jinja module.
-
onapsdk.utils.jinja.
jinja_env
()¶ Create Jinja environment.
jinja_env allow to fetch simply jinja templates where they are. by default jinja engine will look for templates in templates directory of the package. So to load a template, you just have to do:
Example: >>> template = jinja_env().get_template(‘vendor_create.json.j2’) >>> data = template.render(name=”vendor”)
See also
SdcElement.create() for real use
- Returns
the Jinja environment to use
- Return type
Environment
onapsdk.utils.mixins module¶
Mixins module.
-
class
onapsdk.utils.mixins.
WaitForFinishMixin
¶ Bases:
abc.ABC
Wait for finish mixin.
- Mixin with wait_for_finish method and two properties:
completed,
finished.
Can be used to wait for result of asynchronous tasks.
-
WAIT_FOR_SLEEP_TIME
= 10¶
-
abstract property
completed
¶ Store an information if object task is completed or not.
- Returns
True if object task is completed, False otherwise.
- Return type
-
abstract property
finished
¶ Store an information if object task is finished or not.
- Returns
True if object task is finished, False otherwise.
- Return type
-
wait_for_finish
(timeout=None)¶ Wait until object task is finished.
- It uses time.sleep with WAIT_FOR_SLEEP_TIME value as a parameter to
wait unitl request is finished (object’s finished property is equal to True).
- It runs another process to control time of the function. If process timed out
TimeoutError is going to be raised.
- Parameters
timeout (float, optional) – positive number, wait at most timeout seconds
- Raises
TimeoutError – Raised when function timed out
- Returns
True if object’s task is successfully completed, False otherwise
- Return type
onapsdk.utils.tosca_file_handler module¶
Utils class.
-
onapsdk.utils.tosca_file_handler.
get_modules_list_from_tosca_file
(model)¶ Get the list of modules from tosca file.
Modules are stored on topology_template.groups TOSCA file section.
-
onapsdk.utils.tosca_file_handler.
get_parameter_from_yaml
(parameter, config_file)¶ Get the value of a given parameter in file.yaml.
Parameter must be given in string format with dots Example: general.openstack.image_name
- Parameters
- Raises
ParameterError – parameter not defined
- Returns
the value of the parameter
-
onapsdk.utils.tosca_file_handler.
get_vf_list_from_tosca_file
(model)¶ Get the list of Vfs of a VNF based on the tosca file.
-
onapsdk.utils.tosca_file_handler.
random_string_generator
(size=6, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')¶ Get a random String for VNF.
Module contents¶
ONAP SDK utils package.
-
onapsdk.utils.
get_zulu_time_isoformat
()¶ Get zulu time in accepted by ONAP modules format.
- Returns
Actual Zulu time.
- Return type