diff options
Diffstat (limited to 'docs/examples/e2e_artifact_upload.rst')
-rw-r--r-- | docs/examples/e2e_artifact_upload.rst | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/docs/examples/e2e_artifact_upload.rst b/docs/examples/e2e_artifact_upload.rst new file mode 100644 index 0000000..aea4d21 --- /dev/null +++ b/docs/examples/e2e_artifact_upload.rst @@ -0,0 +1,58 @@ +E2E Upload of an artifact +##################################### + + +.. code:: Python + + import os + import logging + + from onapsdk.sdc.vsp import Vsp + from onapsdk.sdc.vf import Vf + from onapsdk.sdc.service import Service + + logger = logging.getLogger("") + logger.setLevel(logging.INFO) + fh = logging.StreamHandler() + fh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + fh.setFormatter(fh_formatter) + logger.addHandler(fh) + + + + # Create required A&AI resources + VF_NAME = "my_VF" + SERVICENAME = "artifact_SERVICE" + + ARTIFACT_NAME = "clampnode" + ARTIFACT_TYPE = "DCAE_INVENTORY_BLUEPRINT" + ARTIFACT_FILE_PATH = "{os.path.dirname(os.path.abspath(__file__))}/my_ArtifactFile.yaml" + + + logger.info("*******************************") + logger.info("******** SERVICE DESIGN *******") + logger.info("*******************************") + + logger.info("******** Get VF *******") + vf = Vf(VF_NAME) + vf.onboard() + + logger.info("******** Create Service *******") + svc = Service(name=SERVICENAME) + svc.create() + svc.add_resource(vf) + + logger.info("******** Extract Artifact Data *******") + data = open(ARTIFACT_FILE_PATH,'rb').read() + + logger.info("******** Upload Artifact *******") + svc.add_artifact_to_vf(vnf_name=VF_NAME, + artifact_type=ARTIFACT_TYPE, + artifact_name=ARTIFACT_NAME, + artifact=data) + + logger.info("******** Distribute Service *******") + svc.checkin() + svc.certify() + svc.distribute() + |