Beispiel #1
0
    def test_configurations_resourcegroup(self, resource_group):
        resourceGroupName = resource_group.name

        # create a new configuration to update exclude to True
        input = ConfigData()
        input.properties = ConfigDataProperties(exclude=True)

        # update the configuration
        self.client.configurations.create_in_resource_group(
            config_contract = input,
            resource_group = resourceGroupName)

        # retrieve the configurations
        output = list(self.client.configurations.list_by_resource_group(resource_group = resourceGroupName))[0]

        # it should be identical to what we just set
        self.assertEqual(output.properties.exclude, True)

        # restore the default configuration
        input.properties = ConfigDataProperties(exclude=False)
        self.client.configurations.create_in_resource_group(
            config_contract = input,
            resource_group = resourceGroupName)

        # retrieve the configurations
        output = list(self.client.configurations.list_by_resource_group(resource_group = resourceGroupName))[0]

        # it should be identical to what we just set
        self.assertEqual(output.properties.exclude, False)
    def test_configurations_subscription(self):

        # create a new configuration to update low CPU threshold to 20
        input = ConfigData()
        input.properties = ConfigDataProperties(low_cpu_threshold=20)

        # update the configuration
        response = self.client.configurations.create_in_subscription(input)

        # retrieve the configurations
        output = list(
            self.client.configurations.list_by_subscription().value)[0]

        # it should be identical to what we just set
        self.assertEqual(output.properties.low_cpu_threshold, "20")

        # restore the default configuration
        input.properties = ConfigDataProperties(low_cpu_threshold=5)
        response = self.client.configurations.create_in_subscription(input)

        # retrieve the configurations
        output = list(
            self.client.configurations.list_by_subscription().value)[0]

        # it should be identical to what we just set
        self.assertEqual(output.properties.low_cpu_threshold, "5")
def configure_advisor_threshold():

    creds = ServicePrincipalCredentials(client_id=client_id,
                                        secret=secret,
                                        tenant=tenant)

    creds.set_token()

    client = AdvisorManagementClient(credentials=creds,
                                     subscription_id=subscription_id)

    # create a new configuration to update low CPU threshold to 20
    cfg = ConfigData()
    cfg.properties = ConfigDataProperties(low_cpu_threshold=20, exclude=False)

    # update the configuration
    client.configurations.create_in_subscription(cfg)
Beispiel #4
0
def cli_advisor_set_configurations(client,
                                   resource_group_name=None,
                                   low_cpu_threshold=None,
                                   exclude=None,
                                   include=None):

    cfg = ConfigData()
    cfg.properties = ConfigDataProperties()

    cfg.properties.low_cpu_threshold = low_cpu_threshold
    cfg.properties.exclude = exclude
    if include:
        cfg.properties.exclude = False

    if resource_group_name:
        return client.create_in_resource_group(
            config_contract=cfg, resource_group=resource_group_name)

    return client.create_in_subscription(cfg)