Support for specifying parameter file
Support for specifying parameter file with the new app command Closes-Bug: #1491621 Change-Id: I752ed9c18969b9b3cfee1547b9cc4b7b150e5cf3
This commit is contained in:
@@ -705,6 +705,20 @@ class AppCommands(cli_utils.CommandsBase):
|
|||||||
|
|
||||||
app_data['ports'] = port_list
|
app_data['ports'] = port_list
|
||||||
|
|
||||||
|
def _get_parameters(self, app_data, args):
|
||||||
|
if args.param_file is not None:
|
||||||
|
try:
|
||||||
|
with open(args.param_file) as param_f:
|
||||||
|
param_def = param_f.read()
|
||||||
|
app_data['parameters'] = yamlutils.load(param_def)
|
||||||
|
except IOError:
|
||||||
|
message = "Could not open param file %s." % args.param_file
|
||||||
|
raise exc.CommandError(message=message)
|
||||||
|
except ValueError:
|
||||||
|
message = ("Param file %s was not YAML." %
|
||||||
|
args.param_file)
|
||||||
|
raise exc.CommandError(message=message)
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
self.register()
|
self.register()
|
||||||
|
|
||||||
@@ -734,6 +748,11 @@ class AppCommands(cli_utils.CommandsBase):
|
|||||||
dest="port",
|
dest="port",
|
||||||
type=ValidPort,
|
type=ValidPort,
|
||||||
help="The port your application listens on")
|
help="The port your application listens on")
|
||||||
|
self.parser.add_argument('--param-file',
|
||||||
|
dest='param_file',
|
||||||
|
help="A yaml file containing custom"
|
||||||
|
" parameters to be used in the"
|
||||||
|
" application")
|
||||||
args = self.parser.parse_args()
|
args = self.parser.parse_args()
|
||||||
app_data = None
|
app_data = None
|
||||||
if args.appfile is not None:
|
if args.appfile is not None:
|
||||||
@@ -767,6 +786,8 @@ class AppCommands(cli_utils.CommandsBase):
|
|||||||
|
|
||||||
self._get_port(app_data, args)
|
self._get_port(app_data, args)
|
||||||
|
|
||||||
|
self._get_parameters(app_data, args)
|
||||||
|
|
||||||
app = self.client.apps.create(**app_data)
|
app = self.client.apps.create(**app_data)
|
||||||
|
|
||||||
app.trigger = app.trigger_actions
|
app.trigger = app.trigger_actions
|
||||||
|
Reference in New Issue
Block a user