Esempio n. 1
0
def created_subscription(context, server_id):

    context.tenant_id = TENANT_ID
    context.server_id = server_id
    context.headers = HEADERS

    context.rule_body = Rule_Utils.create_scale_specific_rule()

    # Create the rule in Policy Manager
    req = api_utils.create_rule(tenant_id=context.tenant_id,
                                server_id=context.server_id,
                                body=context.rule_body)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))

    # Save the Rule ID to obtain the Rule information after
    context.rule_id = req.json()[RULE_ID]

    req = api_utils.create_subscription(tenant_id=context.tenant_id,
                                        server_id=context.server_id,
                                        rule_id=context.rule_id,
                                        url=RULE_URL_DEFAULT,
                                        headers=context.headers)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))
    print(req.content)
    context.subscription_id = req.json()[SUBSCRIPTION_ID]
Esempio n. 2
0
def created_subscription(step, server_id):

    world.tenant_id = TENANT_ID
    world.server_id = server_id
    world.headers = HEADERS

    world.rule_body = Rule_Utils.create_scale_specific_rule()

    # Create the rule in Policy Manager
    req = api_utils.create_rule(tenant_id=world.tenant_id, server_id=world.server_id, body=world.rule_body)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))

    # Save the Rule ID to obtain the Rule information after
    world.rule_id = req.json()[RULE_ID]

    req = api_utils.create_subscription(
        tenant_id=world.tenant_id,
        server_id=world.server_id,
        rule_id=world.rule_id,
        url=RULE_URL_DEFAULT,
        headers=world.headers,
    )

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))
    print req.content
    world.subscription_id = req.json()[SUBSCRIPTION_ID]
Esempio n. 3
0
def given_the_created_scale_rule_in_the_in_the_group1_with_the_following_parameters(
        context, server_id):

    context.cpu = None
    context.mem = None
    context.hdd = None
    context.net = None
    context.server_id = server_id

    for examples in context.table.rows:
        rule_body = Rule_Utils.create_scale_specific_rule(
            operation=examples['operation'],
            name=examples['name'],
            cpu_value=examples['cpu_value'],
            cpu_operand=examples['cpu_operand'],
            mem_value=examples['mem_value'],
            mem_operand=examples['mem_operand'],
            hdd_value=examples['hdd_value'],
            hdd_operand=examples['hdd_operand'],
            net_value=examples['net_value'],
            net_operand=examples['net_operand'])

        req = api_utils.create_rule(tenant_id=context.tenant_id,
                                    server_id=context.server_id,
                                    body=rule_body)
        context.rule_id = req.json()[RULE_ID]
Esempio n. 4
0
def given_the_created_scale_rule_in_the_in_the_group1_with_the_following_parameters(
        step, server_id):

    world.cpu = None
    world.mem = None
    world.hdd = None
    world.net = None
    world.server_id = server_id

    for examples in step.hashes:
        rule_body = Rule_Utils.create_scale_specific_rule(
            operation=examples['operation'],
            name=examples['name'],
            cpu_value=examples['cpu_value'],
            cpu_operand=examples['cpu_operand'],
            mem_value=examples['mem_value'],
            mem_operand=examples['mem_operand'],
            hdd_value=examples['hdd_value'],
            hdd_operand=examples['hdd_operand'],
            net_value=examples['net_value'],
            net_operand=examples['net_operand'])

        req = api_utils.create_rule(tenant_id=world.tenant_id,
                                    server_id=world.server_id,
                                    body=rule_body)
        world.rule_id = req.json()[RULE_ID]
Esempio n. 5
0
def given_a_group1_of_servers_in_a_tenant(step, number_servers):

    world.number_servers = int(number_servers)
    world.servers_body = []

    for x in range(world.number_servers):
        world.rules = []
        server_id = Utils.id_generator(size=6)
        number_rules = random.randint(1, 5)

        for rule in range(number_rules):
            rule_body = Rule_Utils.create_scale_specific_rule()
            req = api_utils.create_rule(world.tenant_id,
                                        server_id,
                                        body=rule_body)
            assert_true(req.ok,
                        HTTP_CODE_NOT_OK.format(req.status_code, req.content))
            rule_id = req.json()[RULE_ID]
            world.rules.append(
                Rule_Utils.create_rule_body(action=None,
                                            rule_id=rule_id,
                                            condition=None,
                                            name=rule_body['name']))

        server_dict = {SERVER_ID: server_id, RULES: world.rules}
        world.servers_body.append(server_dict)
Esempio n. 6
0
def created_rule(step, server_id):

    world.server_id = server_id
    world.rule_body = Rule_Utils.create_scale_specific_rule()

    #Create the rule in Policy Manager
    req = api_utils.create_rule(tenant_id=world.tenant_id, server_id=world.server_id, body=world.rule_body)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))

    #Save the Rule ID to obtain the Rule information after
    world.rule_id = req.json()[RULE_ID]
Esempio n. 7
0
def created_rule(step, server_id):

    world.server_id = server_id
    world.rule_body = Rule_Utils.create_scale_specific_rule()

    #Create the rule in Policy Manager
    req = api_utils.create_rule(tenant_id=world.tenant_id, server_id=world.server_id, body=world.rule_body)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))

    #Save the Rule ID to obtain the Rule information after
    world.rule_id = req.json()[RULE_ID]
Esempio n. 8
0
def given_the_created_scale_rule_in_the_in_the_group1_with_the_following_parameters(step, server_id):

    world.cpu = None
    world.mem = None
    world.server_id = server_id

    for examples in step.hashes:
        rule_body = Rule_Utils.create_scale_specific_rule(operation=examples['operation'],
                                                          name=examples['name'],
                                                          cpu_value=examples['cpu_value'],
                                                          cpu_operand=examples['cpu_operand'],
                                                          mem_value=examples['mem_value'],
                                                          mem_operand=examples['mem_operand'])

        req = api_utils.create_rule(tenant_id=world.tenant_id, server_id=world.server_id, body=rule_body)
        world.rule_id = req.json()[RULE_ID]
Esempio n. 9
0
def given_a_group1_of_servers_in_a_tenant(step, number_servers):

    world.number_servers = int(number_servers)
    world.servers_body = []

    for x in range(world.number_servers):
        world.rules = []
        server_id = Utils.id_generator(size=6)
        number_rules = random.randint(1, 5)

        for rule in range(number_rules):
            rule_body = Rule_Utils.create_scale_specific_rule()
            req = api_utils.create_rule(world.tenant_id, server_id, body=rule_body)
            assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))
            rule_id = req.json()[RULE_ID]
            world.rules.append(Rule_Utils.create_rule_body(action=None, rule_id=rule_id, condition=None,
                                                           name=rule_body['name']))

        server_dict = {SERVER_ID: server_id,
                       RULES: world.rules}
        world.servers_body.append(server_dict)
Esempio n. 10
0
def given_the_created_scale_rule_in_the_in_the_group1_with_the_following_parameters(context, server_id):

    context.cpu = None
    context.mem = None
    context.hdd = None
    context.net = None
    context.server_id = server_id

    for examples in context.table.rows:
        rule_body = Rule_Utils.create_scale_specific_rule(operation=examples['operation'],
                                                          name=examples['name'],
                                                          cpu_value=examples['cpu_value'],
                                                          cpu_operand=examples['cpu_operand'],
                                                          mem_value=examples['mem_value'],
                                                          mem_operand=examples['mem_operand'],
                                                          hdd_value=examples['hdd_value'],
                                                          hdd_operand=examples['hdd_operand'],
                                                          net_value=examples['net_value'],
                                                          net_operand=examples['net_operand'])

        req = api_utils.create_rule(tenant_id=context.tenant_id, server_id=context.server_id, body=rule_body)
        context.rule_id = req.json()[RULE_ID]
Esempio n. 11
0
def and_some_rule_prepared_with_all_data(step):

    world.rule_body = Rule_Utils.create_scale_specific_rule()
Esempio n. 12
0
def and_some_rule_prepared_with_all_data(step):

    world.rule_body = Rule_Utils.create_scale_specific_rule()
Esempio n. 13
0
def and_some_rule_prepared_with_all_data(context):

    context.rule_body = Rule_Utils.create_scale_specific_rule()
Esempio n. 14
0
def and_some_rule_prepared_with_all_data(context):

    context.rule_body = Rule_Utils.create_scale_specific_rule()