/
opt
/
cloudlinux
/
venv
/
lib64
/
python3.11
/
site-packages
/
clwpos
/
feature_suites
/
Upload Filee
HOME
# -*- coding: utf-8 -*- # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2022 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT # suites.py - definitions of AccelerateWP feature suites from enum import Enum from typing import Set, List, Dict, Any from clwpos.optimization_features import ( Feature, OBJECT_CACHE_FEATURE, SITE_OPTIMIZATION_FEATURE, CDN_FEATURE, CRITICAL_CSS_FEATURE, IMAGE_OPTIMIZATION_FEATURE ) from dataclasses import dataclass, field PREMIUM_ENABLE_FLAG = '/var/lve/enable-wpos.flag' IS_FREE_SUITE_ALLOWED_BY_DEFAULT = False IS_PREMIUM_SUITE_ALLOWED_BY_DEFAULT = False IS_CDN_SUITE_ALLOWED_BY_DEFAULT = False class TrafficLimit(Enum): LIMIT_50_GB = "50 GB" LIMIT_100_GB = "100 GB" LIMIT_250_GB = "250 GB" LIMIT_500_GB = "500 GB" LIMIT_1_TB = "1 TB" LIMIT_2_5_TB = "2.5 TB" LIMIT_5_TB = "5 TB" LIMIT_10_TB = "10 TB" @dataclass class Attribute: """Base model of attribute supported by suite""" name: str type: type default: Any = None @dataclass class Suite: """Base Suite implementation""" name: str features: Set # for some cases we need to handle only primary feature (e.g for CDN suite = cdn feature) primary: Set is_allowed_by_default: bool billable_features: Set[Feature] = field(default_factory=set) allowed_attrubites: List[Attribute] = field(default_factory=list) @property def feature_set(self) -> Set[Feature]: """""" return self.features @property def primary_features(self) -> Set[Feature]: """""" return self.primary def non_billable_features(self) -> Set[Feature]: return self.primary.difference(self.billable_features) AWPSuite = Suite( name='accelerate_wp', features={ SITE_OPTIMIZATION_FEATURE }, primary={ SITE_OPTIMIZATION_FEATURE }, is_allowed_by_default=IS_FREE_SUITE_ALLOWED_BY_DEFAULT ) PremiumSuite = Suite( name='accelerate_wp_premium', features={ OBJECT_CACHE_FEATURE, CRITICAL_CSS_FEATURE, IMAGE_OPTIMIZATION_FEATURE }, primary={ OBJECT_CACHE_FEATURE, CRITICAL_CSS_FEATURE, IMAGE_OPTIMIZATION_FEATURE }, is_allowed_by_default=IS_PREMIUM_SUITE_ALLOWED_BY_DEFAULT, billable_features={ CRITICAL_CSS_FEATURE, IMAGE_OPTIMIZATION_FEATURE } ) # Free CDN suite (1GB) CDNSuite = Suite( name='accelerate_wp_cdn', features={ SITE_OPTIMIZATION_FEATURE, CDN_FEATURE }, primary={ CDN_FEATURE }, is_allowed_by_default=IS_CDN_SUITE_ALLOWED_BY_DEFAULT, billable_features={ CDN_FEATURE } ) # Premium CDN suite (50GB) CDNSuitePro = Suite( name='accelerate_wp_cdn_pro', features={ SITE_OPTIMIZATION_FEATURE, CDN_FEATURE }, primary={ CDN_FEATURE }, is_allowed_by_default=IS_PREMIUM_SUITE_ALLOWED_BY_DEFAULT, billable_features={ CDN_FEATURE }, allowed_attrubites=[ Attribute(name='traffic_limit', type=TrafficLimit, default=TrafficLimit.LIMIT_50_GB) ] ) ALL_SUITES: Dict[str, Suite] = { AWPSuite.name: AWPSuite, PremiumSuite.name: PremiumSuite, CDNSuite.name: CDNSuite, CDNSuitePro.name: CDNSuitePro } SUPPORTED_SUITES = { AWPSuite.name: AWPSuite, PremiumSuite.name: PremiumSuite, CDNSuite.name: CDNSuite, CDNSuitePro.name: CDNSuitePro } UNSUPPORTED_SUITES_FOR_RESELLER = [ PremiumSuite.name, CDNSuite.name, CDNSuitePro.name, ] # for backward compatibility with old configs OLD_NEW_SUITE_NAME_PAIRS = { 'object_cache': 'accelerate_wp_premium', 'site_optimization': 'accelerate_wp' }