Ejemplo n.º 1
0
    def get_origin(self, values, option_string):
        from azure.mgmt.cdn.models import DeepCreatedOrigin

        if not 1 <= len(values) <= 3:
            msg = '%s takes 1, 2 or 3 values, %d given'
            raise argparse.ArgumentError(self, msg % (option_string, len(values)))

        deep_created_origin = DeepCreatedOrigin('origin', values[0], http_port=80, https_port=443)
        if len(values) > 1:
            deep_created_origin.http_port = int(values[1])
        if len(values) > 2:
            deep_created_origin.https_port = int(values[2])
        return deep_created_origin
Ejemplo n.º 2
0
    def get_origin(self, values, option_string):
        from azure.mgmt.cdn.models import DeepCreatedOrigin

        if not 1 <= len(values) <= 3:
            msg = '%s takes 1, 2 or 3 values, %d given'
            raise argparse.ArgumentError(self, msg % (option_string, len(values)))

        deep_created_origin = DeepCreatedOrigin(name='origin', host_name=values[0], http_port=80, https_port=443)
        if len(values) > 1:
            deep_created_origin.http_port = int(values[1])
        if len(values) > 2:
            deep_created_origin.https_port = int(values[2])
        return deep_created_origin
Ejemplo n.º 3
0
    def create_cdnendpoint(self):
        '''
        Creates a Azure CDN endpoint.

        :return: deserialized Azure CDN endpoint instance state dictionary
        '''
        self.log("Creating the Azure CDN endpoint instance {0}".format(
            self.name))

        origins = []
        for item in self.origins:
            origins.append(
                DeepCreatedOrigin(name=item['name'],
                                  host_name=item['host_name'],
                                  http_port=item['http_port']
                                  if 'http_port' in item else None,
                                  https_port=item['https_port']
                                  if 'https_port' in item else None))

        parameters = Endpoint(
            origins=origins,
            location=self.location,
            tags=self.tags,
            origin_host_header=self.origin_host_header,
            origin_path=self.origin_path,
            content_types_to_compress=default_content_types() if
            self.is_compression_enabled and not self.content_types_to_compress
            else self.content_types_to_compress,
            is_compression_enabled=self.is_compression_enabled
            if self.is_compression_enabled is not None else False,
            is_http_allowed=self.is_http_allowed
            if self.is_http_allowed is not None else True,
            is_https_allowed=self.is_https_allowed
            if self.is_https_allowed is not None else True,
            query_string_caching_behavior=self.query_string_caching_behavior
            if self.query_string_caching_behavior else
            QueryStringCachingBehavior.ignore_query_string)

        try:
            poller = self.cdn_client.endpoints.create(self.resource_group,
                                                      self.profile_name,
                                                      self.name, parameters)
            response = self.get_poller_result(poller)
            return cdnendpoint_to_dict(response)
        except ErrorResponseException as exc:
            self.log('Error attempting to create Azure CDN endpoint instance.')
            self.fail("Error creating Azure CDN endpoint instance: {0}".format(
                exc.message))
Ejemplo n.º 4
0
    def get_origin(self, values, option_string):
        from azure.mgmt.cdn.models import DeepCreatedOrigin

        if not 1 <= len(values) <= 3 and not 5 <= len(values) <= 6:
            msg = '%s takes 1, 2, 3, 5, or 6 values, %d given'
            raise argparse.ArgumentError(self,
                                         msg % (option_string, len(values)))

        deep_created_origin = DeepCreatedOrigin(name='origin',
                                                host_name=values[0],
                                                http_port=80,
                                                https_port=443)

        if len(values) > 1:
            deep_created_origin.http_port = int(values[1])
        if len(values) > 2:
            deep_created_origin.https_port = int(values[2])
        if len(values) > 4:
            deep_created_origin.private_link_resource_id = values[3]
            deep_created_origin.private_link_location = values[4]
        if len(values) > 5:
            deep_created_origin.private_link_approval_message = values[5]
        return deep_created_origin