Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deployment: update deployment for container measurement
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaocheng Dong <xiaocheng.dong@intel.com>
dongx1x committed Feb 23, 2024
1 parent a272250 commit 796ab06
Showing 38 changed files with 227 additions and 1,475 deletions.
30 changes: 0 additions & 30 deletions container/ccnp-eventlog-server/Dockerfile

This file was deleted.

25 changes: 25 additions & 0 deletions container/ccnp-example/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.12.1-alpine3.19 AS python-builder

RUN apk update && apk add git
RUN python3 -m pip install --upgrade build
RUN git clone https://github.com/cc-api/cc-trusted-api && \
cd cc-trusted-api/common/python && \
python3 -m build

COPY sdk/python3 ccnp-sdk
RUN cd ccnp-sdk && python3 -m build

# ======================================================================================================================

FROM python:3.12.1-alpine3.19

WORKDIR /run/ccnp

COPY container/ccnp-example/ccnp_example.py ./
COPY --from=python-builder cc-trusted-api/common/python/dist/cctrusted_base*.whl ./
COPY --from=python-builder ccnp-sdk/dist/ccnp*.whl ./

RUN apk update && apk add bash vim
RUN pip install ./cctrusted_base*.whl ./ccnp*.whl && rm -f *.whl

ENTRYPOINT ["tail", "-f", "/dev/null"]
50 changes: 50 additions & 0 deletions container/ccnp-example/ccnp_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
CCNP SDK Example
"""

import logging
import argparse

from ccnp import CcnpSdk

LOG = logging.getLogger(__name__)

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
handlers=[
logging.StreamHandler()
]
)

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="The utility to show how to use CCNP SDK")
parser.add_argument('-r', action='store_true', help='get cc report', dest='report')
parser.add_argument('-e', action='store_true', help='get cc eventlog', dest='eventlog')
parser.add_argument('-m', action='store_true', help='get cc measurement', dest='measurement')
parser.add_argument('-v', action='store_true', help='verify eventlog', dest='verify')
args = parser.parse_args()

if args.report:
CcnpSdk.inst().get_cc_report().dump()
elif args.eventlog:
evt = CcnpSdk.inst().get_cc_eventlog()
for e in evt:
e.dump()
elif args.measurement:
for i in [0, 1, 3]:
m = CcnpSdk.inst().get_cc_measurement([i, 12])
LOG.info("IMR index: %d, hash: %s", i, m.hash.hex())
elif args.verify:
evt = CcnpSdk.inst().get_cc_eventlog()
replay = CcnpSdk.inst().replay_cc_eventlog(evt)
for r in replay:
LOG.info("Replay IMR[%d]: %s", r, replay[r][12].hex())
m = CcnpSdk.inst().get_cc_measurement([r, 12])
LOG.info("Read IMR[%d]: %s", r, m.hash.hex())
if m.hash != replay[r][12]:
LOG.error("Replay IMR value does not match real IMR.")
else:
LOG.info("Verify event log replay value successfully.")
else:
parser.print_help()
30 changes: 0 additions & 30 deletions container/ccnp-measurement-server/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions container/ccnp-node-measurement-example/Dockerfile

This file was deleted.

Loading

0 comments on commit 796ab06

Please sign in to comment.