当前位置: 首页>>代码示例>>Python>>正文


Python FilterRegistry.register方法代码示例

本文整理汇总了Python中c7n.filters.FilterRegistry.register方法的典型用法代码示例。如果您正苦于以下问题:Python FilterRegistry.register方法的具体用法?Python FilterRegistry.register怎么用?Python FilterRegistry.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在c7n.filters.FilterRegistry的用法示例。


在下文中一共展示了FilterRegistry.register方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FilterRegistry

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
import c7n.filters.vpc as net_filters
from datetime import datetime
from dateutil.tz import tzutc
from c7n import tags
from c7n.manager import resources
from c7n.query import QueryResourceManager, DescribeSource
from c7n.utils import local_session, chunks, type_schema, get_retry, REGION_PARTITION_MAP

from c7n.resources.shield import IsShieldProtected, SetShieldProtection

log = logging.getLogger('custodian.elb')

filters = FilterRegistry('elb.filters')
actions = ActionRegistry('elb.actions')

filters.register('tag-count', tags.TagCountFilter)
filters.register('marked-for-op', tags.TagActionFilter)
filters.register('shield-enabled', IsShieldProtected)
filters.register('shield-metrics', ShieldMetrics)


@resources.register('elb')
class ELB(QueryResourceManager):

    class resource_type(object):
        service = 'elb'
        resource_type = 'elasticloadbalancing:loadbalancer'
        type = 'loadbalancer'
        enum_spec = ('describe_load_balancers',
                     'LoadBalancerDescriptions', None)
        detail_spec = None
开发者ID:jpoley,项目名称:cloud-custodian,代码行数:33,代码来源:elb.py

示例2: import

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
from c7n.query import QueryResourceManager, ResourceQuery
from c7n.tags import RemoveTag, Tag, TagActionFilter, TagDelayedAction
from c7n.utils import (
    chunks, local_session, set_annotation, type_schema, dumps, get_account_id)

"""
TODO:
 - How does replication status effect in place encryption.
 - Test glacier support
"""

log = logging.getLogger('custodian.s3')

filters = FilterRegistry('s3.filters')
actions = ActionRegistry('s3.actions')
filters.register('marked-for-op', TagActionFilter)
actions.register('auto-tag-user', AutoTagUser)

MAX_COPY_SIZE = 1024 * 1024 * 1024 * 2


@resources.register('s3')
class S3(QueryResourceManager):

    #resource_type = "aws.s3.bucket"

    class resource_type(ResourceQuery.resolve("aws.s3.bucket")):
        dimension = 'BucketName'

    executor_factory = executor.ThreadPoolExecutor
    filter_registry = filters
开发者ID:andrewalexander,项目名称:cloud-custodian,代码行数:33,代码来源:s3.py

示例3: import

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
    CrossAccountAccessFilter)
import c7n.filters.vpc as net_filters

from c7n.manager import resources
from c7n.resolver import ValuesFrom
from c7n.query import QueryResourceManager
from c7n import tags
from c7n.utils import (
    type_schema, local_session, chunks, generate_arn, get_retry,
    snapshot_identifier)

log = logging.getLogger('custodian.redshift')

filters = FilterRegistry('redshift.filters')
actions = ActionRegistry('redshift.actions')
filters.register('marked-for-op', tags.TagActionFilter)


@resources.register('redshift')
class Redshift(QueryResourceManager):

    class resource_type(object):
        service = 'redshift'
        type = 'cluster'
        enum_spec = ('describe_clusters', 'Clusters', None)
        detail_spec = None
        name = id = 'ClusterIdentifier'
        filter_name = 'ClusterIdentifier'
        filter_type = 'scalar'
        date = 'ClusterCreateTime'
        dimension = 'ClusterIdentifier'
开发者ID:jpoley,项目名称:cloud-custodian,代码行数:33,代码来源:redshift.py

示例4: FilterRegistry

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
from c7n.actions import ActionRegistry, BaseAction
from c7n.filters import FilterRegistry

from c7n.manager import ResourceManager, resources
from c7n.offhours import Time, OffHour, OnHour
from c7n.tags import TagActionFilter, DEFAULT_TAG
from c7n.utils import local_session, query_instances, type_schema

log = logging.getLogger('custodian.asg')

filters = FilterRegistry('asg.filters')
actions = ActionRegistry('asg.actions')


filters.register('time', Time)
filters.register('offhour', OffHour)
filters.register('onhour', OnHour)
filters.register('marked-for-op', TagActionFilter)


@resources.register('asg')
class ASG(ResourceManager):

    filter_registry = filters
    action_registry = actions
    
    def resources(self):
        c = self.session_factory().client('autoscaling')
        query = self.resource_query()
        if self._cache.load():
开发者ID:amritpalbhatia,项目名称:cloud-custodian,代码行数:32,代码来源:asg.py

示例5: FilterRegistry

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
from c7n.actions import ActionRegistry, BaseAction
from c7n.filters import FilterRegistry, Filter, AgeFilter
from c7n.manager import resources
from c7n.query import QueryResourceManager
from c7n import tags
from c7n.utils import local_session, type_schema, get_account_id, chunks

from skew.resources.aws import rds

log = logging.getLogger('custodian.rds')

filters = FilterRegistry('rds.filters')
actions = ActionRegistry('rds.actions')

filters.register('tag-count', tags.TagCountFilter)
filters.register('marked-for-op', tags.TagActionFilter)


@resources.register('rds')
class RDS(QueryResourceManager):

    class resource_type(rds.DBInstance.Meta):
        filter_name = 'DBInstanceIdentifier'

    filter_registry = filters
    action_registry = actions
    account_id = None

    def augment(self, resources):
        session = local_session(self.session_factory)
开发者ID:zeroXten,项目名称:cloud-custodian,代码行数:32,代码来源:rds.py

示例6: import

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
    OPERATORS)
from c7n.filters.offhours import OffHour, OnHour
import c7n.filters.vpc as net_filters

from c7n.manager import resources
from c7n.query import QueryResourceManager
from c7n.tags import TagActionFilter, DEFAULT_TAG, TagCountFilter, TagTrim
from c7n.utils import (
    local_session, type_schema, chunks, get_retry, worker)

log = logging.getLogger('custodian.asg')

filters = FilterRegistry('asg.filters')
actions = ActionRegistry('asg.actions')

filters.register('offhour', OffHour)
filters.register('onhour', OnHour)
filters.register('tag-count', TagCountFilter)
filters.register('marked-for-op', TagActionFilter)
actions.register('auto-tag-user', AutoTagUser)


@resources.register('asg')
class ASG(QueryResourceManager):

    class resource_type(object):
        service = 'autoscaling'
        type = 'autoScalingGroup'
        id = name = 'AutoScalingGroupName'
        date = 'CreatedTime'
        dimension = 'AutoScalingGroupName'
开发者ID:kapilt,项目名称:cloud-custodian,代码行数:33,代码来源:asg.py

示例7: FilterRegistry

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
from c7n.actions import ActionRegistry, BaseAction
from c7n.exceptions import PolicyValidationError
from c7n.filters import Filter, FilterRegistry, ValueFilter
from c7n.filters.missing import Missing
from c7n.manager import ResourceManager, resources
from c7n.utils import local_session, type_schema

from c7n.resources.iam import CredentialReport


filters = FilterRegistry('aws.account.actions')
actions = ActionRegistry('aws.account.filters')


filters.register('missing', Missing)


def get_account(session_factory, config):
    session = local_session(session_factory)
    client = session.client('iam')
    aliases = client.list_account_aliases().get(
        'AccountAliases', ('',))
    name = aliases and aliases[0] or ""
    return {'account_id': config.account_id,
            'account_name': name}


@resources.register('account')
class Account(ResourceManager):
开发者ID:tim-elliott,项目名称:cloud-custodian,代码行数:31,代码来源:account.py

示例8: set

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
        group_ids = set()
        for r in resources:
            group_ids.update(
                [s['SubnetIdentifier'] for s in
                 self.groups[r['CacheSubnetGroupName']]['Subnets']])
        return group_ids

    def process(self, resources, event=None):
        self.groups = {
            r['CacheSubnetGroupName']: r for r in
            self.manager.get_resource_manager(
                'cache-subnet-group').resources()}
        return super(SubnetFilter, self).process(resources, event)


filters.register('network-location', net_filters.NetworkLocation)


@actions.register('delete')
class DeleteElastiCacheCluster(BaseAction):
    """Action to delete an elasticache cluster

    To prevent unwanted deletion of elasticache clusters, it is recommended
    to include a filter

    :example:

        .. code-block: yaml

            policies:
              - name: elasticache-delete-stale-clusters
开发者ID:kapilt,项目名称:cloud-custodian,代码行数:33,代码来源:elasticache.py

示例9: import

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
    OPERATORS)
from c7n.filters.offhours import OffHour, OnHour
import c7n.filters.vpc as net_filters

from c7n.manager import resources
from c7n.query import QueryResourceManager
from c7n.tags import TagActionFilter, DEFAULT_TAG, TagCountFilter, TagTrim
from c7n.utils import (
    local_session, query_instances, type_schema, chunks, get_retry, worker)

log = logging.getLogger('custodian.asg')

filters = FilterRegistry('asg.filters')
actions = ActionRegistry('asg.actions')

filters.register('offhour', OffHour)
filters.register('onhour', OnHour)
filters.register('tag-count', TagCountFilter)
filters.register('marked-for-op', TagActionFilter)
actions.register('auto-tag-user', AutoTagUser)


@resources.register('asg')
class ASG(QueryResourceManager):

    resource_type = "aws.autoscaling.autoScalingGroup"
    id_field = 'AutoScalingGroupName'
    report_fields = [
        'AutoScalingGroupName',
        'count:Instances',
        'tag:ASV',
开发者ID:tabladrum,项目名称:cloud-custodian,代码行数:33,代码来源:asg.py

示例10: FilterRegistry

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
from c7n.filters.offhours import OffHour, OnHour
from c7n.filters.health import HealthEventFilter
import c7n.filters.vpc as net_filters

from c7n.manager import resources
from c7n.query import QueryResourceManager

from c7n import utils
from c7n.utils import type_schema


filters = FilterRegistry('ec2.filters')
actions = ActionRegistry('ec2.actions')

actions.register('auto-tag-user', AutoTagUser)
filters.register('health-event', HealthEventFilter)


@resources.register('ec2')
class EC2(QueryResourceManager):

    class resource_type(object):
        service = 'ec2'
        type = 'instance'
        enum_spec = ('describe_instances', 'Reservations[].Instances[]', None)
        detail_spec = None
        id = 'InstanceId'
        filter_name = 'InstanceIds'
        filter_type = 'list'
        name = 'PublicDnsName'
        date = 'LaunchTime'
开发者ID:JJediny,项目名称:cloud-custodian,代码行数:33,代码来源:ec2.py

示例11: import

# 需要导入模块: from c7n.filters import FilterRegistry [as 别名]
# 或者: from c7n.filters.FilterRegistry import register [as 别名]
from c7n.filters.health import HealthEventFilter
import c7n.filters.vpc as net_filters
from c7n.manager import resources
from c7n.query import QueryResourceManager
from c7n import tags
from c7n.utils import (
    local_session, type_schema,
    get_retry, chunks, generate_arn, snapshot_identifier)
from c7n.resources.kms import ResourceKmsKeyAlias

log = logging.getLogger('custodian.rds')

filters = FilterRegistry('rds.filters')
actions = ActionRegistry('rds.actions')

filters.register('tag-count', tags.TagCountFilter)
filters.register('marked-for-op', tags.TagActionFilter)
filters.register('health-event', HealthEventFilter)
actions.register('auto-tag-user', AutoTagUser)


@resources.register('rds')
class RDS(QueryResourceManager):
    """Resource manager for RDS DB instances.
    """

    class resource_type(object):
        service = 'rds'
        type = 'db'
        enum_spec = ('describe_db_instances', 'DBInstances', None)
        id = 'DBInstanceIdentifier'
开发者ID:naveenb29,项目名称:cloud-custodian,代码行数:33,代码来源:rds.py


注:本文中的c7n.filters.FilterRegistry.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。