Skip to content

Commit

Permalink
Merge branch 'release-1.9.11'
Browse files Browse the repository at this point in the history
* release-1.9.11:
  Bumping version to 1.9.11
  Rename traffic policy version arguments to prevent shadowing.
  Updating changelog
  Update on feedback
  Change value for blocking socket to 0
  Use session's default config for setting timeouts
  link to glacier initiate-job from upload-archive
  Add the ability to turnoff timeouts
  Add --cli-connect-timeout as parameter
  • Loading branch information
AWS committed Dec 4, 2015
2 parents 29f27b4 + d2070d9 commit 33a68f9
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 19 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
CHANGELOG
=========

1.9.11
======

* feature:``aws rds``: Added support for specifying port number.
* feature:``aws ds``: Added support for Microsoft ActiveDirctory.
* feature:``aws route53``: Added support for TrafficFlow, a new
management and modeling layer for Route53.
* feature:Timeouts: Added additonal options for configuring socket timeouts.


1.9.10
======

Expand Down
2 changes: 1 addition & 1 deletion awscli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""
import os

__version__ = '1.9.10'
__version__ = '1.9.11'

#
# Get our data path to be added to botocore's search path
Expand Down
8 changes: 1 addition & 7 deletions awscli/clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from botocore.compat import copy_kwargs, OrderedDict
from botocore.exceptions import NoCredentialsError
from botocore.exceptions import NoRegionError
from botocore.client import Config

from awscli import EnvironmentVariables, __version__
from awscli.formatter import get_formatter
Expand Down Expand Up @@ -658,15 +657,10 @@ def invoke(self, service_name, operation_name, parameters, parsed_globals):
value is returned.
"""
if parsed_globals.read_timeout is not None:
config = Config(read_timeout=parsed_globals.read_timeout)
else:
config = Config()
client = self._session.create_client(
service_name, region_name=parsed_globals.region,
endpoint_url=parsed_globals.endpoint_url,
verify=parsed_globals.verify_ssl,
config=config)
verify=parsed_globals.verify_ssl)
py_operation_name = xform_name(operation_name)
if client.can_paginate(py_operation_name) and parsed_globals.paginate:
paginator = client.get_paginator(py_operation_name)
Expand Down
3 changes: 3 additions & 0 deletions awscli/customizations/argrename.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
'codepipeline.get-pipeline.version': 'pipeline-version',
'codepipeline.create-custom-action-type.version': 'action-version',
'codepipeline.delete-custom-action-type.version': 'action-version',
'route53.delete-traffic-policy.version': 'traffic-policy-version',
'route53.get-traffic-policy.version': 'traffic-policy-version',
'route53.update-traffic-policy-comment.version': 'traffic-policy-version'
}

# Same format as ARGUMENT_RENAMES, but instead of renaming the arguments,
Expand Down
32 changes: 29 additions & 3 deletions awscli/customizations/globalargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import sys
import os

from botocore.client import Config
from botocore.endpoint import DEFAULT_TIMEOUT
from botocore.handlers import disable_signing
import jmespath

Expand All @@ -24,6 +26,7 @@ def register_parse_global_args(cli):
cli.register('top-level-args-parsed', no_sign_request)
cli.register('top-level-args-parsed', resolve_verify_ssl)
cli.register('top-level-args-parsed', resolve_cli_read_timeout)
cli.register('top-level-args-parsed', resolve_cli_connect_timeout)


def resolve_types(parsed_args, **kwargs):
Expand Down Expand Up @@ -80,9 +83,32 @@ def no_sign_request(parsed_args, session, **kwargs):
session.register('choose-signer', disable_signing)


def resolve_cli_connect_timeout(parsed_args, session, **kwargs):
arg_name = 'connect_timeout'
_resolve_timeout(session, parsed_args, arg_name)


def resolve_cli_read_timeout(parsed_args, session, **kwargs):
arg_name = 'read_timeout'
arg_value = getattr(parsed_args, arg_name, None)
_resolve_timeout(session, parsed_args, arg_name)

if arg_value is not None:
setattr(parsed_args, arg_name, int(arg_value))

def _resolve_timeout(session, parsed_args, arg_name):
arg_value = getattr(parsed_args, arg_name, None)
if arg_value is None:
arg_value = DEFAULT_TIMEOUT
arg_value = int(arg_value)
if arg_value == 0:
arg_value = None
setattr(parsed_args, arg_name, arg_value)
# Update in the default client config so that the timeout will be used
# by all clients created from then on.
_update_default_client_config(session, arg_name, arg_value)


def _update_default_client_config(session, arg_name, arg_value):
current_default_config = session.get_default_client_config()
new_default_config = Config(**{arg_name: arg_value})
if current_default_config is not None:
new_default_config = current_default_config.merge(new_default_config)
session.set_default_client_config(new_default_config)
7 changes: 6 additions & 1 deletion awscli/data/cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@
"cli-read-timeout": {
"dest": "read_timeout",
"type": "int",
"help": "<p>The maximum socket read time in seconds.</p>"
"help": "<p>The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout.</p>"
},
"cli-connect-timeout": {
"dest": "connect_timeout",
"type": "int",
"help": "<p>The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout.</p>"
}
}
}
6 changes: 5 additions & 1 deletion awscli/examples/glacier/upload-archive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ Output::
"location": "/0123456789012/vaults/my-vault/archives/kKB7ymWJVpPSwhGP6ycSOAekp9ZYe_--zM_mw6k76ZFGEIWQX-ybtRDvc2VkPSDtfKmQrj0IRQLSGsNuDp-AJVlu2ccmDSyDUmZwKbwbpAdGATGDiB3hHO0bjbGehXTcApVud_wyDw"
}

Amazon Glacier requires an account ID argument when performing operations, but you can use a hyphen to specify the in-use account.
Amazon Glacier requires an account ID argument when performing operations, but you can use a hyphen to specify the in-use account.

To retrieve an uploaded archive, initiate a retrieval job with the `aws glacier initiate-job`_ command.

.. _`aws glacier initiate-job`: http://docs.aws.amazon.com/cli/latest/reference/glacier/initiate-job.html
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# The short X.Y version.
version = '1.9.'
# The full version, including alpha/beta/rc tags.
release = '1.9.10'
release = '1.9.11'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ universal = 1

[metadata]
requires-dist =
botocore==1.3.10
botocore==1.3.11
colorama>=0.2.5,<=0.3.3
docutils>=0.10
rsa>=3.1.2,<=3.3.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import awscli


requires = ['botocore==1.3.10',
requires = ['botocore==1.3.11',
'colorama>=0.2.5,<=0.3.3',
'docutils>=0.10',
'rsa>=3.1.2,<=3.3.0']
Expand Down
29 changes: 28 additions & 1 deletion tests/unit/customizations/test_globalargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
from botocore.session import get_session
from botocore.handlers import disable_signing
import os

Expand Down Expand Up @@ -196,6 +197,32 @@ def test_valid_endpoint_url(self):

def test_cli_read_timeout(self):
parsed_args = FakeParsedArgs(read_timeout='60')
session = mock.Mock()
session = get_session()
globalargs.resolve_cli_read_timeout(parsed_args, session)
self.assertEqual(parsed_args.read_timeout, 60)
self.assertEqual(
session.get_default_client_config().read_timeout, 60)

def test_cli_connect_timeout(self):
parsed_args = FakeParsedArgs(connect_timeout='60')
session = get_session()
globalargs.resolve_cli_connect_timeout(parsed_args, session)
self.assertEqual(parsed_args.connect_timeout, 60)
self.assertEqual(
session.get_default_client_config().connect_timeout, 60)

def test_cli_read_timeout_for_blocking(self):
parsed_args = FakeParsedArgs(read_timeout='0')
session = get_session()
globalargs.resolve_cli_read_timeout(parsed_args, session)
self.assertEqual(parsed_args.read_timeout, None)
self.assertEqual(
session.get_default_client_config().read_timeout, None)

def test_cli_connect_timeout_for_blocking(self):
parsed_args = FakeParsedArgs(connect_timeout='0')
session = get_session()
globalargs.resolve_cli_connect_timeout(parsed_args, session)
self.assertEqual(parsed_args.connect_timeout, None)
self.assertEqual(
session.get_default_client_config().connect_timeout, None)
35 changes: 35 additions & 0 deletions tests/unit/test_clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
"read-timeout": {
"type": "int",
"help": ""
},
"connect-timeout": {
"type": "int",
"help": ""
}
}
},
Expand Down Expand Up @@ -690,6 +694,37 @@ def test_aws_with_read_timeout(self):
call_args = self.create_endpoint.call_args
self.assertEqual(call_args[1]['timeout'][1], 90)

def test_aws_with_blocking_read_timeout(self):
self.assert_params_for_cmd(
'lambda invoke --function-name foo out.log --cli-read-timeout 0',
expected_rc=0)
call_args = self.create_endpoint.call_args
self.assertEqual(call_args[1]['timeout'][1], None)

def test_aws_with_connnect_timeout(self):
self.assert_params_for_cmd(
'lambda invoke --function-name foo out.log '
'--cli-connect-timeout 90',
expected_rc=0)
call_args = self.create_endpoint.call_args
self.assertEqual(call_args[1]['timeout'][0], 90)

def test_aws_with_blocking_connect_timeout(self):
self.assert_params_for_cmd(
'lambda invoke --function-name foo out.log '
'--cli-connect-timeout 0',
expected_rc=0)
call_args = self.create_endpoint.call_args
self.assertEqual(call_args[1]['timeout'][0], None)

def test_aws_with_read_and_connnect_timeout(self):
self.assert_params_for_cmd(
'lambda invoke --function-name foo out.log '
'--cli-read-timeout 70 --cli-connect-timeout 90',
expected_rc=0)
call_args = self.create_endpoint.call_args
self.assertEqual(call_args[1]['timeout'], (90, 70))


class TestHTTPParamFileDoesNotExist(BaseAWSCommandParamsTest):

Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
GLOBALOPTS = ['--debug', '--endpoint-url', '--no-verify-ssl', '--no-paginate',
'--output', '--profile', '--region', '--version', '--color',
'--query', '--no-sign-request', '--ca-bundle',
'--cli-read-timeout']
'--cli-read-timeout', '--cli-connect-timeout']

COMPLETIONS = [
('aws ', -1, set(['apigateway', 'autoscaling', 'cloudformation', 'cloudfront',
Expand Down Expand Up @@ -73,7 +73,8 @@
'--no-verify-ssl', '--no-paginate', '--no-sign-request', '--output',
'--profile', '--starting-token', '--max-items', '--page-size',
'--region', '--version', '--color', '--query', '--ca-bundle',
'--generate-cli-skeleton', '--cli-input-json', '--cli-read-timeout'])),
'--generate-cli-skeleton', '--cli-input-json', '--cli-read-timeout',
'--cli-connect-timeout'])),
('aws s3', -1, set(['cp', 'mv', 'rm', 'mb', 'rb', 'ls', 'sync', 'website'])),
('aws s3 m', -1, set(['mv', 'mb'])),
('aws s3 cp -', -1, set(['--no-guess-mime-type', '--dryrun',
Expand Down

0 comments on commit 33a68f9

Please sign in to comment.