Skip to content

Commit fa795a7

Browse files
authored
Merge pull request #245 from oracle/release_2020-04-14
Releasing version 2.12.4
2 parents ae15f6a + 9594e64 commit fa795a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3579
-5430
lines changed

CHANGELOG.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ Change Log
33
All notable changes to this project will be documented in this file.
44

55
The format is based on `Keep a Changelog <http://keepachangelog.com/>`_.
6+
====================
7+
2.12.4 - 2020-04-14
8+
====================
9+
10+
Added
11+
-----
12+
* Support for access types on instances in the Content and Experience service
13+
* Support for identity contexts in the Search service
14+
* Support for Client Side Encryption: https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/clientsideencryption.htm
15+
* Support for retries on Python built-in `ConnectionError <https://docs.python.org/3/library/exceptions.html#ConnectionError>`__
16+
617
====================
718
2.12.3 - 2020-04-07
819
====================

THIRD_PARTY_LICENSES.txt

Lines changed: 808 additions & 5302 deletions
Large diffs are not rendered by default.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# coding: utf-8
2+
# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
3+
4+
# Instructions:
5+
# As a pre-requisite for this example you must have a vault created in KMS with at least one master key.
6+
# OCI KMS has APIs that allow creating master keys or importing a previously generated key, either will work.
7+
# You can refer to the example at examples/kms_example.py for an example of how to create a master key.
8+
# Update the values for VAULT_ID and MASTER_KEY_ID below with the values for your vault and key and then run
9+
# the example.
10+
# Also update BUCKET_NAME to a bucket in your tenancy that can be used for the upload / download encrypted object
11+
# portion of the sample.
12+
13+
import oci
14+
15+
# TODO: populate variables below
16+
VAULT_ID = ""
17+
MASTER_KEY_ID = ""
18+
BUCKET_NAME = ""
19+
20+
# load default configuration from ~/.oci/config
21+
config = oci.config.from_file()
22+
23+
kms_master_key = oci.encryption.KMSMasterKey(
24+
config=config, master_key_id=MASTER_KEY_ID, vault_id=VAULT_ID
25+
)
26+
27+
kms_master_key_provider = oci.encryption.KMSMasterKeyProvider(
28+
config=config,
29+
kms_master_keys=[kms_master_key]
30+
)
31+
32+
###############################################
33+
# Object Storage examples
34+
###############################################
35+
input_payload_file = 'encryption_payload_sample.txt'
36+
object_name = input_payload_file + '.enc'
37+
38+
object_storage_client = oci.object_storage.ObjectStorageClient(config)
39+
upload_manager = oci.object_storage.UploadManager(object_storage_client)
40+
namespace_name = object_storage_client.get_namespace().data
41+
42+
# encrypt and upload file to object storage
43+
with open(input_payload_file, 'rb') as input_file:
44+
with oci.encryption.create_encryption_stream(
45+
master_key_provider=kms_master_key_provider,
46+
stream_to_encrypt=input_file,
47+
) as encryption_stream:
48+
upload_manager.upload_stream(
49+
namespace_name=namespace_name,
50+
bucket_name=BUCKET_NAME,
51+
object_name=object_name,
52+
stream_ref=encryption_stream,
53+
)
54+
55+
print('encrypted object uploaded. namespace: {}, bucket: {}, object: {}'.format(namespace_name, BUCKET_NAME, object_name))
56+
57+
get_obj_response = object_storage_client.get_object(namespace_name=namespace_name, bucket_name=BUCKET_NAME, object_name=object_name)
58+
59+
# download content from object storage and decrypt
60+
with oci.encryption.create_decryption_stream(
61+
master_key_provider=kms_master_key_provider,
62+
stream_to_decrypt=get_obj_response.data.raw
63+
) as decryption_stream:
64+
decrypted_content = decryption_stream.read()
65+
66+
print('decrypted object downloaded. namespace: {}, bucket: {}, object: {}'.format(namespace_name, BUCKET_NAME, object_name))
67+
68+
with open(input_payload_file, 'rb') as input_file:
69+
assert input_file.read() == decrypted_content
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# coding: utf-8
2+
# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
3+
4+
# Instructions:
5+
# As a pre-requisite for this example you must have a vault created in KMS with at least one master key.
6+
# OCI KMS has APIs that allow creating master keys or importing a previously generated key, either will work.
7+
# You can refer to the example at examples/kms_example.py for an example of how to create a master key.
8+
# Update the values for VAULT_ID and MASTER_KEY_ID below with the values for your vault and key and then run
9+
# the example.
10+
11+
import shutil
12+
import filecmp
13+
14+
import oci
15+
16+
# TODO: populate variables below
17+
VAULT_ID = ""
18+
MASTER_KEY_ID = ""
19+
20+
# load default configuration from ~/.oci/config
21+
config = oci.config.from_file()
22+
23+
# if you want to target a region other than the one specified
24+
# in your config, you must override 'region' in the config
25+
# before initializing the MasterKey and MasterKeyProvider
26+
config['region'] = 'us-phoenix-1'
27+
28+
kms_master_key = oci.encryption.KMSMasterKey(
29+
config=config, master_key_id=MASTER_KEY_ID, vault_id=VAULT_ID
30+
)
31+
32+
kms_master_key_provider = oci.encryption.KMSMasterKeyProvider(
33+
config=config,
34+
kms_master_keys=[kms_master_key]
35+
)
36+
37+
###############################################
38+
# stream encryption / decryption
39+
###############################################
40+
input_payload_file = 'encryption_payload_sample.txt'
41+
encrypted_file = 'encrypted_payload.enc'
42+
decrypted_file = 'decrypted_payload.txt'
43+
44+
# encrypt stream and write to file
45+
encryption_context = {"some_additional_authenticated": "data"}
46+
with open(input_payload_file, 'rb') as input_file, open(encrypted_file, 'wb') as output_file:
47+
with oci.encryption.create_encryption_stream(
48+
master_key_provider=kms_master_key_provider,
49+
stream_to_encrypt=input_file,
50+
encryption_context=encryption_context,
51+
) as encryption_stream:
52+
# copy bytes from encryption stream to output file incrementally
53+
shutil.copyfileobj(encryption_stream, output_file)
54+
55+
# copy bytes from encryption stream to output file all at once
56+
# output_file.write(encryption_stream.read())
57+
58+
# decrypt stream and write to file
59+
with open(encrypted_file, 'rb') as input_file, open(decrypted_file, 'wb') as decrypted_output_file:
60+
with oci.encryption.create_decryption_stream(
61+
master_key_provider=kms_master_key_provider,
62+
stream_to_decrypt=input_file
63+
) as decryption_stream:
64+
# copy bytes from decryption stream to output file incrementally
65+
shutil.copyfileobj(decryption_stream, decrypted_output_file)
66+
67+
# copy bytes from decryption stream to output file all at once
68+
# decrypted_output_file.write(decryption_stream.read())
69+
70+
# validate encryption context contains all keys passed in initial encryption context
71+
# do not check exact equality as the SDK may add additional keys to the returned context
72+
encryption_context_keys = list(encryption_context)
73+
for key in encryption_context_keys:
74+
assert encryption_context[key] == decryption_stream.get_encryption_context()[key]
75+
76+
# validate that decrypted data matches initial payload
77+
assert filecmp.cmp(input_payload_file, decrypted_file)
78+
79+
# decrypt file reading into memory
80+
with open(encrypted_file, 'rb') as input_file:
81+
with oci.encryption.create_decryption_stream(
82+
master_key_provider=kms_master_key_provider,
83+
stream_to_decrypt=input_file
84+
) as decryption_stream:
85+
# copy bytes from decryption stream into memory all at once
86+
decrypted_content = decryption_stream.read()
87+
88+
with open(input_payload_file, 'rb') as input_file:
89+
assert input_file.read() == decrypted_content
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# coding: utf-8
2+
# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
3+
4+
# Instructions:
5+
# As a pre-requisite for this example you must have a vault created in KMS with at least one master key.
6+
# OCI KMS has APIs that allow creating master keys or importing a previously generated key, either will work.
7+
# You can refer to the example at examples/kms_example.py for an example of how to create a master key.
8+
# Update the values for VAULT_ID and MASTER_KEY_ID below with the values for your vault and key and then run
9+
# the example.
10+
11+
import oci
12+
13+
# TODO: populate variables below
14+
VAULT_ID = ""
15+
MASTER_KEY_ID = ""
16+
17+
# load default configuration from ~/.oci/config
18+
config = oci.config.from_file()
19+
20+
kms_master_key = oci.encryption.KMSMasterKey(
21+
config=config, master_key_id=MASTER_KEY_ID, vault_id=VAULT_ID
22+
)
23+
24+
kms_master_key_provider = oci.encryption.KMSMasterKeyProvider(
25+
config=config,
26+
kms_master_keys=[kms_master_key]
27+
)
28+
29+
# basic encrypt bytes or string data
30+
data_to_encrypt = b"Sample data to encrypt"
31+
encryption_context = {"some_additional_authenticated": "data"}
32+
crypto_result_encrypt = oci.encryption.encrypt(master_key_provider=kms_master_key_provider, data=data_to_encrypt, encryption_context=encryption_context)
33+
ciphertext = crypto_result_encrypt.get_data()
34+
35+
# basic decrypt bytes or str data
36+
crypto_result_decrypt = oci.encryption.decrypt(master_key_provider=kms_master_key_provider, data=ciphertext)
37+
decrypted_data = crypto_result_decrypt.get_data()
38+
39+
# crypto result includes the encryption context used to decrypt the data
40+
result_encryption_context = crypto_result_decrypt.get_encryption_context()
41+
42+
# validate that decrypted data matches initial payload
43+
assert data_to_encrypt == decrypted_data
44+
45+
# validate encryption context contains all keys passed in initial encryption context
46+
# do not check exact equality as the SDK may add additional keys to the returned context
47+
encryption_context_keys = list(encryption_context)
48+
for key in encryption_context_keys:
49+
assert encryption_context[key] == crypto_result_decrypt.get_encryption_context()[key]
50+
51+
52+
# You can also decrypt without specifying a specific KMSMasterKey ahead of time
53+
decryption_only_master_key_provider = oci.encryption.KMSMasterKeyProvider(
54+
config=config
55+
)
56+
57+
crypto_result_decrypt_2 = oci.encryption.decrypt(master_key_provider=decryption_only_master_key_provider, data=ciphertext)
58+
assert data_to_encrypt == crypto_result_decrypt_2.get_data()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is some sample data to be encrypted with the OCI Python SDK

examples/showoci/CHANGELOG.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

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

7+
=====================
8+
20.04.13 - 2020-04-13
9+
=====================
10+
* Added python version check
11+
* Removed VCN check for compartment in order to extract other components
12+
* Added Summary Total for Region
13+
* Fixed Summary Total to include stopped VMs OCPUs in different category
14+
* Added WAAS Policies to the -edge flag
15+
* Added network security groups to the csv output
16+
717
=====================
818
20.04.06 - 2020-04-06
919
=====================

examples/showoci/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Output can be printer friendly, CSV files or JSON file.
4646
- oci.nosql.NosqlClient
4747
- oci.dns.DnsClient
4848
- oci.events.EventsClient
49+
- oci.waas.WaasClient
4950

5051
** DISCLAIMER – This is not an official Oracle application
5152

@@ -163,7 +164,7 @@ optional arguments:
163164
-cn Print Containers
164165
-d Print Database
165166
-e Print EMail
166-
-edge Print Edge and DNS Services
167+
-edge Print Edge, DNS Services and WAAS policies
167168
-f Print File Storage
168169
-fun Print Functions
169170
-i Print Identity

examples/showoci/showoci.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
# - oci.dns.DnsClient
6161
# - oci.events.EventsClient
6262
# - oci.bds.BdsClient
63+
# - oci.waas.WaasClient
6364
#
6465
# Modules Not Yet Covered:
65-
# - oci.waas.WaasClient
6666
# - oci.secrets.SecretsClient
6767
# - oci.vault.VaultsClient
6868
# - oci.work_requests.WorkRequestClient
@@ -71,18 +71,29 @@
7171
from showoci_data import ShowOCIData
7272
from showoci_output import ShowOCIOutput, ShowOCISummary, ShowOCICSV
7373
from showoci_service import ShowOCIFlags
74+
7475
import json
7576
import sys
7677
import argparse
7778
import datetime
7879

79-
version = "20.04.07"
80+
version = "20.04.13"
8081

8182
##########################################################################
82-
# execute_extract
83+
# check OCI version
8384
##########################################################################
85+
if sys.version_info.major < 3:
86+
python_version = str(sys.version_info.major) + "." + str(sys.version_info.minor)
87+
print("******************************************************")
88+
print("*** Showoci only supports Python 3 or Above ***")
89+
print("*** Current Version = " + python_version.ljust(16) + " ***")
90+
print("******************************************************")
91+
sys.exit()
8492

8593

94+
##########################################################################
95+
# execute_extract
96+
##########################################################################
8697
def execute_extract():
8798

8899
# get parset cmd
@@ -239,7 +250,7 @@ def set_parser_arguments():
239250
parser.add_argument('-cn', action='store_true', default=False, dest='container', help='Print Containers')
240251
parser.add_argument('-d', action='store_true', default=False, dest='database', help='Print Database')
241252
parser.add_argument('-e', action='store_true', default=False, dest='email', help='Print EMail')
242-
parser.add_argument('-edge', action='store_true', default=False, dest='edge', help='Print Edge and DNS Services')
253+
parser.add_argument('-edge', action='store_true', default=False, dest='edge', help='Print Edge, DNS Services and WAAS policies')
243254
parser.add_argument('-f', action='store_true', default=False, dest='file', help='Print File Storage')
244255
parser.add_argument('-fun', action='store_true', default=False, dest='function', help='Print Functions')
245256
parser.add_argument('-i', action='store_true', default=False, dest='identity', help='Print Identity')

examples/showoci/showoci_data.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ def get_showoci_config(self, cmdline, start_time):
121121
'version': self.service.flags.showoci_version,
122122
'override_tenant_id': self.service.flags.filter_by_tenancy_id,
123123
'datetime': start_time,
124+
'machine': self.service.flags.machine,
125+
'python': self.service.flags.python,
124126
'cmdline': cmdline,
125127
'oci_sdk_version': self.service.get_oci_version()
126128
}
@@ -1907,6 +1909,8 @@ def __get_database_autonomous_databases(self, region_name, compartment):
19071909
'time_created': str(dbs['time_created'])[0:16],
19081910
'connection_strings': str(dbs['connection_strings']),
19091911
'sum_info': "Autonomous Database " + str(dbs['db_workload']) + " (OCPUs) - " + dbs['license_model'],
1912+
'sum_info_stopped': "Stopped Autonomous Database " + str(dbs['db_workload']) + " (Count) - " + dbs['license_model'],
1913+
'sum_info_count': "Autonomous Database " + str(dbs['db_workload']) + " (Count) - " + dbs['license_model'],
19101914
'sum_count': str(dbs['sum_count']),
19111915
'sum_info_storage': "Autonomous Database (TB)",
19121916
'sum_size_tb': str(dbs['data_storage_size_in_tbs']), 'backups': self.__get_database_autonomous_backups(dbs['backups']),
@@ -2565,6 +2569,7 @@ def __get_load_edge_main(self, region_name, compartment):
25652569
healthcheck_ping = self.service.search_multi_items(self.service.C_EDGE, self.service.C_EDGE_HEALTHCHECK_PING, 'region_name', region_name, 'compartment_id', compartment['id'])
25662570
dns_zone = self.service.search_multi_items(self.service.C_EDGE, self.service.C_EDGE_DNS_ZONE, 'region_name', region_name, 'compartment_id', compartment['id'])
25672571
dns_steering = self.service.search_multi_items(self.service.C_EDGE, self.service.C_EDGE_DNS_STEERING, 'region_name', region_name, 'compartment_id', compartment['id'])
2572+
waas_policies = self.service.search_multi_items(self.service.C_EDGE, self.service.C_EDGE_WAAS_POLICIES, 'region_name', region_name, 'compartment_id', compartment['id'])
25682573

25692574
data = {}
25702575
if len(healthcheck_http) > 0 or len(healthcheck_ping) > 0:
@@ -2576,6 +2581,9 @@ def __get_load_edge_main(self, region_name, compartment):
25762581
if dns_steering:
25772582
data['dns_steering'] = dns_steering
25782583

2584+
if waas_policies:
2585+
data['waas_policies'] = waas_policies
2586+
25792587
return data
25802588

25812589
except Exception as e:

0 commit comments

Comments
 (0)