Deprecate create/adopt --create-timeout in favor of --timeout
Replace the --create-timeout option with a more generic and intuitive --timeout option, which can also later be used for update. Since users may be using this option and it does currently work, leave the old -c/--create-timeout option for now, but mark deprecated in the usage and output a warning message if users use it. To make this warning visible the default loglevel is changed to WARNING. Note neither timeout contains an integer default now, we rely on the server-side default (which is 60mins anyway) as this make the fallback to support the previous option easier and potentially to provide an easier way to solve heat bug #1290603. Partial-Bug: #1290456 Related-Bug: #1290603 Change-Id: Ia8c8d61b259ffa1f8a59d29a3e7fa7d9c128984f
This commit is contained in:
parent
38098938be
commit
d9e3b3d2cd
@ -273,7 +273,7 @@ class HeatShell(object):
|
||||
endpoint_type=kwargs.get('endpoint_type') or 'publicURL')
|
||||
|
||||
def _setup_logging(self, debug):
|
||||
log_lvl = logging.DEBUG if debug else logging.ERROR
|
||||
log_lvl = logging.DEBUG if debug else logging.WARNING
|
||||
logging.basicConfig(
|
||||
format="%(levelname)s (%(module)s:%(lineno)d) %(message)s",
|
||||
level=log_lvl)
|
||||
|
@ -709,6 +709,53 @@ class ShellTestUserPass(ShellBase):
|
||||
for r in required:
|
||||
self.assertRegexpMatches(create_text, r)
|
||||
|
||||
def test_stack_create_timeout(self):
|
||||
self._script_keystone_client()
|
||||
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
|
||||
template_data = open(template_file).read()
|
||||
resp = fakes.FakeHTTPResponse(
|
||||
201,
|
||||
'Created',
|
||||
{'location': 'http://no.where/v1/tenant_id/stacks/teststack2/2'},
|
||||
None)
|
||||
expected_data = {
|
||||
'files': {},
|
||||
'disable_rollback': True,
|
||||
'parameters': {'DBUsername': 'wp',
|
||||
'KeyName': 'heat_key',
|
||||
'LinuxDistribution': 'F17"',
|
||||
'"InstanceType': 'm1.large',
|
||||
'DBPassword': 'verybadpassword'},
|
||||
'stack_name': 'teststack',
|
||||
'environment': {},
|
||||
'template': jsonutils.loads(template_data),
|
||||
'timeout_mins': 123}
|
||||
http.HTTPClient.json_request(
|
||||
'POST', '/stacks', data=expected_data,
|
||||
headers={'X-Auth-Key': 'password', 'X-Auth-User': 'username'}
|
||||
).AndReturn((resp, None))
|
||||
fakes.script_heat_list()
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
||||
create_text = self.shell(
|
||||
'stack-create teststack '
|
||||
'--template-file=%s '
|
||||
'--timeout=123 '
|
||||
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
||||
'DBPassword=verybadpassword;KeyName=heat_key;'
|
||||
'LinuxDistribution=F17"' % template_file)
|
||||
|
||||
required = [
|
||||
'stack_name',
|
||||
'id',
|
||||
'teststack',
|
||||
'1'
|
||||
]
|
||||
|
||||
for r in required:
|
||||
self.assertRegexpMatches(create_text, r)
|
||||
|
||||
def test_stack_create_url(self):
|
||||
|
||||
self._script_keystone_client()
|
||||
|
@ -13,6 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
|
||||
import yaml
|
||||
|
||||
from heatclient.common import template_utils
|
||||
@ -22,6 +24,8 @@ from heatclient.openstack.common.py3kcompat import urlutils
|
||||
|
||||
import heatclient.exc as exc
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@utils.arg('-f', '--template-file', metavar='<FILE>',
|
||||
help='Path to the template.')
|
||||
@ -32,8 +36,12 @@ import heatclient.exc as exc
|
||||
@utils.arg('-o', '--template-object', metavar='<URL>',
|
||||
help='URL to retrieve template object (e.g. from swift).')
|
||||
@utils.arg('-c', '--create-timeout', metavar='<TIMEOUT>',
|
||||
default=60, type=int,
|
||||
help='Stack creation timeout in minutes. Default: 60.')
|
||||
type=int,
|
||||
help='Stack creation timeout in minutes.'
|
||||
' DEPRECATED use --timeout instead.')
|
||||
@utils.arg('-t', '--timeout', metavar='<TIMEOUT>',
|
||||
type=int,
|
||||
help='Stack creation timeout in minutes.')
|
||||
@utils.arg('-r', '--enable-rollback', default=False, action="store_true",
|
||||
help='Enable rollback on create/update failure.')
|
||||
@utils.arg('-P', '--parameters', metavar='<KEY1=VALUE1;KEY2=VALUE2...>',
|
||||
@ -57,8 +65,12 @@ def do_create(hc, args):
|
||||
@utils.arg('-o', '--template-object', metavar='<URL>',
|
||||
help='URL to retrieve template object (e.g. from swift).')
|
||||
@utils.arg('-c', '--create-timeout', metavar='<TIMEOUT>',
|
||||
default=60, type=int,
|
||||
help='Stack creation timeout in minutes. Default: 60.')
|
||||
type=int,
|
||||
help='Stack creation timeout in minutes.'
|
||||
' DEPRECATED use --timeout instead.')
|
||||
@utils.arg('-t', '--timeout', metavar='<TIMEOUT>',
|
||||
type=int,
|
||||
help='Stack creation timeout in minutes.')
|
||||
@utils.arg('-r', '--enable-rollback', default=False, action="store_true",
|
||||
help='Enable rollback on create/update failure.')
|
||||
@utils.arg('-P', '--parameters', metavar='<KEY1=VALUE1;KEY2=VALUE2...>',
|
||||
@ -78,9 +90,13 @@ def do_stack_create(hc, args):
|
||||
env_files, env = template_utils.process_environment_and_files(
|
||||
env_path=args.environment_file)
|
||||
|
||||
if args.create_timeout:
|
||||
logger.warning('-c/--create-timeout is deprecated, '
|
||||
'please use -t/--timeout instead')
|
||||
|
||||
fields = {
|
||||
'stack_name': args.name,
|
||||
'timeout_mins': args.create_timeout,
|
||||
'timeout_mins': args.timeout or args.create_timeout,
|
||||
'disable_rollback': not(args.enable_rollback),
|
||||
'parameters': utils.format_parameters(args.parameters),
|
||||
'template': template,
|
||||
@ -101,8 +117,12 @@ def do_stack_create(hc, args):
|
||||
@utils.arg('-o', '--template-object', metavar='<URL>',
|
||||
help='URL to retrieve template object (e.g from swift).')
|
||||
@utils.arg('-c', '--create-timeout', metavar='<TIMEOUT>',
|
||||
default=60, type=int,
|
||||
help='Stack creation timeout in minutes. Default: 60.')
|
||||
type=int,
|
||||
help='Stack creation timeout in minutes.'
|
||||
' DEPRECATED use --timeout instead.')
|
||||
@utils.arg('-t', '--timeout', metavar='<TIMEOUT>',
|
||||
type=int,
|
||||
help='Stack creation timeout in minutes.')
|
||||
@utils.arg('-a', '--adopt-file', metavar='<FILE or URL>',
|
||||
help='Path to adopt stack data file.')
|
||||
@utils.arg('-r', '--enable-rollback', default=False, action="store_true",
|
||||
@ -130,9 +150,13 @@ def do_stack_adopt(hc, args):
|
||||
adopt_url = template_utils.normalise_file_path_to_url(args.adopt_file)
|
||||
adopt_data = urlutils.urlopen(adopt_url).read()
|
||||
|
||||
if args.create_timeout:
|
||||
logger.warning('-c/--create-timeout is deprecated, '
|
||||
'please use -t/--timeout instead')
|
||||
|
||||
fields = {
|
||||
'stack_name': args.name,
|
||||
'timeout_mins': args.create_timeout,
|
||||
'timeout_mins': args.timeout or args.create_timeout,
|
||||
'disable_rollback': not(args.enable_rollback),
|
||||
'adopt_stack_data': adopt_data,
|
||||
'parameters': utils.format_parameters(args.parameters),
|
||||
|
Loading…
Reference in New Issue
Block a user