in src/sfctl/custom_service.py [0:0]
def create( # pylint: disable=too-many-arguments, too-many-locals
client, app_id, name, service_type, stateful=False, stateless=False,
singleton_scheme=False, named_scheme=False, int_scheme=False,
named_scheme_list=None, int_scheme_low=None, int_scheme_high=None,
int_scheme_count=None, constraints=None, correlated_service=None,
correlation=None, load_metrics=None, placement_policy_list=None,
move_cost=None, activation_mode=None, dns_name=None,
target_replica_set_size=None, min_replica_set_size=None,
replica_restart_wait=None, quorum_loss_wait=None,
stand_by_replica_keep=None, no_persisted_state=False,
instance_count=None, timeout=60, scaling_policies=None,
service_placement_time=None, tags_required_to_place=None, tags_required_to_run=None):
"""
Creates the specified Service Fabric service.
:param str app_id: The identity of the application. This is
typically the full name of the application without the 'fabric:' URI
scheme. Starting from version 6.0, hierarchical names are delimited with
the '~' character. For example, if the application name is
'fabric:/myapp/app1', the application identity would be 'myapp~app1' in
6.0+ and 'myapp/app1' in previous versions.
:param str name: Name of the service. This should be a child of the
application id. This is the full name including the `fabric:` URI.
For example service `fabric:/A/B` is a child of application
`fabric:/A`.
:param str service_type: Name of the service type.
:param bool stateful: Indicates the service is a stateful service.
:param bool stateless: Indicates the service is a stateless service.
:param bool singleton_scheme: Indicates the service should have a single
partition or be a non-partitioned service.
:param bool named_scheme: Indicates the service should have multiple named
partitions.
:param list of str named_scheme_list: JSON encoded list of names to
partition the service across, if using the named partition scheme
:param bool int_scheme: Indicates the service should be uniformly
partitioned across a range of unsigned integers.
:param str int_scheme_low: The start of the key integer range, if using an
uniform integer partition scheme.
:param str int_scheme_high: The end of the key integer range, if using an
uniform integer partition scheme.
:param str int_scheme_count: The number of partitions inside the integer
key range to create, if using a uniform integer partition scheme.
:param str constraints: The placement constraints as a string. Placement
constraints are boolean expressions on node properties and allow for
restricting a service to particular nodes based on the service
requirements. For example, to place a service on nodes where NodeType
is blue specify the following:"NodeColor == blue".
:param str correlation: Correlate the service with an existing service
using an alignment affinity. Possible values include: 'Invalid',
'Affinity', 'AlignedAffinity', 'NonAlignedAffinity'.
:param str load_metrics: JSON encoded list of metrics used when load
balancing services across nodes.
:param str placement_policy_list: JSON encoded list of placement policies
for the service, and any associated domain names. Policies can be one or
more of: `NonPartiallyPlaceService`, `PreferPrimaryDomain`,
`RequireDomain`, `RequireDomainDistribution`.
:param str correlated_service: Name of the target service to correlate
with.
:param str move_cost: Specifies the move cost for the service. Possible
values are: 'Zero', 'Low', 'Medium', 'High', 'VeryHigh'.
:param str activation_mode: The activation mode for the service package.
Possible values include: 'SharedProcess', 'ExclusiveProcess'.
:param str dns_name: The DNS name of the service to be created. The Service
Fabric DNS system service must be enabled for this setting.
:param int target_replica_set_size: The target replica set size as a
number. This applies to stateful services only.
:param int min_replica_set_size: The minimum replica set size as a number.
This applies to stateful services only.
:param int replica_restart_wait: The duration, in seconds, between when a
replica goes down and when a new replica is created. This applies to
stateful services only.
:param int quorum_loss_wait: The maximum duration, in seconds, for which a
partition is allowed to be in a state of quorum loss. This applies to
stateful services only.
:param int stand_by_replica_keep: The maximum duration, in seconds, for
which StandBy replicas will be maintained before being removed. This
applies to stateful services only.
:param bool no_persisted_state: If true, this indicates the service has no
persistent state stored on the local disk, or it only stores state in
memory.
:param int instance_count: The instance count. This applies to stateless
services only.
:param str scaling_policies: JSON encoded list of scaling policies for this service.
:param list of str tags_required_to_place: JSON encoded list of tags to
require to place the service, if using node tagging feature
:param list of str tags_required_to_run: JSON encoded list of tags to
require to run the service, if using node tagging feature
:param int service_placement_time: The duration for which replicas can stay
InBuild before reporting that build is stuck. This
applies to stateful services only.
"""
from azure.servicefabric.models import StatelessServiceDescription, StatefulServiceDescription
validate_service_create_params(stateful, stateless, singleton_scheme,
int_scheme, named_scheme, instance_count,
target_replica_set_size,
min_replica_set_size)
partition_desc = parse_partition_policy(named_scheme, named_scheme_list,
int_scheme, int_scheme_low,
int_scheme_high, int_scheme_count,
singleton_scheme)
cor_desc = correlation_desc(correlated_service, correlation)
load_list = parse_load_metrics(load_metrics)
place_policy = parse_placement_policies(placement_policy_list)
validate_move_cost(move_cost)
validate_activation_mode(activation_mode)
scaling_policy_description = parse_scaling_policy(scaling_policies)
tags_required_to_place_description = parse_service_tags(tags_required_to_place)
tags_required_to_run_description = parse_service_tags(tags_required_to_run)
if stateless:
svc_desc = StatelessServiceDescription(service_name=name,
service_type_name=service_type,
partition_description=partition_desc,
instance_count=instance_count,
application_name="fabric:/" + app_id,
initialization_data=None,
placement_constraints=constraints,
correlation_scheme=cor_desc,
service_load_metrics=load_list,
service_placement_policies=place_policy,
default_move_cost=move_cost,
is_default_move_cost_specified=bool(move_cost),
service_package_activation_mode=activation_mode,
service_dns_name=dns_name,
scaling_policies=scaling_policy_description,
tags_required_to_place=tags_required_to_place_description,
tags_required_to_run=tags_required_to_run_description)
if stateful:
flags = stateful_flags(replica_restart_wait, quorum_loss_wait,
stand_by_replica_keep, service_placement_time)
svc_desc = StatefulServiceDescription(
service_name=name,
service_type_name=service_type,
partition_description=partition_desc,
target_replica_set_size=target_replica_set_size,
min_replica_set_size=min_replica_set_size,
has_persisted_state=not no_persisted_state,
application_name="fabric:/" + app_id,
initialization_data=None,
placement_constraints=constraints,
correlation_scheme=cor_desc,
service_load_metrics=load_list,
service_placement_policies=place_policy,
default_move_cost=move_cost,
is_default_move_cost_specified=bool(move_cost),
service_package_activation_mode=activation_mode,
service_dns_name=dns_name,
scaling_policies=scaling_policy_description,
flags=flags,
replica_restart_wait_duration_seconds=replica_restart_wait,
quorum_loss_wait_duration_seconds=quorum_loss_wait,
stand_by_replica_keep_duration_seconds=stand_by_replica_keep,
service_placement_time_limit_seconds=service_placement_time,
tags_required_to_place=tags_required_to_place_description,
tags_required_to_run=tags_required_to_run_description)
client.create_service(app_id, svc_desc, timeout)