Skip to content

Commit

Permalink
Merge pull request #88 from oracle/release_2018-09-27
Browse files Browse the repository at this point in the history
Releasing version 2.4.33
  • Loading branch information
paul-hummel-oracle authored Sep 27, 2018
2 parents baff723 + 6e77d86 commit 38688a2
Show file tree
Hide file tree
Showing 76 changed files with 29,486 additions and 26,105 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ All notable changes to this project will be documented in this file.

The format is based on `Keep a Changelog <http://keepachangelog.com/>`__.

2.4.33 - 2018-09-27
---------------------
Added
~~~~~~~~
* Support for Key Management Service (``oci kms``)

* Examples on using the Key Management Service can be found on `GitHub <https://github.com/oracle/oci-cli/blob/master/scripts/examples/kms_example.sh>`__.
* Support for ``--wait-for-state`` option on multiple commands.
* Improved custom image support by introducing PARAVIRTUALIZED as a launch mode option in the Image Import command.

* (``oci compute image import --launch-mode PARAVIRTUALIZED``)
* Support for creating bucket with ``--kms-key-id``, updating ``--kms-key-id`` of a bucket.
* Support for creating data volume, boot volume, launch instance with ``--kms-key-id``, updating ``--kms-key-id`` for a data volume or boot volume.

2.4.32 - 2018-09-06
---------------------
Added
Expand Down
9 changes: 7 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# You may need to run this as:
# pip install --trusted-host=artifactory.oci.oraclecorp.com -r requirements.txt
# because the requirements.txt file doesn't support the --trusted-host option (https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format)
--extra-index-url https://artifactory.oci.oraclecorp.com/api/pypi/opc-public-sdk-dev-pypi-local/simple

appdirs==1.4.3
arrow==0.10.0
certifi
Expand All @@ -12,7 +17,7 @@ Jinja2==2.9.6
jmespath==0.9.3
ndg-httpsclient==0.4.2
mock==2.0.0
oci==2.0.3
oci==2.0.4
packaging==16.8
pluggy==0.4.0
py==1.4.33
Expand All @@ -31,6 +36,6 @@ sphinx==1.6.4
sphinx-rtd-theme==0.2.5b1
terminaltables==3.1.0
tox==2.9.1
vcrpy==1.11.1
vcrpy==1.13.0
virtualenv==15.1.0
pytest-xdist==1.22.2
138 changes: 138 additions & 0 deletions scripts/examples/kms_example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/bin/bash
# This script provides basic examples on the usage of the KMS service with the CLI.
#
# These examples assume you already have a Vault in ACTIVE state. If you need to create a new Vault, please
# refer to the command in the comments section of this file. Please keep in mind that KMS does not support immediate
# deletion of Vaults because of the high risk; instead, you need to schedule the deletion of a Vault and a
# retention period of 7-30 days will be enforced before the Vault is deleted. During the retention period, you
# can cancel the deletion and the Vault will be ACTIVE again. Be careful before creating a Vault to avoid
# unnecessary expenses.
#
# As a reference, here is the command you can use to create a new Vault with OCI CLI, replace the compartment-id and
# display-name with your own values:
#
# oci kms management vault create --compartment-id $COMPARTMENT_ID --display-name $VAULT_NAME --vault-type VIRTUAL_PRIVATE --wait-for-state ACTIVE
#
# Here are some parameters that need to be specified first:
#
# * COMPARTMENT_ID: The OCID of the compartment where KMS resources will be created
# * VAULT_NAME_NEW: A new name for the Vault
# * KEY_NAME: A user friendly name of Key
# * KEY_NAME_NEW: A new name for the Key
# * KEY_SHAPE: The shape of the Key. An example: '{"algorithm":"AES","length":"16"}'
# * PLAINTEXT: The Base64-Encoded plaintext that will be encrypted
#
# Requirements for running this script:
# - OCI CLI v2.4.31 or later (you can check this by running oci --version)
# - Please make sure the user and tenancy used by the CLI have the appropriate permissions for these operations

set -e

# Fill up the values of the following parameters
VAULT_OCID=""
COMPARTMENT_ID=""
VAULT_NAME_NEW=""
KEY_NAME=""
KEY_NAME_NEW=""
# Use this one by default or replace with yours
KEY_SHAPE='{"algorithm":"AES","length":"16"}'
PLAINTEXT=""

# KMS Vault Operations
echo ""
echo "=========================================== KMS Vault Operations (oci kms management vault) ==========================================="
echo ""

# Retrieve the details of the existing Vault in ACTIVE state.
# The Vault may be in CREATING state for a short period of time and then transit to ACTIVE state
echo "Get KMS Vault with OCID: $VAULT_OCID"
oci kms management vault get --vault-id $VAULT_OCID
MANAGEMENT_ENDPOINT=$(oci kms management vault get --vault-id $VAULT_OCID --query 'data."management-endpoint"' --raw-output)
CRYPTO_ENDPOINT=$(oci kms management vault get --vault-id $VAULT_OCID --query 'data."crypto-endpoint"' --raw-output)

# Update the display name of the Vault
echo "Updating display name of Vault with OCID: $VAULT_OCID"
oci kms management vault update --vault-id $VAULT_OCID --display-name $VAULT_NAME_NEW

# List all Vaults in the compartment
echo "Listing all Vaults in the compartment with OCID: $COMPARTMENT_ID"
oci kms management vault list --compartment-id $COMPARTMENT_ID --all

# Schedule deletion of the Vault.
# An optional parameter, time-of-deletion, can be used to specify when the deletion shall happen. Here the parameter is
# ignored and the default time (30 days after the time of request) will be used.
# The Vault may stay in SCHEDULING_DELETION state for a short period of time, and then transit to PENDING_DELETION state
echo "Scheduling deletion of Vault with OCID: $VAULT_OCID"
oci kms management vault schedule-deletion --vault-id $VAULT_OCID
echo "Wait a bit for Vault deletion to be scheduled"
sleep 30

# Cancel the deletion of the Vault
# The Vault may stay in CANCELLING_DELETION state for a short period of time, and then transit to ACTIVE state
echo "Cancelling deletion of Vault with OCID: $VAULT_OCID"
oci kms management vault cancel-deletion --vault-id $VAULT_OCID
echo "Wait a bit for Vault deletion to be cancelled"
sleep 30

# KMS Key Operations
echo " "
echo "=========================================== KMS Key Operations (oci kms management key) ==========================================="
echo " "

# Create a new Key in the Vault above, using the management-endpoint of the Vault
echo "Creating Key in Vault: $VAULT_OCID"
KEY_OCID=$(oci kms management key create --compartment-id $COMPARTMENT_ID --display-name $KEY_NAME --key-shape $KEY_SHAPE --query 'data.id' --raw-output --endpoint $MANAGEMENT_ENDPOINT) --wait-for-state ENABLED
echo "Wait a bit for Key creation to complete"

# Retrieve the details of the Key
echo "Retrieving KMS Key, OCID: $KEY_OCID"
oci kms management key get --key-id $KEY_OCID --endpoint $MANAGEMENT_ENDPOINT

# List all Keys in the Vault
echo "List all Keys in Vault with OCID: $VAULT_OCID"
oci kms management key list --compartment-id $COMPARTMENT_ID --endpoint $MANAGEMENT_ENDPOINT --all

# Create a new KeyVersion of the Key. This has the same effects of rotating a Key.
echo "Creating a new KeyVersion for Key with OCID: $KEY_OCID"
oci kms management key-version create --key-id $KEY_OCID --endpoint $MANAGEMENT_ENDPOINT
echo "Wait a bit for Key-Version to be created"
sleep 30

# List all KeyVersions of the Key
echo "Listing all KeyVersions of Key with OCID: $KEY_OCID"
oci kms management key-version list --key-id $KEY_OCID --endpoint $MANAGEMENT_ENDPOINT --all

# Disable the Key
# The Key may stay in DISABLING state for a short period of time, and then transit to DISABLED state
echo "Disabling Key with OCID: $KEY_OCID"
oci kms management key disable --key-id $KEY_OCID --endpoint $MANAGEMENT_ENDPOINT
echo "Wait a bit for Key to be disabled"
sleep 30

# Enable the Key
# The Key may stay in ENABLING state for a short period of time, and then transit to ENABLED state
echo "Enabling Key with OCID: $KEY_OCID"
oci kms management key enable --key-id $KEY_OCID --endpoint $MANAGEMENT_ENDPOINT
echo "Wait a bit for Key to be enabled"
sleep 30

# Update the display name of the Key
echo "Updating DisplayName of Key with OCID: $KEY_OCID"
oci kms management key update --key-id $KEY_OCID --display-name $KEY_NAME_NEW --endpoint $MANAGEMENT_ENDPOINT

echo " "
echo "=========================================== KMS Crypto Operations (oci kms crypto) ==========================================="
echo " "

# Encrypt some data with the Key, the plaintext must be base64 encoded
echo "Encrypting plaintext with Key with OCID: $KEY_OCID"
oci kms crypto encrypt --key-id $KEY_OCID --plaintext $PLAINTEXT --endpoint $CRYPTO_ENDPOINT
CIPHERTEXT=$(oci kms crypto encrypt --key-id $KEY_OCID --plaintext $PLAINTEXT --endpoint $CRYPTO_ENDPOINT --query 'data.ciphertext' --raw-output)

# Decrypt the data we just encrypted previously
echo "Decrypting ciphertext with Key with OCID: $KEY_OCID"
oci kms crypto decrypt --key-id $KEY_OCID --ciphertext $CIPHERTEXT --endpoint $CRYPTO_ENDPOINT

# Generate DataEncryptionKey (A key that you can use to encrypt or decrypt data).
echo "Generating DataEncryptionKey (DEK) with Key with OCID: $KEY_OCID"
oci kms crypto generate-data-encryption-key --key-id $KEY_OCID --include-plaintext-key true --key-shape $KEY_SHAPE --endpoint $CRYPTO_ENDPOINT
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def open_relative(*path):
readme = f.read()

requires = [
'oci==2.0.3',
'oci==2.0.4',
'arrow==0.10.0',
'certifi',
'click==6.7',
Expand Down
11 changes: 1 addition & 10 deletions src/oci_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,11 @@
from .custom_types import cli_from_json # noqa: F401,E402

from .generated import * # noqa: F401,F403,E402
from .extended import * # noqa: F401,F403,E402

from . import aliasing # noqa: F401,E402
from . import audit_cli_extended # noqa: F401,E402
from . import containerengine_cli_extended # noqa: F401,E402
from . import core_cli_extended # noqa: F401,E402
from . import database_cli_extended # noqa: F401,E402
from . import dns_cli_extended # noqa: F401,E402
from . import identity_cli_extended # noqa: F401,E402
from . import objectstorage_cli_extended # noqa: F401,E402
from . import resourcesearch_cli_extended # noqa: F401,E402
from . import email_cli_extended # noqa: F401,E402
from . import file_filters # noqa: F401,E402
from . import final_command_processor # noqa: F401,E402
from . import lb_cli_extended # noqa: F401,E402
from . import cli_setup # noqa: F401,E402
from . import cli_util # noqa: F401,E402
from . import cli_exceptions # noqa: F401,E402
Expand Down
Loading

0 comments on commit 38688a2

Please sign in to comment.