def _process_resource(self, resource):
        model = models.AppServicePlan(location=resource['location'])

        if resource['kind'] == 'functionapp':
            self.log.info("Skipping %s, because this App Service Plan "
                          "is for Consumption Azure Functions." %
                          resource['name'])
            return

        if resource['kind'] == 'linux':
            model.reserved = True

        size = Lookup.extract(self.data.get('size'), resource)

        # get existing tier
        model.sku = models.SkuDescription()
        model.sku.tier = resource['sku']['tier']
        model.sku.name = resource['sku']['name']

        if 'size' in self.data:
            model.sku.tier = ResizePlan.get_sku_name(size)
            model.sku.name = size

        if 'count' in self.data:
            model.sku.capacity = Lookup.extract(self.data.get('count'),
                                                resource)

        try:
            self.client.app_service_plans.update(resource['resourceGroup'],
                                                 resource['name'], model)
        except models.DefaultErrorResponseException as e:
            self.log.error("Failed to resize %s.  Inner exception: %s" %
                           (resource['name'], e.inner_exception))
Example #2
0
    def test_extract_lookup(self):
        data = {'field_level_1': {'field_level_2': 'value_1'}}
        source = {
            'type': Lookup.RESOURCE_SOURCE,
            'key': 'field_level_1.field_level_2',
            'default-value': 'value_2'
        }

        value = Lookup.extract(source, data)
        self.assertEqual(value, 'value_1')
Example #3
0
 def _get_tags(self, resource):
     return self.data.get('tags') or {Lookup.extract(
         self.data.get('tag'), resource): Lookup.extract(self.data.get('value'), resource)}
Example #4
0
 def test_extract_no_lookup(self):
     source = 'mock_string_value'
     value = Lookup.extract(source)
     self.assertEqual(source, value)