-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from oracle/release_2018-10-04
Releasing version 2.4.34
- Loading branch information
Showing
37 changed files
with
3,311 additions
and
506 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
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
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,41 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. | ||
# This script provides an example of how to copy an object in object storage. | ||
# | ||
# Requirements for running this script: | ||
# - OCI CLI v2.4.33 or later (you can check this by running oci --version) | ||
# - jq (https://stedolan.github.io/jq/) for JSON querying and manipulation of CLI output. This may be a useful utility in general | ||
# and may help cater to scenarios which can't be wholly addressed by the --query option in the CLI | ||
set -e | ||
|
||
COMPARTMENT_ID="" | ||
SOURCE_BUCKET="" | ||
SOURCE_OBJECT="" | ||
DEST_BUCKET="" | ||
DEST_OBJECT="" | ||
|
||
echo "Fetching namespace." | ||
NAMESPACE=$(oci os ns get | jq -r .data) | ||
echo "Using namespace '$NAMESPACE'." | ||
|
||
WORK_REQUEST_ID=$(oci os object copy --bucket-name $SOURCE_BUCKET --source-object-name $SOURCE_OBJECT --destination-region us-phoenix-1 --destination-namespace $NAMESPACE --destination-bucket $DEST_BUCKET --destination-object-name $DEST_OBJECT | jq -r '."opc-work-request-id"') | ||
echo "Work request ID is $WORK_REQUEST_ID." | ||
|
||
while true; do | ||
|
||
WORK_REQUEST_STATE=$(oci os work-request get --work-request-id $WORK_REQUEST_ID | jq -r .data.status) | ||
if [ "$WORK_REQUEST_STATE" == "COMPLETED" ]; then | ||
echo "Copy has completed." | ||
break | ||
elif [ "$WORK_REQUEST_STATE" == "FAILED" ]; then | ||
echo "Copy has failed." | ||
break | ||
elif [ "$WORK_REQUEST_STATE" == "CANCELED" ]; then | ||
echo "Copy has been canceled." | ||
break | ||
else | ||
echo "Copy is still in $WORK_REQUEST_STATE state." | ||
sleep 5 | ||
fi | ||
|
||
done |
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,38 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. | ||
# This script provides an example of how use the consumer listings CLI in terms of: | ||
# - Retrieving a listing | ||
# - Retrieving at most 8 resource versions available for the listing | ||
# | ||
# It displays a short summary of the listing and resource versions of a listing. | ||
# | ||
# For more help with specific consumer listing commands with, see: | ||
# oci compute pic -h | ||
# | ||
# Requirements for running this script: | ||
# - OCI CLI v2.4.33 or later (you can check this by running oci --version) | ||
# - jq (https://stedolan.github.io/jq/) for JSON querying and manipulation of CLI output. This may be a useful utility in general | ||
# and may help cater to scenarios which can't be wholly addressed by the --query option in the CLI | ||
|
||
set -e | ||
|
||
echo "Fetching data from pic catalog listing" | ||
|
||
# Fetch a listing and get all the relevant fields | ||
pic_list=$(oci compute pic listing list --limit 1 --sort-order ASC 2>/dev/null) | ||
listing_id=$(printf "%s" $pic_list | jq -r '.data[0]."listing-id"') | ||
display_name=$(printf "%s" $pic_list | jq -r '.data[0]."display-name"') | ||
publisher_name=$(printf "%s" $pic_list | jq -r '.data[0]."publisher-name"') | ||
summary=$(printf "%s" $pic_list | jq -r '.data[0]."summary"') | ||
|
||
# Get the last 8 resource versions sorted by publish date | ||
echo "Fetching data from pic catalog listing version" | ||
resource_version_list=$(oci compute pic version list --listing-id $listing_id --sort-order ASC --limit 8) | ||
resource_versions=$(printf "%s" $resource_version_list | jq '.data[] | ."listing-resource-version"' | paste -s -d, -) | ||
|
||
echo "" | ||
echo "Listing Id : $listing_id" | ||
echo "Display Name : $display_name" | ||
echo "Publisher Name : $publisher_name" | ||
echo "Summary : $summary" | ||
echo "Versions : [$resource_versions]" |
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,38 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. | ||
# This script provides an example of how use the consumer listings CLI in terms of: | ||
# - Retrieving a listing | ||
# - Retrieving a resource versions available for the listing | ||
# - Creating a subscription for the listing and version | ||
# | ||
# It displays a short summary of the listing and resource versions of a listing. | ||
# | ||
# For more help with specific consumer listing commands with, see: | ||
# oci compute pic -h | ||
# | ||
# Requirements for running this script: | ||
# - OCI CLI v2.4.33 or later (you can check this by running oci --version) | ||
# - jq (https://stedolan.github.io/jq/) for JSON querying and manipulation of CLI output. This may be a useful utility in general | ||
# and may help cater to scenarios which can't be wholly addressed by the --query option in the CLI | ||
|
||
set -e | ||
|
||
# TODO: Fill in your compartment-id | ||
compartment_id={COMPARTMENT-ID} | ||
|
||
echo 'Fetching listing id' | ||
listing_id=$(oci compute pic listing list --limit 1 --sort-order ASC 2>/dev/null | jq -r '.data[0]."listing-id"') | ||
|
||
echo "Fetching version for the listing: $listing_id" | ||
resource_version=$(oci compute pic version list --listing-id $listing_id --limit 1 | jq -r '.data[0]."listing-resource-version"') | ||
|
||
echo "Fetching agreements for listing:$listing_id and version:$resource_version" | ||
agreements=$(oci compute pic agreements get --listing-id "$listing_id" --resource-version "$resource_version") | ||
signature=$(printf "%s" $agreements | jq -r '.data."signature"') | ||
time_ret=$(printf "%s" $agreements | jq -r '.data."time-retrieved"' | sed -e 's/000+00:00/Z/') | ||
eula_link=$(printf "%s" $agreements | jq -r '.data."eula-link"') | ||
oracle_tou_link=$(printf "%s" $agreements | jq -r '.data."oracle-terms-of-use-link"') | ||
|
||
echo 'Creating subscription' | ||
oci compute pic subscription create --compartment-id "$compartment_id" --listing-id "$listing_id" --resource-version "$resource_version" \ | ||
--signature "$signature" --oracle-tou-link "$oracle_tou_link" --time-retrieved "$time_ret" --eula-link "$eula_link" |
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
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,79 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. | ||
# This script provides an example of how to create an object lifecycle policy on a bucket. | ||
# | ||
# Requirements for running this script: | ||
# - OCI CLI v2.4.33 or later (you can check this by running oci --version) | ||
# - jq (https://stedolan.github.io/jq/) for JSON querying and manipulation of CLI output. This may be a useful utility in general | ||
# and may help cater to scenarios which can't be wholly addressed by the --query option in the CLI | ||
set -e | ||
|
||
COMPARTMENT_ID="" # Your compartment OCID | ||
BUCKET_NAME="" # Bucket to apply the object lifecycle policy to | ||
|
||
if [[ -z $COMPARTMENT_ID || -z $BUCKET_NAME ]]; then | ||
echo "Arguments required. Set arguments at top of script." | ||
exit 1 | ||
fi | ||
|
||
echo "Fetching namespace." | ||
NAMESPACE_NAME=$(oci os ns get | jq -r .data) | ||
if [[ -z $NAMESPACE_NAME ]]; then | ||
echo "Couldn't read namespace. Check your credentials." | ||
exit 1 | ||
fi | ||
echo "Using namespace '$NAMESPACE_NAME'." | ||
|
||
echo "Creating bucket." | ||
oci os bucket create --namespace-name $NAMESPACE_NAME --name $BUCKET_NAME --compartment-id $COMPARTMENT_ID --storage-tier Standard | ||
echo "Created bucket." | ||
|
||
# An object lifecycle policy's rules needs to be uploaded as a JSON array. Each element in the array is a rule with this structure: | ||
# | ||
# { | ||
# "action": "string", | ||
# "isEnabled": true, | ||
# "name": "string", | ||
# "objectNameFilter": { | ||
# "inclusionPrefixes": [ | ||
# "string", | ||
# "string" | ||
# ] | ||
# }, | ||
# "timeAmount": 0, | ||
# "timeUnit": "string" | ||
# } | ||
# | ||
# (Use `oci os object-lifecycle-policy put --generate-param-json-input items` to generate the structure of the rule array.) | ||
# | ||
# An explanation of each element: | ||
# - action: The action to take on objects matching this rule. Valid values are "ARCHIVE" and "DELETE" | ||
# - isEnabled: A boolean that can be used to temporarily disable a rule. | ||
# - name: A user-friendly name for the rule. This element has no effect on the rule's execution. | ||
# - objectNameFilter: An object that allows filtering object names. A rule with a missing or empty filter will match all objects. | ||
# - inclusionPrefixes: An array of string object name prefixes that will match desired objects in the bucket. For example, "/tmp/". | ||
# - timeAmount: An integer amount of time, specified in terms of the timeUnit below. For example, 90 DAYS. | ||
# - timeUnit: The unit of time to interpret timeAmount in terms of. Valid values are "DAYS" and "YEARS". | ||
# | ||
# A full lifecycle policy is an array of these rules. You may, for example, have one rule that archives objects after 30 days, and | ||
# another that deletes objects after 120 days. If an object matches both of these rules, it will be deleted. | ||
# | ||
# A valid example lifecycle policy exists in write_object_lifecycle_policy_example/object_lifecycle_policy.json | ||
# It will archive objects whose names begin with "/tmp/" when they reach one day old (rounded to midnight UTC), and all others after | ||
# 30 days. | ||
echo "Writing lifecycle policy." | ||
oci os object-lifecycle-policy put --namespace $NAMESPACE_NAME --bucket-name $BUCKET_NAME --items file://scripts/examples/write_object_lifecycle_policy_example/object_lifecycle_policy.json | ||
echo "Object lifecycle policy created successfully." | ||
|
||
echo "Retrieving lifecycle policy." | ||
oci os object-lifecycle-policy get --namespace $NAMESPACE_NAME --bucket-name $BUCKET_NAME | ||
echo "Retrieved lifecycle policy." | ||
|
||
# Overwriting or deleting a lifecycle policy immediately cancels any in-progress execution of the old policy. | ||
echo "Deleting lifecycle policy." | ||
oci os object-lifecycle-policy delete --namespace $NAMESPACE_NAME --bucket-name $BUCKET_NAME | ||
echo "Deleted lifecycle policy." | ||
|
||
echo "Deleting bucket." | ||
oci os bucket delete --namespace $NAMESPACE_NAME --bucket-name $BUCKET_NAME | ||
echo "Deleted bucket." |
21 changes: 21 additions & 0 deletions
21
scripts/examples/write_object_lifecycle_policy_example/object_lifecycle_policy.json
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,21 @@ | ||
[ | ||
{ | ||
"action": "ARCHIVE", | ||
"isEnabled": true, | ||
"name": "archive-all-objects-after-30-days", | ||
"timeAmount": 30, | ||
"timeUnit": "DAYS" | ||
}, | ||
{ | ||
"action": "ARCHIVE", | ||
"isEnabled": true, | ||
"name": "archive-tmp-objects-after-1-day", | ||
"objectNameFilter": { | ||
"inclusionPrefixes": [ | ||
"/tmp/" | ||
] | ||
}, | ||
"timeAmount": 1, | ||
"timeUnit": "DAYS" | ||
} | ||
] |
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.