本文整理汇总了Python中c7n.filters.FilterRegistry类的典型用法代码示例。如果您正苦于以下问题:Python FilterRegistry类的具体用法?Python FilterRegistry怎么用?Python FilterRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FilterRegistry类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import
from c7n.filters import (
Filter, FilterRegistry, DefaultVpcBase, ValueFilter,
ShieldMetrics)
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'
示例2: import
FilterRegistry, Filter, CrossAccountAccessFilter, MetricsFilter)
from c7n.manager import resources
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'
示例3: import
from c7n.filters import (
FilterRegistry, ValueFilter, DefaultVpcBase, AgeFilter, OPERATORS,
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'
示例4: FilterRegistry
from dateutil.tz import tzutc
import logging
import itertools
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
示例5: FilterRegistry
from botocore.exceptions import ClientError
from concurrent.futures import as_completed
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
示例6: import
from c7n.actions import Action, ActionRegistry, AutoTagUser
from c7n.filters import (
FilterRegistry, ValueFilter, AgeFilter, Filter, FilterValidationError,
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'
示例7: FilterRegistry
from datetime import datetime, timedelta
from dateutil.parser import parse as parse_date
from dateutil.tz import tzutc
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}
示例8: import
from dateutil.parser import parse
from c7n.actions import (
ActionRegistry, BaseAction, ModifyVpcSecurityGroupsAction)
from c7n.filters import FilterRegistry, AgeFilter, OPERATORS
import c7n.filters.vpc as net_filters
from c7n.manager import resources
from c7n.query import QueryResourceManager
from c7n.tags import universal_augment
from c7n.utils import (
local_session, generate_arn,
get_retry, chunks, snapshot_identifier, type_schema)
log = logging.getLogger('custodian.elasticache')
filters = FilterRegistry('elasticache.filters')
actions = ActionRegistry('elasticache.actions')
TTYPE = re.compile('cache.t')
@resources.register('cache-cluster')
class ElastiCacheCluster(QueryResourceManager):
class resource_type(object):
service = 'elasticache'
type = 'cluster'
enum_spec = ('describe_cache_clusters',
'CacheClusters[]', None)
name = id = 'CacheClusterId'
filter_name = 'CacheClusterId'
示例9: import
from c7n.actions import ActionRegistry, BaseAction, AutoTagUser
from c7n.filters import (
FilterRegistry, ValueFilter, AgeFilter, Filter, FilterValidationError,
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 = [
示例10: import
)
from c7n.filters import (
FilterRegistry, AgeFilter, ValueFilter, Filter, OPERATORS, DefaultVpcBase
)
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'
示例11: import
CrossAccountAccessFilter, FilterRegistry, Filter, AgeFilter, OPERATORS,
FilterValidationError)
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'