def attach_policy(sc, **params):
    cluster_name = params.get('cluster_name', 'sur_cluster')
    
    # create scaling policy
    si_policy_name = cluster_name + '_si_policy'
    so_policy_name = cluster_name + '_so_policy'

    si_policy_spec = params.get('si_policy_spec', None)
    so_policy_spec = params.get('so_policy_spec', None)

    SIPolicy.policy_create(sc, si_policy_name, si_policy_spec)
    SOPolicy.policy_create(sc, so_policy_name, so_policy_spec)
    time.sleep(1)

    Cluster.cluster_policy_attach(sc, cluster_name, si_policy_name)
    Cluster.cluster_policy_attach(sc, cluster_name, so_policy_name)
Beispiel #2
0
def attach_policy(sc, **params):
    cluster_name = params.get('cluster_name', 'sur_cluster')

    # create scaling policy
    si_policy_name = cluster_name + '_si_policy'
    so_policy_name = cluster_name + '_so_policy'

    si_policy_spec = params.get('si_policy_spec', None)
    so_policy_spec = params.get('so_policy_spec', None)

    SIPolicy.policy_create(sc, si_policy_name, si_policy_spec)
    SOPolicy.policy_create(sc, so_policy_name, so_policy_spec)
    time.sleep(1)

    Cluster.cluster_policy_attach(sc, cluster_name, si_policy_name)
    Cluster.cluster_policy_attach(sc, cluster_name, so_policy_name)
def main():
    # setup senlin client
    sc = SURClient('localhost', '8778', '1').setup_client()

    # create loadbalancing policy
#     LBPolicy.policy_create(sc, 'coreos_lb', 'specs/lb_policy_lbaas.spec')

    # attach loadbalancing policy
#     Cluster.cluster_policy_attach(sc, 'coreos_cluster', 'coreos_lb')

    #create scaling policy
    SIPolicy.policy_create(sc, 'coreos_si', 'specs/scaling_policy.spec')
    SOPolicy.policy_create(sc, 'coreos_so', 'specs/scaling_policy.spec')
    time.sleep(1)

    # attach scaling policy
    Cluster.cluster_policy_attach(sc, 'coreos_cluster', 'coreos_si')
    Cluster.cluster_policy_attach(sc, 'coreos_cluster', 'coreos_so')
    time.sleep(1)

    # create scale-out webhook
    wb = Webhook.cluster_webhook_create(sc, 'so_webhook', 'coreos_cluster',
                                        'CLUSTER_SCALE_OUT', {})
    wb_url = wb['webhook']['url']
    
    # setup ceilometer client
    cc = SURClient('localhost', '8777', '2', 'ceilometer').setup_client()
    
    # create ceilometer threshold alarm
    alarm_args = {
        'name': 'test_alarm',
        'meter_name': 'cpu_util',
        'threshold': 50.0,
        'state': 'alarm',
        'severity': 'moderate',
        'enabled': True,
        'repeat_actions': False,
        'alarm_actions': [wb_url],
        'comparison_operator': 'gt',
        'statistic': 'max'
    }
    Alarm.alarm_threshold_create(cc, **alarm_args)
Beispiel #4
0
def main():
    # setup senlin client
    sc = SURClient('localhost', '8778', '1').setup_client()

    # create loadbalancing policy
    #     LBPolicy.policy_create(sc, 'coreos_lb', 'specs/lb_policy_lbaas.spec')

    # attach loadbalancing policy
    #     Cluster.cluster_policy_attach(sc, 'coreos_cluster', 'coreos_lb')

    #create scaling policy
    SIPolicy.policy_create(sc, 'coreos_si', 'specs/scaling_policy.spec')
    SOPolicy.policy_create(sc, 'coreos_so', 'specs/scaling_policy.spec')
    time.sleep(1)

    # attach scaling policy
    Cluster.cluster_policy_attach(sc, 'coreos_cluster', 'coreos_si')
    Cluster.cluster_policy_attach(sc, 'coreos_cluster', 'coreos_so')
    time.sleep(1)

    # create scale-out webhook
    wb = Webhook.cluster_webhook_create(sc, 'so_webhook', 'coreos_cluster',
                                        'CLUSTER_SCALE_OUT', {})
    wb_url = wb['webhook']['url']

    # setup ceilometer client
    cc = SURClient('localhost', '8777', '2', 'ceilometer').setup_client()

    # create ceilometer threshold alarm
    alarm_args = {
        'name': 'test_alarm',
        'meter_name': 'cpu_util',
        'threshold': 50.0,
        'state': 'alarm',
        'severity': 'moderate',
        'enabled': True,
        'repeat_actions': False,
        'alarm_actions': [wb_url],
        'comparison_operator': 'gt',
        'statistic': 'max'
    }
    Alarm.alarm_threshold_create(cc, **alarm_args)