in src/sfctl/custom_app.py [0:0]
def create(client, # pylint: disable=too-many-locals,too-many-arguments
app_name, app_type, app_version, parameters=None,
min_node_count=0, max_node_count=0, metrics=None,
timeout=60):
"""
Creates a Service Fabric application using the specified description.
:param str app_name: The name of the application, including the 'fabric:'
URI scheme.
:param str app_type: The application type name found in the application
manifest.
:param str app_version: The version of the application type as defined in
the application manifest.
:param str parameters: A JSON encoded list of application parameter
overrides to be applied when creating the application.
:param int min_node_count: The minimum number of nodes where Service
Fabric will reserve capacity for this application. Note that this does not
mean that the services of this application will be placed on all of those
nodes.
:param int max_node_count: The maximum number of nodes where Service
Fabric will reserve capacity for this application. Note that this does not
mean that the services of this application will be placed on all of those
nodes.
:param str metrics: A JSON encoded list of application capacity metric
descriptions. A metric is defined as a name, associated with a set of
capacities for each node that the application exists on.
"""
from azure.servicefabric.models import ApplicationDescription, ApplicationCapacityDescription
if (any([min_node_count, max_node_count]) and
not all([min_node_count, max_node_count])):
raise CLIError('Must specify both maximum and minimum node count')
if (all([min_node_count, max_node_count]) and
min_node_count > max_node_count):
raise CLIError('The minimum node reserve capacity count cannot '
'be greater than the maximum node count')
app_params = parse_app_params(parameters)
app_metrics = parse_app_metrics(metrics)
app_cap_desc = ApplicationCapacityDescription(minimum_nodes=min_node_count,
maximum_nodes=max_node_count,
application_metrics=app_metrics)
app_desc = ApplicationDescription(name=app_name,
type_name=app_type,
type_version=app_version,
parameter_list=app_params,
application_capacity=app_cap_desc)
client.create_application(app_desc, timeout)