-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Releasing version 2.4.44
- Loading branch information
Showing
44 changed files
with
11,372 additions
and
240 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,88 @@ | ||
#!/bin/bash | ||
# This script provides a basic example of how to use the Traffic Management | ||
# feature of the DNS service in the CLI. The variables at the beginning of the | ||
# script must be specified accordingly: | ||
# | ||
# * COMPARTMENT_ID: The first argument is the OCID of the compartment where we'll create a DNS zone | ||
# * DNS_ZONE_NAME: The second is the name of the DNS zone to create (e.g. my-example-zone.com) | ||
# * STEERING_POLICY_NAME: The third is the name of the Steering Policy (e.g. "Example Load Balance Policy") | ||
# * DOMAIN_NAME: The fourth is the domain name within the zone to attach the policy to. The domain must be within the zone. (e.g. www.my-example-zone.com) | ||
# | ||
# Requirements for running this script: | ||
# - OCI CLI v2.4.40 or later (you can check this by running oci --version) | ||
# - jsonlint (required for converting commented JSON files to uncommented) | ||
|
||
set -e | ||
|
||
COMPARTMENT_ID="" | ||
DNS_ZONE_NAME="" | ||
STEERING_POLICY_NAME="" | ||
DOMAIN_NAME="" | ||
|
||
BORDER="==========================================" | ||
|
||
function print_header() { | ||
echo $BORDER | ||
echo $1 | ||
echo $BORDER | ||
} | ||
|
||
echo "Creating DNS zone: $DNS_ZONE_NAME" | ||
ZONE_ID=$(oci dns zone create -c $COMPARTMENT_ID --zone-type PRIMARY --name $DNS_ZONE_NAME --raw-output --query 'data.id') | ||
echo "Zone ID: $ZONE_ID" | ||
|
||
# We will create a Steering Policy that is configured to load balance responses to DNS queries for A | ||
# records across 3 servers with different weights. If you look at the file | ||
# scripts/examples/dns_traffic_management_example/load_balance_answers_with_comments.json you'll see | ||
# that we have 3 answers of rtype "A" listed. Note that the third answer has "isDisabled" set to | ||
# "true". | ||
# | ||
# The Steering Policy has rules defined in | ||
# scripts/examples/dns_traffic_management_example/load_balance_rules_with_comments.json: | ||
# | ||
# 1. FILTER rule: Used to remove manually disabled answers (like the third answer in our example). | ||
# | ||
# 2. WEIGHTED rule: Used to randomly shuffle the answers with the weight values assigned to each | ||
# answer by name. A higher weight value will increase the probability of an answer being returned | ||
# first in the list of answers. | ||
# | ||
# 3. LIMIT rule: Used to remove answers from the list until the number of answers left is less than | ||
# or equal to the value defined in "defaultCount". For example, this means that we will only | ||
# return 1 answer when we're done processing the policy. | ||
echo "Creating a Traffic Management Steering Policy for load balancing" | ||
|
||
# Use jsonlint to generate comment free JSON files since real JSON files cannot contains comments. | ||
jsonlint -Sf scripts/examples/dns_traffic_management_example/load_balance_answers_with_comments.json > \ | ||
scripts/examples/dns_traffic_management_example/load_balance_answers.json | ||
jsonlint -Sf scripts/examples/dns_traffic_management_example/load_balance_rules_with_comments.json > \ | ||
scripts/examples/dns_traffic_management_example/load_balance_rules.json | ||
|
||
POLICY_ID=$(oci dns steering-policy create -c $COMPARTMENT_ID --display-name "$STEERING_POLICY_NAME" \ | ||
--template LOAD_BALANCE --ttl 30 \ | ||
--answers file://scripts/examples/dns_traffic_management_example/load_balance_answers.json \ | ||
--rules file://scripts/examples/dns_traffic_management_example/load_balance_rules.json \ | ||
--raw-output --query 'data.id') | ||
echo "Steering Policy ID: $POLICY_ID" | ||
|
||
# After we have a Steering Policy we have to create a Steering Policy Attachment to apply the policy | ||
# to a domain within a zone. | ||
echo "Attaching Steering Policy to domain: $DOMAIN_NAME" | ||
ATTACHMENT_ID=$(oci dns steering-policy-attachment create --steering-policy-id $POLICY_ID --zone-id $ZONE_ID \ | ||
--domain-name "$DOMAIN_NAME" \ | ||
--raw-output --query 'data.id') | ||
echo "Attachment ID: $ATTACHMENT_ID" | ||
|
||
# At this point the policy has been applied to the specified domain and answers to DNS queries for | ||
# A records at that domain will be computed using the policy. | ||
|
||
# Clean up all the resources we created. | ||
echo "Deleting Steering Policy Attachment: $ATTACHMENT_ID" | ||
oci dns steering-policy-attachment delete --steering-policy-attachment-id $ATTACHMENT_ID --force | ||
|
||
echo "Deleting Steering Policy: $POLICY_ID" | ||
oci dns steering-policy delete --steering-policy-id $POLICY_ID --force | ||
|
||
echo "Deleting DNS zone: $DNS_ZONE_NAME" | ||
oci dns zone delete --zone-name-or-id $ZONE_ID --force | ||
|
||
echo "SUCCESS" |
22 changes: 22 additions & 0 deletions
22
scripts/examples/dns_traffic_management_example/load_balance_answers_with_comments.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,22 @@ | ||
[ | ||
// The first answer is an A record that points to the IPv4 address 1.2.3.4 | ||
{ | ||
"name": "Server 1", | ||
"rtype": "A", | ||
"rdata": "1.2.3.4" | ||
}, | ||
// The second answer is an A record that points to the IPv4 address 2.3.4.5 | ||
{ | ||
"name": "Server 2", | ||
"rtype": "A", | ||
"rdata": "2.3.4.5" | ||
}, | ||
// The third answer is an A record that points to the IPv4 address 3.4.5.6, but it is manually | ||
// disabled. | ||
{ | ||
"name": "Server 1", | ||
"rtype": "A", | ||
"rdata": "3.4.5.6", | ||
"isDisabled": true | ||
} | ||
] |
58 changes: 58 additions & 0 deletions
58
scripts/examples/dns_traffic_management_example/load_balance_rules_with_comments.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,58 @@ | ||
[ | ||
{ | ||
/* | ||
* The first rule in a LOAD_BALANCE policy template is a FILTER rule that only keeps answers | ||
* that do not have their isDisabled property set to true. Answers without an isDisable property | ||
* defined are kept. | ||
*/ | ||
"ruleType": "FILTER", | ||
"defaultAnswerData": [ | ||
{ | ||
"answerCondition": "answer.isDisabled != true", | ||
"shouldKeep": true | ||
} | ||
] | ||
}, | ||
/* | ||
* If we need to remove answers for unhealthy hosts then we would define a health check monitor | ||
* for the policy using the healthCheckMonitorId property in the steering policy details and the | ||
* next rule would be a HEALTH rule: | ||
* { | ||
* "ruleType": "HEALTH" | ||
* }, | ||
*/ | ||
{ | ||
/* | ||
* The next rule in a LOAD_BALANCE policy template is a WEIGHTED rule where we define the | ||
* weights for each answer by the answer's name property to determine how often an answer will | ||
* be at the beginning of the list of answers in response to a DNS query. This rule is the main | ||
* point of a LOAD_BALANCE policy. | ||
* | ||
* In this example, we want to return Server 1 first in the list three times as often as Server | ||
* 2. | ||
*/ | ||
"ruleType": "WEIGHTED", | ||
"defaultAnswerData": [ | ||
{ | ||
"answerCondition": "answer.name == 'Server 1'", | ||
"value": 75 | ||
}, | ||
{ | ||
"answerCondition": "answer.name == 'Server 2'", | ||
"value": 25 | ||
}, | ||
{ | ||
"answerCondition": "answer.name == 'Server 3'", | ||
"value": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
/* | ||
* The final rule in a LOAD_BALANCE policy template is a LIMIT rule that limits the number of | ||
* answers returned in the response to a DNS query. | ||
*/ | ||
"ruleType": "LIMIT", | ||
"defaultCount": 1 | ||
} | ||
] |
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 |
---|---|---|
@@ -1,36 +1,54 @@ | ||
#!/bin/bash | ||
# This script provides a basic example of how to use the Email Service in the Python SDK. This script accepts two | ||
# will demonstrate: | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. | ||
# This script provides a basic example of how to use the Email Service in the CLI. | ||
# It will demonstrate: | ||
# | ||
# * Creating, retrieving, listing and deleting email senders | ||
# * Creating, retrieving, listing and deleting email suppressions | ||
# * Obtaining SMTP credentials for your IAM user so that you can send emails. | ||
# See https://docs.us-phoenix-1.oraclecloud.com/Content/Email/Tasks/configuresmtpconnection.htm for more | ||
# information on sending emails | ||
# * Creating, retrieving, updating, listing, and deleting email senders | ||
# * Creating, retrieving, listing, and deleting email suppressions | ||
# * Creating, retrieving, listing, and deleting SMTP credentials | ||
# See https://docs.cloud.oracle.com/iaas/Content/Email/Tasks/configuresmtpconnection.htm for more | ||
# information on sending emails with your IAM user | ||
# | ||
# The following three variables must be populated at the top of this script: | ||
# The following three variables must be populated from the environment: | ||
# | ||
# * The tenancy ID where the suppressions will be created | ||
# * The compartment ID where email senders will be created | ||
# * The User ID to create the SMTP credentials for | ||
# * The address of the email sender | ||
# * The address of the email suppression | ||
# * TENANCY_ID: The tenancy ID where the suppressions will be created | ||
# * COMPARTMENT_ID: The compartment ID where email senders will be created | ||
# * USER_ID: The User ID to create the SMTP credentials for | ||
# | ||
# Note that email senders are created in the compartment which you specify, but the suppressions are always created at the tenancy | ||
# level. | ||
# This script will create and delete these resources: | ||
# | ||
# * SENDER_EMAIL_ADDRESS: The address of the approved sender | ||
# * SUPPRESSION_EMAIL_ADDRESS: The address of the email suppression | ||
# * an SMTP credential | ||
# | ||
# Note that email senders are created in the compartment which you specify, but suppressions | ||
# are always created at the tenancy level. | ||
# | ||
# Requirements for running this script: | ||
# - OCI CLI v2.4.19 or later (you can check this by running oci --version) | ||
# - jq (https://stedolan.github.io/jq/) for JSON querying 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 | ||
# - OCI CLI v2.4.42 or later (you can check this by running oci --version) | ||
# - region set in the ~/.oci/config DEFAULT profile | ||
# - jq (https://stedolan.github.io/jq/) for JSON querying of CLI output. This useful utility may also | ||
# be used to help cater to scenarios which can't be wholly addressed by the --query option in the CLI | ||
|
||
set -e | ||
|
||
TENANCY_ID="" | ||
COMPARTMENT_ID="" | ||
USER_ID="" | ||
SENDER_EMAIL_ADDRESS="[email protected]" | ||
SUPPRESSION_EMAIL_ADDRESS="[email protected]" | ||
if [ "${TENANCY_ID}" == "" ]; then | ||
echo $0: "TENANCY_ID must be defined in the environment" | ||
exit 1 | ||
fi | ||
|
||
if [ "${COMPARTMENT_ID}" == "" ]; then | ||
echo $0: "COMPARTMENT_ID must be defined in the environment" | ||
exit 1 | ||
fi | ||
|
||
if [ "${USER_ID}" == "" ]; then | ||
echo $0: "USER_ID must be defined in the environment" | ||
exit 1 | ||
fi | ||
|
||
readonly SENDER_EMAIL_ADDRESS="cli-example-sender-email-${RANDOM}@oracle.com" | ||
readonly SUPPRESSION_EMAIL_ADDRESS="cli-example-suppression-email-${RANDOM}@oracle.com" | ||
|
||
BORDER="==========================================" | ||
|
||
|
@@ -40,27 +58,40 @@ function print_header() { | |
echo $BORDER | ||
} | ||
|
||
print_header "Sender Operations" | ||
print_header "Approved Sender Operations" | ||
echo "Creating sender and waiting for it to become active" | ||
SENDER_ID=$(oci email sender create -c $COMPARTMENT_ID --email-address $SENDER_EMAIL_ADDRESS --wait-for-state ACTIVE --query 'data.id' --raw-output 2>/dev/null) | ||
echo "Getting sender" | ||
oci email sender get --sender-id $SENDER_ID | ||
echo "Updating sender" | ||
oci email sender update --sender-id $SENDER_ID --freeform-tags '{"Department": "Finance"}' --force | ||
echo "Listing senders" | ||
oci email sender list -c $COMPARTMENT_ID --all | ||
echo "Deleting sender" | ||
oci email sender delete --sender-id $SENDER_ID --force | ||
|
||
print_header "Suppression Operations" | ||
echo "Creating suppression" | ||
SUPPRESSION_ID=$(oci email suppression create -c $TENANCY_ID --email-address $SUPPRESSION_EMAIL_ADDRESS --query 'data.id' --raw-output) | ||
echo "Getting suppression" | ||
oci email suppression get --suppression-id $SUPPRESSION_ID | ||
oci email suppression list -c $TENANCY_ID --email-address $SUPPRESSION_EMAIL_ADDRESS --time-created-greater-than-or-equal-to 2018-03-10T00:00:00Z | ||
echo "Listing suppressions" | ||
oci email suppression list -c $TENANCY_ID --email-address $SUPPRESSION_EMAIL_ADDRESS --time-created-greater-than-or-equal-to 2019-01-10T00:00:00Z | ||
echo "Deleting suppression" | ||
oci email suppression delete --suppression-id $SUPPRESSION_ID --force | ||
|
||
print_header "SMTP Credential operations" | ||
print_header "SMTP Credential Operations" | ||
echo "Creating SMTP credential" | ||
SMTP_CREDENTIAL=$(oci iam smtp-credential create --user-id $USER_ID --description 'Example SMTP credential') | ||
SMTP_CREDENTIAL_ID=$(jq -r '.data.id' <<< "$SMTP_CREDENTIAL") | ||
SMTP_CREDENTIAL_USERNAME=$(jq -r '.data.username' <<< "$SMTP_CREDENTIAL") | ||
SMTP_CREDENTIAL_PASSWORD=$(jq -r '.data.password' <<< "$SMTP_CREDENTIAL") | ||
# The 'create' call is the only time the password for the credential will be returned | ||
echo "SMTP Credential username: $SMTP_CREDENTIAL_USERNAME" | ||
echo "SMTP Credential password: $SMTP_CREDENTIAL_PASSWORD" | ||
echo "Listing SMTP credentials" | ||
oci iam smtp-credential list --user-id $USER_ID | ||
echo "Deleting SMTP credential" | ||
oci iam smtp-credential delete --user-id $USER_ID --smtp-credential-id $SMTP_CREDENTIAL_ID --force | ||
|
||
echo "Success!" | ||
echo "Complete." |
Oops, something went wrong.