# Copyright (c) ETSI 2017.
# https://forge.etsi.org/etsi-forge-copyright-notice.txt

definitions:
  VnfSnapshotPkgInfo:
    description: >
      This type represents the information of a VNF snapshot package. It shall comply with the provisions defined in table 12.5.2.2-1.

      NOTE:	The attribute shall not be present before the VNF snapshot package content has been uploaded or built. Otherwise, this 
            attribute shall be present unless it has been requested to be excluded per attribute selector.
    type: object
    required:
    - id
    - name
    - isFullSnapshot
    - state
    - isCancelPending
    - _links
    properties:
      id:
        description: > 
          Identifier of the VNF snapshot packageinformation held by the NFVO. This identifier 
          is allocated by the NFVO.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Identifier"
      vnfSnapshotPkgUniqueId:
        description: > 
          Identifier of the VNF snapshot package, which identifies the VNF snapshot package in 
          a globally unique way. It is created during the "build VNF snapshot package operation". 
          Multiples instances of the same VNF snapshot package share the same vnfSnapshotPkgUniqueId.

          See note.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Identifier"
      name:
        description: > 
          Human-readable name of the VNF snapshot package.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/String"
      checksum:
        description: > 
          Checksum of the stored VNF snapshot package. Hash algorithms applicable to VNF 
          snapshot packages are defined in ETSI GS NFV-SOL 010.

          See note.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Checksum"
      createdAt:
        description: > 
          Timestamp indicating when the VNF snapshot package creation has been completed.

          See note.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/DateTime"
      vnfSnapshotId:
        description: > 
          Identifier of specific VNF snapshot in the VNF snapshot package. 
          This identifier  is allocated by the VNFM during the VNF snapshot creation.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Identifier"
      vnfcSnapshotInfoIds:
        description: > 
          Identifiers of information held by the VNFM about specific VNFC snapshots part 
          of the VNF snapshot and contained in the VNF snapshot package. This identifier 
          is allocated by the VNFM during the VNF snapshot creation.

          See note.
        type: object
        items:
          $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/IdentifierLocal"
      isFullSnapshot:
        description: > 
          Value is TRUE in case of a "full" VNF snapshot package, i.e., containing all snapshotted 
          VNFC instances; otherwise the value is FALSE.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Boolean"
      vnfdInfo:
        description: > 
          VNFD of the snapshotted VNF instance that is contained in the stored VNF snapshot package.
        $ref: "#/definitions/VnfdInfo"
      vnfsr:
        description: > 
          VNF snapshot record with the information as present in the representation of the 
          "Individual VNF snapshot" resource.
        $ref: "#/definitions/VnfSnapshotRecord"
      vnfcSnapshotImages:
        description: > 
          Information about VNF snapshot artifacts that are VNFC snapshot images. Every local and 
          external snapshot image shall be included. No other artifacts shall be included.

          See note.
        type: object
        items:
          $ref: "#/definitions/VnfcSnapshotImageInfo"
      additionalArtifacts:
        description: > 
          Information about VNF snapshot artifacts that are not VNFC snapshot images.

          See note.
        type: object
        items:
          $ref: "#/definitions/SnapshotPkgArtifactInfo"
      state:
        description: > 
          State of the VNF snapshot package. 
          Permitted values:
          - CREATED: the VNF snapshot package information has been created.
          - BUILDING: the VNF snapshot package is being built.
          - UPLOADING: the VNF snapshot package is being uploaded.
          - EXTRACTING: the VNF snapshot package’s content is being extracted.
          - AVAILABLE: the VNF snapshot package is available (i.e., build or upload is completed).
          - PROCESSING: the VNF snapshot is being processed. 
          - ERROR: failure during the VNF snapshot package building, uploading or processing.
          - ERROR_EXTRACTING: failure during the VNF snapshot package extraction task.
        type: string
        enum:
          - CREATED
          - BUILDING
          - UPLOADING
          - EXTRACTING
          - AVAILABLE
          - PROCESSING
          - ERROR
          - ERROR_EXTRACTING
      isCancelPending:
        description: > 
          Indicates if an ongoing operation with the content of the VNF snapshot package is being 
          cancelled. If the value of the "state" attribute is "BUILDING", "UPLOADING", "PROCESSING" 
          or "EXTRACTING" and the operation is being cancelled, this attribute shall be set to true. 
          Otherwise, it shall be set to false.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Boolean"
      failureDetails:
        description: > 
          Failure details associated to current error state of the VNF snapshot package state.
          If "state" is "ERROR" or "ERROR_EXTRACTING", this attribute shall be present unless 
          it has been requested to be excluded via an attribute selector.
        type: object
        required: 
        - errorType
        - details
        properties: 
          errorType:
            description: >
              Type of error, when the failure happened (building, upload, processing, extracting).
              
              Permitted values:
              - BUILD_ERROR
              - UPLOAD_ERROR
              - PROCESS_ERROR
              - CANCELLED
              - EXTRACTION_ERROR
            type: string
            enum:
              - BUILD_ERROR
              - UPLOAD_ERROR
              - PROCESS_ERROR
              - CANCELLED
              - EXTRACTION_ERROR
          details:
            description: >
              Failure details containing error information (such as failed uploading or processing
              operation, affected artifact, reason for cancellation, etc.). See clause 6.3 of 
              ETSI GS NFV-SOL 013 for the details of "ProblemDetails" structure.
            $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/ProblemDetails"
      userDefinedData:
        description: > 
          User defined data for the VNF snapshot package to be built/uploaded.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/KeyValuePairs"
      _links:
        description: > 
          Links to resources related to this resource.
        type: object
        required: 
        - self
        - packageContent
        properties:
          self:
            description: >
              URI of this resource.
            $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Link"
          packageContent:
            description: >
              Link to the "VNF snapshot package content" resource.
            $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Link"

  VnfcSnapshotImageInfo:
    description: >
      This type represents an artifact contained in a VNF snapshot package which represents a snapshot image. 
      It shall comply with the provisions defined in table 12.5.3.2-1.

      NOTE 1:	The list of permitted values was taken from "Container formats" in OpenStack® documentation: "Disk and container formats for images"
              (Available at https://docs.openstack.org/glance/pike/user/formats.html).
      NOTE 2:	The list of permitted values was adapted from "Disk formats" in OpenStack® documentation: "Disk and container formats for images"
              (Available at https://docs.openstack.org/glance/pike/user/formats.html).
    type: object
    required:
    - id
    - name
    - checksum
    - isEncrypted
    - vnfcInstanceId
    - containerFormat
    - diskFormat
    - createdAt
    - minDisk
    - minRam
    - size
    properties:
      id:
        description: > 
          Identifier of the VNFC snapshot image.
          When building the VNF snapshot package, the NFVO shall set the value of this attribute as follows:
          - for an image artifact corresponding to a compute snapshot resource, the value is copied from the 
            "id" attribute of the “VnfcSnapshotInfo”,
          - for an image artifact corresponding to a storage snapshot resource, the value is copied from the 
            "storageResourceId" attribute in the "VnfcSnapshotInfo" of the corresponding storage snapshot resource.
          When onboarding an existing VNF snapshot package, the NFVO shall set the value of this attribute as provided 
          in the manifest file in the VNF snapshot package (refer to ETSI GS NFV-SOL 010).
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/IdentifierLocal"
      name:
        description: > 
          Name of the VNFC snapshot image.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/String"
      checksum:
        description: > 
          Checksum of the snapshot image file. Hash algorithms applicable to VNF 
          snapshot package artifacts are defined in ETSI GS NFV-SOL 010.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Checksum"
      isEncrypted:
        description: > 
          Reflects whether the artifact is encrypted (true) or not (false).
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Boolean"
      vnfcInstanceId:
        description: > 
          Identifier of the snapshotted VNFC instance that this snapshot image belongs to.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/IdentifierInVnf"
      containerFormat:
        description: > 
          Container format indicates whether the snapshot image is in a file format that 
          also contains metadata about the actual snapshot.

          Permitted values:
          - AKI: a kernel image format
          - AMI: a machine image format
          - ARI: a ramdisk image format
          - BARE: the image does not have a container or metadata envelope
          - DOCKER: docker container format
          - OVA: OVF package in a tarfile
          - OVF: OVF container format

          See note 1.
        type: string
        enum:
          - AKI
          - AMI
          - ARI
          - BARE
          - DOCKER
          - OVA
          - OVF
      diskFormat:
        description: > 
          Disk format of a snapshot image is the format of the underlying disk image.

          Permitted values:
          - AKI: a kernel image format
          - AMI: a machine image format
          - ARI: a ramdisk image format
          - ISO: an archive format for the data contents of an optical disc, such as CD-ROM
          - QCOW2: a common disk image format, which can expand dynamically and supports copy on write
          - RAW: an unstructured disk image format
          - VDI: a common disk image format
          - VHD: a common disk image format
          - VHDX: enhanced version of VHD format
          - VMDK: a common disk image format

          See note 2.
        type: string
        enum:
          - AKI
          - AMI
          - ARI
          - ISO
          - QCOW2
          - RAW
          - VDI
          - VHD
          - VHDX
          - VMDK
      createdAt:
        description: > 
          Timestamp indicating when the VNFC snapshot image was created.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/DateTime"
      minDisk:
        description: > 
          The minimal disk for this VNFC snapshot image (in bytes).
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/UnsignedInt"
      minRam:
        description: > 
          The minimal RAM for this VNFC snapshot image (in bytes).
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/UnsignedInt"
      size:
        description: > 
          Size of this VNFC snapshot image (in bytes).
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/UnsignedInt"
      userMetadata:
        description: > 
          User-defined metadata.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/KeyValuePairs"
      imagePath:
        description: > 
          Path which identifies the image artifact and also allows to access a copy of the image artifact.
          For an image artifact contained as a file in the VNF snapshot package, this attribute shall be 
          present, and the value of this attribute shall start with the name of the first segment in the 
          path in the package, i.e., it shall not be prefixed by path separator characters such as "." 
          and "/". 
          
          EXAMPLE: foo/bar/m%40ster.vhd

          For an external image artifact represented as a URI in the manifest file, this attribute shall 
          be present if the artifact has been downloaded by the NFVO or the artifact has been processed 
          after building the VNF snapshot package and shall be absent otherwise. If present, it shall 
          contain the artifactPath under which the image artifact can be obtained using the 
          "Individual artifact in a VNF snapshot package" resource defined in clause 12.4.5. It is the 
          responsibility of the NFVO to synthesize this path in a manner that avoids any collision of 
          the synthesized artifact path with the paths and names of artifacts included in the snapshot 
          package.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/String"
      imageUri:
        description: > 
          URI of the image artifact as defined in the VNF snapshot package manifest. Shall be present 
          if the image artifact is external to the snapshot package and shall be absent otherwise.

          EXAMPLE: https://example.com/m%40ster.vhd
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Uri"

  SnapshotPkgArtifactInfo:
    description: >
      This type represents an artifact other than a software image which is contained in 
      a VNF snapshot package.
    type: object
    required:
    - checksum
    - isEncrypted
    properties:
      artifactPath:
        description: > 
          Path which identifies the artifact and also allows to access a copy of the artifact.
          For an artifact contained as a file in the VNF snapshot package, this attribute shall 
          be present, and the value of this attribute shall start with the name of the first 
          segment in the path in the package, i.e. it shall not be prefixed by path separator 
          characters such as "." and "/". 

          EXAMPLE: foo/bar/m%40ster.sh

          For an external artifact represented as a URI in the manifest file, this attribute 
          shall be present if the artifact has been downloaded by the NFVO or the artifact has
          been processed after building the VNF snapshot package and shall be absent otherwise. 
          If present, it shall contain the artifactPath under which the artifact can be obtained
          using the "Individual artifact in a VNF snapshot package" resource defined in 
          clause 12.4.5. It is the responsibility of the NFVO to synthesize this path in a manner 
          that avoids any collision of the synthesized artifact path with the paths and names of 
          artifacts included in the snapshot package.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/String"
      artifactUri:
        description: > 
          URI of the artifact as defined in the VNF snapshot package manifest. Shall be present 
          if the artifact is external to the snapshot package and shall be absent otherwise.
          
          EXAMPLE: https://example.com/m%40ster.sh
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Uri"
      checksum:
        description: > 
          Checksum of the artifact file. Hash algorithms applicable to VNF 
          snapshot package artifacts are defined in ETSI GS NFV-SOL 010.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Checksum"
      isEncrypted:
        description: > 
          Reflects whether the artifact is encrypted (true) or not (false).
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Boolean"
      metadata:
        description: > 
          The metadata of the artifact that are available in the VNF package, such as Content type, 
          size, creation date, etc.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/KeyValuePairs"

  VnfdInfo:
    description: >
      This type represents the VNFD which is contained in a VNF snapshot package.
    type: object
    required:
    - avnfdId
    - vnfdPath
    - checksum
    - isEncrypted
    properties:
      avnfdId:
        description: > 
          VNFD identifier of the snapshotted VNF instance.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Identifier"
      vnfdPath:
        description: > 
          Path which allows to access a copy of the VNFD. The VNFD is implemented as 
          a collection of one or more files, and the path refers to the ZIP archive 
          file embedding these files. The VNF snapshot package format is defined 
          specified in the ETSI GS NFV-SOL 010.
          The value of this attribute shall start with the name of the first segment 
          of the path in the package, i.e. it shall not be prefixed by path separator 
          characters such as "." and "/".
          EXAMPLE: foo/bar/m@ster
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/String"
      checksum:
        description: > 
          Checksum of the VNFD archive file. Hash algorithms applicable to VNF 
          snapshot package artifacts are defined in ETSI GS NFV-SOL 010.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Checksum"
      isEncrypted:
        description: > 
          Reflects whether the VNFD archive file is encrypted (true) or not (false).
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Boolean"

  VnfSnapshotRecord:
    description: >
      This type represents the VNF snapshot record which is contained in a VNF snapshot package.
    type: object
    required:
    - recordPath
    - checksum
    - isEncrypted
    properties:
      recordPath:
        description: >
          Path which identifies the VNF snapshot record and allows to access a copy of the 
          VNF snapshot record for the extraction.
          The value of this attribute shall start with the name of the first segment of the 
          path in the package, i.e. it shall not be prefixed by path separator characters 
          such as "." and "/".
          EXAMPLE: foo/bar/m@ster
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/String"
      checksum:
        description: >
          Checksum of the VNF snapshot record file. Hash algorithms applicable to VNF 
          snapshot package artifacts are defined in ETSI GS NFV-SOL 010.
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Checksum"
      isEncrypted:
        description: >
          Reflects whether the VNF snapshot record file is encrypted (true) or not (false).
        $ref: "../../../definitions/SOL002SOL003_def.yaml#/definitions/Boolean"
