Skip to content

Commit fc8a85e

Browse files
authored
Merge pull request #30 from oracle/release_2017-12-11
Releasing version 2.4.13
2 parents 880957d + e70f5bb commit fc8a85e

Some content is hidden

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

44 files changed

+14301
-15806
lines changed

CHANGELOG.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ All notable changes to this project will be documented in this file.
77
The format is based on `Keep a
88
Changelog <http://keepachangelog.com/>`__.
99

10+
2.4.13 - 2017-12-11
11+
--------------------
12+
Added
13+
~~~~~~~~~~
14+
* Support for Load Balancing Service operations ('oci lb')
15+
16+
* An example of creating a load balancer can be found a https://github.com/oracle/oci-cli/blob/master/scripts/create_load_balancer.sh
17+
18+
* Support for user managed boot volumes: 'oci bv boot-volume', 'oci compute instance launch --source-details', 'oci compute instance terminate --preserve-boot-volume'
19+
* Operations which create, update or delete resources with a lifecycle-state now support a --wait-for-state option which allows you to perform the action and then wait until the resource reaches a given state
20+
* Support for specifying --profile option through OCI_CLI_PROFILE environment variable
21+
22+
Changed
23+
~~~~~~~~~~
24+
* When listing audit events ('oci audit event list'), audit events can now have a 'response-payload' attribute which contains metadata of interest. For example, the OCID of a resource
25+
1026
2.4.12 - 2017-11-27
1127
-------------------
1228

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Jinja2==2.9.6
1212
jmespath==0.9.3
1313
ndg-httpsclient==0.4.2
1414
mock==2.0.0
15-
oci==1.3.10
15+
oci==1.3.11
1616
packaging==16.8
1717
pluggy==0.4.0
1818
py==1.4.32

scripts/create_load_balancer.sh

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
#!/bin/bash
2+
# This script provides an example of how to create a load balancer using the CLI. Two main ways to create a load balancer are shown:
3+
#
4+
# - Creating a load balancer by providing all options at create time (e.g. certificates, listeners, backend sets)
5+
# - We also show two sub-variants: providing each option as an individual parameter (e.g. --certificiates, --listeners) and how to provide a consolidated
6+
# set of options using --from-json
7+
# - Creating a load balancer by providing the minimum options at create time and then adding related resources (e.g. certificates, listeners, backend sets)
8+
# post-creation
9+
#
10+
# Requirements for running this script:
11+
# - OCI CLI v2.4.13 or later (you can check this by running oci --version)
12+
# - 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
13+
# which can't be wholly addressed by the --query option in the CLI
14+
# - OpenSSL (for certificate generation). This is not a strict requirement for normal CLI usage, just for this demo script
15+
# - demjson (http://deron.meranda.us/python/demjson/). This is not a strict requirement fpr normal CLI usage, it is just used to strip comments and explanatory notes from the example
16+
# input files which support this script
17+
18+
COMPARTMENT_ID="" # Your compartment OCID
19+
AVAILABILITY_DOMAIN_ONE="" # An availability domain, e.g. Uocm:IAD-AD-1
20+
AVAILABILITY_DOMAIN_TWO="" # An availability domain, but different to AVAILABILITY_DOMAIN_TWO, e.g. Uocm:IAD-AD-2
21+
22+
CREATED_VCN=$(oci network vcn create -c $COMPARTMENT_ID --display-name createLbExampleVcn --cidr-block 10.0.0.0/16 --dns-label createLbExample --wait-for-state AVAILABLE 2>/dev/null)
23+
VCN_ID=$(jq -r '.data.id' <<< "$CREATED_VCN")
24+
echo "VCN OCID: ${VCN_ID}"
25+
26+
FIRST_CREATED_SUBNET=$(oci network subnet create -c $COMPARTMENT_ID --availability-domain $AVAILABILITY_DOMAIN_ONE --display-name createLbSubnet --vcn-id $VCN_ID --dns-label subnetLb --cidr-block 10.0.0.0/24 --wait-for-state AVAILABLE 2>/dev/null)
27+
FIRST_SUBNET_ID=$(jq -r '.data.id' <<< "$FIRST_CREATED_SUBNET")
28+
echo "First Subnet OCID: $FIRST_SUBNET_ID"
29+
30+
SECOND_CREATED_SUBNET=$(oci network subnet create -c $COMPARTMENT_ID --availability-domain $AVAILABILITY_DOMAIN_TWO --display-name createLbSubnet2 --vcn-id $VCN_ID --dns-label subnetLbTwo --cidr-block 10.0.1.0/24 --wait-for-state AVAILABLE 2>/dev/null)
31+
SECOND_SUBNET_ID=$(jq -r '.data.id' <<< "$SECOND_CREATED_SUBNET")
32+
echo "Second Subnet OCID: $SECOND_SUBNET_ID"
33+
34+
# We need to specify a shape when creating a load balancer. Here we are just picking the first shape
35+
# we get from listing all the available shapes
36+
LB_SHAPE=$(oci lb shape list -c $COMPARTMENT_ID | jq -r '.data[0].name')
37+
echo "Load Balancer Shape: $LB_SHAPE"
38+
39+
# A function which creates a load balancer by providing all options at create time to the oci lb load-balancer create command. This command takes multiple complex parameters (complex
40+
# parameters are those where the CLI expects JSON to be provided as input). For ease of use, the complex parameter input will be passed in from a file rather than trying to specify
41+
# the strings on the command line
42+
#
43+
# This also provides each complex type as an individual option (e.g. --certificates, --listeners). It is also possible to provide these in a consolidated format, which is demonstrated
44+
# by the function create_lb_with_all_options_using_from_json
45+
function create_lb_with_all_options_as_individual_options() {
46+
# certificates_with_comments.json contains a description of the parameter. Since valid JSON cannot contain comments, we use jsonlint (which was installed
47+
# via our demjson dependency) to remove the comments and allow the CLI to use it.
48+
#
49+
# You should replace the values in certificates_with_comments.json with those appropriate for your use case (e.g. your own PEM-formatted strings)
50+
jsonlint -Sf scripts/create_load_balancer_example/certificates_with_comments.json > scripts/create_load_balancer_example/certificates.json
51+
52+
jsonlint -Sf scripts/create_load_balancer_example/backend_sets_with_comments.json > scripts/create_load_balancer_example/backend_sets.json
53+
jsonlint -Sf scripts/create_load_balancer_example/listeners_with_comments.json > scripts/create_load_balancer_example/listeners.json
54+
55+
# Subnets are passed as a JSON array where each entry is a subnet OCID. For example:
56+
#
57+
# ["ocid...", "ocid...", "ocid..."]
58+
#
59+
# Because we have these in variables already, we can pipe an array to a file and use that
60+
echo "[\"${FIRST_SUBNET_ID}\", \"${SECOND_SUBNET_ID}\"]" > scripts/create_load_balancer_example/subnets.json
61+
62+
# Note here in our create we use --certificates, --listeners etc. to pass in each complex type
63+
#
64+
# There is some implicit sequencing in that:
65+
# - The backend set information (--backend-sets) may need the name of the certificate bundle specified in --certificates
66+
# - The listener information (--listeners) needs the name of one of the backend sets in --backend-sets
67+
# - The listener information (--listeners) may need the name of the certificate bundle specified in --certificates
68+
#
69+
# So you need to take that into account when preparing your files for input
70+
CREATED_LB=$(oci lb load-balancer create -c $COMPARTMENT_ID --display-name exampleLb --shape-name $LB_SHAPE --subnet-ids file://scripts/create_load_balancer_example/subnets.json --certificates file://scripts/create_load_balancer_example/certificates.json --backend-sets file://scripts/create_load_balancer_example/backend_sets.json --listeners file://scripts/create_load_balancer_example/listeners.json)
71+
WORK_REQUEST_ID=$(jq -r '."opc-work-request-id"' <<< "$CREATED_LB")
72+
echo "Create Load Balancer Work Request ID: $WORK_REQUEST_ID"
73+
74+
# Creating a load balancer returns a work request. We can poll the work request to check when it completes. Once the work request
75+
# has completed, the load balancer is available
76+
WORK_REQUEST=$(oci lb work-request get --work-request-id $WORK_REQUEST_ID)
77+
WORK_REQUEST_STATUS=$(jq -r '.data."lifecycle-state"' <<< "$WORK_REQUEST")
78+
echo "Work request status: $WORK_REQUEST_STATUS"
79+
while [[ $WORK_REQUEST_STATUS != "SUCCEEDED" ]]
80+
do
81+
WORK_REQUEST=$(oci lb work-request get --work-request-id $WORK_REQUEST_ID)
82+
WORK_REQUEST_STATUS=$(jq -r '.data."lifecycle-state"' <<< "$WORK_REQUEST")
83+
echo "Work request status: $WORK_REQUEST_STATUS"
84+
sleep 60
85+
done
86+
87+
# The work request will have the OCID of the load balancer in it
88+
LB_ID=$(jq -r '.data."load-balancer-id"' <<< "$WORK_REQUEST")
89+
echo "Load Balancer OCID: $LB_ID"
90+
91+
# Print out information about the load balancer
92+
oci lb load-balancer get --load-balancer-id $LB_ID
93+
94+
# Delete the load balancer, and sleep a bit to make sure it has been deleted
95+
oci lb load-balancer delete --load-balancer-id $LB_ID --force
96+
sleep 120
97+
}
98+
99+
# We've seen in the create_lb_with_all_options_as_individual_options function that we can create a load balancer and provide complex parameters, such as --backend-sets,
100+
# as separate options. However, rather than specifying complex parameters individually, we can supply them in a consolidated format - in this case by passing it in
101+
# as a single file to the --from-json option.
102+
#
103+
# It is actually possible to not provide individual options to CLI commands at all and pass all parameters via --from-json, but for the purposes of this example we'll
104+
# just show passing in the complex parameters
105+
function create_lb_with_all_options_using_from_json() {
106+
jsonlint -Sf scripts/create_load_balancer_example/create_load_balancer_all_complex_params_with_comments.json > scripts/create_load_balancer_example/create_load_balancer_all_complex_params.json
107+
108+
echo "[\"${FIRST_SUBNET_ID}\", \"${SECOND_SUBNET_ID}\"]" > scripts/create_load_balancer_example/subnets.json
109+
110+
CREATED_LB=$(oci lb load-balancer create -c $COMPARTMENT_ID --display-name exampleLb --shape-name $LB_SHAPE --subnet-ids file://scripts/create_load_balancer_example/subnets.json --from-json file://scripts/create_load_balancer_example/create_load_balancer_all_complex_params.json)
111+
WORK_REQUEST_ID=$(jq -r '."opc-work-request-id"' <<< "$CREATED_LB")
112+
echo "Create Load Balancer Work Request ID: $WORK_REQUEST_ID"
113+
114+
# Creating a load balancer returns a work request. We can poll the work request to check when it completes. Once the work request
115+
# has completed, the load balancer is available
116+
WORK_REQUEST=$(oci lb work-request get --work-request-id $WORK_REQUEST_ID)
117+
WORK_REQUEST_STATUS=$(jq -r '.data."lifecycle-state"' <<< "$WORK_REQUEST")
118+
echo "Work request status: $WORK_REQUEST_STATUS"
119+
while [[ $WORK_REQUEST_STATUS != "SUCCEEDED" ]]
120+
do
121+
WORK_REQUEST=$(oci lb work-request get --work-request-id $WORK_REQUEST_ID)
122+
WORK_REQUEST_STATUS=$(jq -r '.data."lifecycle-state"' <<< "$WORK_REQUEST")
123+
echo "Work request status: $WORK_REQUEST_STATUS"
124+
sleep 60
125+
done
126+
127+
# The work request will have the OCID of the load balancer in it
128+
LB_ID=$(jq -r '.data."load-balancer-id"' <<< "$WORK_REQUEST")
129+
echo "Load Balancer OCID: $LB_ID"
130+
131+
# Print out information about the load balancer
132+
oci lb load-balancer get --load-balancer-id $LB_ID
133+
134+
# Delete the load balancer, and sleep a bit to make sure it has been deleted
135+
oci lb load-balancer delete --load-balancer-id $LB_ID --force
136+
sleep 120
137+
}
138+
139+
function create_lb_with_minimum_then_add_related_resources() {
140+
echo "[\"${FIRST_SUBNET_ID}\", \"${SECOND_SUBNET_ID}\"]" > scripts/create_load_balancer_example/subnets.json
141+
142+
# The minimum required information is the compartment, display name, load balancer shape, and subnets
143+
CREATED_LB=$(oci lb load-balancer create -c $COMPARTMENT_ID --display-name exampleLb --shape-name $LB_SHAPE --subnet-ids file://scripts/create_load_balancer_example/subnets.json)
144+
WORK_REQUEST_ID=$(jq -r '."opc-work-request-id"' <<< "$CREATED_LB")
145+
echo "Create Load Balancer Work Request ID: $WORK_REQUEST_ID"
146+
147+
WORK_REQUEST=$(oci lb work-request get --work-request-id $WORK_REQUEST_ID)
148+
WORK_REQUEST_STATUS=$(jq -r '.data."lifecycle-state"' <<< "$WORK_REQUEST")
149+
echo "Work request status: $WORK_REQUEST_STATUS"
150+
while [[ $WORK_REQUEST_STATUS != "SUCCEEDED" ]]
151+
do
152+
WORK_REQUEST=$(oci lb work-request get --work-request-id $WORK_REQUEST_ID)
153+
WORK_REQUEST_STATUS=$(jq -r '.data."lifecycle-state"' <<< "$WORK_REQUEST")
154+
echo "Work request status: $WORK_REQUEST_STATUS"
155+
sleep 60
156+
done
157+
158+
# Now that the load balancer is available, we can add certificates, listeners and backend sets. First
159+
# we'll need the load balancer's OCID so that we can use it in further commands. Remember that the OCID
160+
# can be obtained from the work request
161+
LB_ID=$(jq -r '.data."load-balancer-id"' <<< "$WORK_REQUEST")
162+
echo "Load Balancer OCID: $LB_ID"
163+
164+
# Generate a self-signed certificate to use as part of our requests
165+
openssl req -newkey rsa:2048 -nodes -sha256 -keyout key.pem -x509 -days 365 -out certificate.pem -subj "/C=US/ST=WA/L=Seattle/O=Test/CN=www.example.com"
166+
167+
# Here we add a certificate. Note that unlike providing it as part of the create operation, we specify the path to
168+
# the PEM files rather than providing the PEM-formatted strings themselves
169+
#
170+
# We can call the command multiple times to add multiple certificates
171+
oci lb certificate create --certificate-name my_cert_bundle --load-balancer-id $LB_ID --ca-certificate-file certificate.pem --private-key-file key.pem --public-certificate-file certificate.pem
172+
173+
# Here we create a backend set and then add backends to it. Note that if we specify a SSL certificate then it should match the name we specified
174+
# as "oci lb certificate create"
175+
oci lb backend-set create --load-balancer-id $LB_ID \
176+
--name backendSetName \
177+
--policy ROUND_ROBIN \
178+
--health-checker-protocol HTTP \
179+
--health-checker-return-code 200 \
180+
--health-checker-url-path /healthcheck \
181+
--health-checker-interval-in-ms 60000 \
182+
--session-persistence-cookie-name myCookie \
183+
--session-persistence-disable-fallback false \
184+
--ssl-certificate-name my_cert_bundle \
185+
--ssl-verify-depth 3 \
186+
--ssl-verify-peer-certificate false
187+
188+
# Now that we have our backend set, we can add backends to it by calling "oci lb backend create" multiple times
189+
oci lb backend create --load-balancer-id $LB_ID --backend-set-name backendSetName --ip-address 10.10.10.4 --port 80 --weight 3
190+
oci lb backend create --load-balancer-id $LB_ID --backend-set-name backendSetName --ip-address 10.10.10.5 --port 80 --weight 3
191+
192+
# Now that we have our certificates and backend set, we can add a listener. We need to specify a backend set which exists (e.g. the one we made)
193+
#
194+
# The valid values for --protocol can be found via "oci lb protocol list"
195+
#
196+
# If we specify a SSL certificate then it should match the name of a certificate we created via "oci lb certificate create"
197+
oci lb listener create --load-balancer-id $LB_ID \
198+
--default-backend-set-name backendSetName \
199+
--name myListener \
200+
--port 8080 \
201+
--protocol HTTP \
202+
--ssl-certificate-name my_cert_bundle \
203+
--ssl-verify-depth 3 \
204+
--ssl-verify-peer-certificate false
205+
206+
# Print out information about the load balancer
207+
oci lb load-balancer get --load-balancer-id $LB_ID
208+
209+
# Delete the load balancer, and sleep a bit to make sure it has been deleted
210+
oci lb load-balancer delete --load-balancer-id $LB_ID --force
211+
sleep 120
212+
}
213+
214+
create_lb_with_all_options_as_individual_options
215+
create_lb_with_all_options_using_from_json
216+
create_lb_with_minimum_then_add_related_resources
217+
218+
# Delete the subnets
219+
oci network subnet delete --subnet-id $FIRST_SUBNET_ID --force --wait-for-state TERMINATED
220+
oci network subnet delete --subnet-id $SECOND_SUBNET_ID --force --wait-for-state TERMINATED
221+
222+
# Delete the VCN
223+
oci network vcn delete --vcn-id $VCN_ID --force --wait-for-state TERMINATED

scripts/install/install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if ([System.Enum]::GetNames('System.Net.SecurityProtocolType') -Contains 'Tls12'
2626
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12';
2727
}
2828

29-
$PythonInstallScriptUrl = "https://raw.githubusercontent.com/oracle/oci-cli/v2.4.11/scripts/install/install.py"
29+
$PythonInstallScriptUrl = "https://raw.githubusercontent.com/oracle/oci-cli/v2.4.13/scripts/install/install.py"
3030
$PythonVersionToInstall = "3.6.2" # version of Python to install if none exists
3131
$MinValidPython2Version = "2.7.5" # minimum required version of Python 2 on system
3232
$MinValidPython3Version = "3.5.0" # minimum required version of Python 3 on system

scripts/install/install.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def get_install_dir():
178178
create_dir(install_dir)
179179
if os.listdir(install_dir):
180180
print_status("'{}' is not empty and may contain a previous installation.".format(install_dir))
181-
ans_yes = prompt_y_n('Remove this directory?', 'y')
181+
ans_yes = prompt_y_n('Remove this directory?', 'n')
182182
if ans_yes:
183183
try:
184184
shutil.rmtree(install_dir)
@@ -194,7 +194,7 @@ def get_install_dir():
194194
return install_dir
195195

196196

197-
def get_exec_dir():
197+
def get_exec_dir(install_dir):
198198
exec_dir = None
199199
while not exec_dir:
200200
prompt_message = "In what directory would you like to place the '{}' executable?".format(OCI_EXECUTABLE_NAME)
@@ -203,6 +203,13 @@ def get_exec_dir():
203203
if ' ' in exec_dir:
204204
print_status("The executable directory '{}' cannot contain spaces.".format(exec_dir))
205205
exec_dir = None
206+
207+
install_dir_bin_folder = 'Scripts' if is_windows() else 'bin'
208+
install_bin_dir = os.path.join(install_dir, install_dir_bin_folder)
209+
if exec_dir == install_bin_dir:
210+
print_status("The executable directory cannot be the same as the {} directory of the virtualenv. Adding this directory to your PATH could interfere with your system python installation.".format(install_dir_bin_folder))
211+
exec_dir = None
212+
206213
create_dir(exec_dir)
207214
print_status("The executable will be in '{}'.".format(exec_dir))
208215
return exec_dir
@@ -433,7 +440,7 @@ def main():
433440
verify_native_dependencies()
434441
tmp_dir = create_tmp_dir()
435442
install_dir = get_install_dir()
436-
exec_dir = get_exec_dir()
443+
exec_dir = get_exec_dir(install_dir)
437444
oci_exec_path = os.path.join(exec_dir, OCI_EXECUTABLE_NAME)
438445
bmcs_exec_path = os.path.join(exec_dir, BMCS_EXECUTABLE_NAME)
439446
verify_install_dir_exec_path_conflict(install_dir, oci_exec_path)

scripts/install/install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Bash script to install the Oracle Cloud Infrastructure CLI
55
# Example invocation: curl -L "https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh" | bash
66
#
7-
INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/oracle/oci-cli/v2.4.11/scripts/install/install.py"
7+
INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/oracle/oci-cli/v2.4.13/scripts/install/install.py"
88
_TTY=/dev/tty
99

1010
install_script=$(mktemp -t oci_cli_install_tmp_XXXX) || exit
@@ -30,7 +30,7 @@ command -v python >/dev/null 2>&1
3030
if [ $? -eq 0 ]; then
3131
# python is installed so check if the version is valid
3232
# this python command returns an exit code of 0 if the system version is sufficient, and 1 if it is not
33-
python -c "import sys; v = sys.version_info; valid = v >= (2, 7, 5) if v.major == 2 else v >= (3, 5, 0); sys.exit(0) if valid else sys.exit(1)"
33+
python -c "import sys; v = sys.version_info; valid = v >= (2, 7, 5) if v[0] == 2 else v >= (3, 5, 0); sys.exit(0) if valid else sys.exit(1)"
3434
if [ $? -eq 0 ]; then
3535
# if python is installed and meets the version requirements then we dont need to install it
3636
need_to_install_python=false

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def open_relative(*path):
3030

3131

3232
requires = [
33-
'oci==1.3.10',
33+
'oci==1.3.11',
3434
'arrow==0.10.0',
3535
'certifi',
3636
'click==6.7',

0 commit comments

Comments
 (0)