in src/sfctl/custom_chaos.py [0:0]
def parse_chaos_parameters(chaos_parameters): #pylint: disable=too-many-locals
"""Parse ChaosParameters from string"""
from azure.servicefabric.models import ChaosParameters, ChaosContext, ChaosTargetFilter
from sfctl.custom_cluster_upgrade import create_cluster_health_policy
time_to_run = chaos_parameters.get("TimeToRunInSeconds")
max_cluster_stabilization = chaos_parameters.get("MaxClusterStabilizationTimeoutInSeconds")
max_concurrent_faults = chaos_parameters.get("MaxConcurrentFaults")
enable_move_replica_faults = chaos_parameters.get("EnableMoveReplicaFaults")
wait_time_between_faults = chaos_parameters.get("WaitTimeBetweenFaultsInSeconds")
wait_time_between_iterations = chaos_parameters.get("WaitTimeBetweenIterationsInSeconds")
cluster_health_policy = chaos_parameters.get("ClusterHealthPolicy")
health_policy = None
if cluster_health_policy is not None:
health_policy = create_cluster_health_policy(
cluster_health_policy.get("ConsiderWarningAsError"),
cluster_health_policy.get("MaxPercentUnhealthyNodes"),
cluster_health_policy.get("MaxPercentUnhealthyApplications"),
cluster_health_policy.get("ApplicationTypeHealthPolicyMap"))
chaos_context = chaos_parameters.get("Context")
context = None
if chaos_context is not None:
context = ChaosContext(map=chaos_context.get("Map"))
chaos_target_filter = chaos_parameters.get("ChaosTargetFilter")
target_filter = None
if chaos_target_filter is not None:
target_filter = ChaosTargetFilter(
node_type_inclusion_list=chaos_target_filter.get("NodeTypeInclusionList"),
application_inclusion_list=chaos_target_filter.get("ApplicationTypeInclusionList"))
return ChaosParameters(time_to_run_in_seconds=time_to_run,
max_cluster_stabilization_timeout_in_seconds=max_cluster_stabilization,
max_concurrent_faults=max_concurrent_faults,
enable_move_replica_faults=enable_move_replica_faults,
wait_time_between_faults_in_seconds=wait_time_between_faults,
wait_time_between_iterations_in_seconds=wait_time_between_iterations,
cluster_health_policy=health_policy,
context=context,
chaos_target_filter=target_filter)