-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a jupyter document for creating and managing service groups
This commit depends on the PDO update for persistent service groups database. Add a jupyter notebook for creating, managing and using service groups. This update includes widgets to simplify selection and use of service groups. Also adds a jupyter notebook for demonstrating different widgets that are not part of the management pages. Signed-off-by: Mic Bowman <mic.bowman@intel.com>
- Loading branch information
Showing
5 changed files
with
483 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# --- | ||
# jupyter: | ||
# jupytext: | ||
# text_representation: | ||
# extension: .py | ||
# format_name: percent | ||
# format_version: '1.3' | ||
# jupytext_version: 1.16.1 | ||
# kernelspec: | ||
# display_name: Python 3 (ipykernel) | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% [markdown] | ||
# # Service Groups Management for PDO Contracts | ||
# | ||
# This notebook helps to manage the services database. | ||
|
||
# %% | ||
import pdo.contracts.jupyter as pc_jupyter | ||
import IPython.display as ip_display | ||
import ipywidgets | ||
|
||
from pdo.contracts.services import service_labels | ||
from pdo.contracts.groups import ServiceGroupListWidget | ||
from pdo.contracts.groups import EnclaveServiceGroupCreateWidget | ||
from pdo.contracts.groups import ProvisioningServiceGroupCreateWidget | ||
from pdo.contracts.groups import StorageServiceGroupCreateWidget | ||
|
||
pc_jupyter.load_ipython_extension(get_ipython()) | ||
|
||
try : | ||
state | ||
except NameError: | ||
(state, bindings) = pc_jupyter.initialize_environment('unknown') | ||
|
||
# %% [markdown] | ||
# ## List of Available Service Groups | ||
# | ||
# %% | ||
children = map(lambda stype : ServiceGroupListWidget(state, bindings, stype), service_labels.keys()) | ||
service_list_widget = ipywidgets.Tab(children=list(children), titles=list(service_labels.values())) | ||
ip_display.display(service_list_widget) | ||
|
||
# %% [markdown] | ||
# ## Create a New Enclave Service Group | ||
# | ||
# %% | ||
ip_display.display(EnclaveServiceGroupCreateWidget(state, bindings)) | ||
|
||
# %% [markdown] | ||
# ## Create a New Provisioning Service Group | ||
# | ||
# %% | ||
ip_display.display(ProvisioningServiceGroupCreateWidget(state, bindings)) | ||
|
||
# %% [markdown] | ||
# ## Create a New Storage Service Group | ||
# | ||
# %% | ||
ip_display.display(StorageServiceGroupCreateWidget(state, bindings)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# --- | ||
# jupyter: | ||
# jupytext: | ||
# text_representation: | ||
# extension: .py | ||
# format_name: percent | ||
# format_version: '1.3' | ||
# jupytext_version: 1.16.1 | ||
# kernelspec: | ||
# display_name: Python 3 (ipykernel) | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% [markdown] | ||
# # Sample Widgets | ||
# ## WORK IN PROGRESS | ||
# | ||
# This notebook demonstrates a variety of Jupyter widgets for PDO. | ||
|
||
# %% | ||
import pdo.contracts.jupyter as pc_jupyter | ||
import IPython.display as ip_display | ||
import ipywidgets | ||
|
||
from pdo.contracts.services import service_labels, ServiceSelectionWidget | ||
from pdo.contracts.groups import ServiceGroupSelectionWidget | ||
|
||
pc_jupyter.load_ipython_extension(get_ipython()) | ||
|
||
try : | ||
state | ||
except NameError: | ||
(state, bindings) = pc_jupyter.initialize_environment('unknown') | ||
|
||
# %% [markdown] | ||
# # Key Management Widgets | ||
# %% [markdown] | ||
# ## Key Selection Widgets | ||
# %% | ||
def display_key(selection, output) : | ||
with output : | ||
print("Selection: {}".format(selection)) | ||
|
||
public_key_widget = pc_jupyter.keys.PublicKeySelectionWidget(state, bindings, "Display", display_key) | ||
ip_display.display(public_key_widget) | ||
|
||
private_key_widget = pc_jupyter.keys.PrivateKeySelectionWidget(state, bindings, "Display", display_key) | ||
ip_display.display(private_key_widget) | ||
|
||
# %% [markdown] | ||
# # Service Management Widgets | ||
# %% [markdown] | ||
# ## Service Selection Widget | ||
# %% | ||
def display_service(service_type, selection, output) : | ||
with output : | ||
print("Selection [{}]: {}".format(service_type, ", ".join(selection))) | ||
|
||
def create_service_selection(service_type) : | ||
return ServiceSelectionWidget(state, bindings, service_type, 'Display', display_service) | ||
|
||
children = map(lambda service_type : create_service_selection(service_type), service_labels.keys()) | ||
service_selection_widget = ipywidgets.Tab(children=list(children), titles=list(service_labels.values())) | ||
ip_display.display(service_selection_widget) | ||
|
||
# %% [markdown] | ||
# # Service Groups Widgets | ||
# %% [markdown] | ||
# ## Select Service Groups | ||
# %% | ||
def display_group(service_type, selection, output) : | ||
with output : | ||
print("Selection [{}]: {}".format(service_type, selection)) | ||
|
||
def create_group_selection(service_type) : | ||
return ServiceGroupSelectionWidget(state, bindings, service_type, 'Display', display_group) | ||
|
||
children = map(lambda service_type : create_group_selection(service_type), service_labels.keys()) | ||
group_selection_widget = ipywidgets.Tab(children=list(children), titles=list(service_labels.values())) | ||
ip_display.display(group_selection_widget) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.