class ConfigFile(entity.Immutable): @pyargs_validator.validate(basestring, basestring, pyargs_validator.optional(Date), pyargs_validator.optional(list)) def __init__(self, fullpath, content=None, last_modified_time=None, db_sources=None): """ :param fullpath: Full path to config file :type fullpath: str or unicode :param content: File's content :type content: str or unicode :param last_modified_time: Date :type last_modified_time: Date :param db_sources: list of Datasources which was found in the passed content :type db_sources: list[NamedDbSource] """ self.fullpath = fullpath self.content = content self.last_modified_time = last_modified_time self.db_sources = db_sources def __repr__(self): return '%s(%s)' % (str(self.__class__), ', '.join( imap(repr, (self.fullpath, self.last_modified_time))))
class FcPort( collections.namedtuple('FcPort', ('id', 'wwn', 'type', 'name', 'speed'))): @validate(not_none, optional, wwn.WWN, optional(basestring), optional(basestring), optional(float)) def __new__(cls, id, wwn, type=None, name=None, speed=None): return super(FcPort, cls).__new__(cls, id, wwn, type, name, speed)
class WebSiteConfigurationFilePathCmd(PowerShellScriptCmd): SCRIPT_BLOCK = "Get-WebConfigFile -PSPath \"%s\"" @pyargs_validator.validate(basestring, pyargs_validator.optional(object)) def __init__(self, path, handler=None): PowerShellScriptCmd.__init__(self, handler=handler, properties=['fullname']) self.cmdline = self.cmdline % path
class WebDir(entity.Immutable): @pyargs_validator.validate(basestring, basestring, pyargs_validator.optional(list)) def __init__(self, resource_path, physical_path, config_files=None): """ :param resource_path: Resource path - absolute path from root of website :type resource_path: str or unicode :param physical_path: Full physical path on the file syste, :type physical_path: str or unicode :param config_files: Collection of config files which was find under cur dir :type config_files: list[iis.ConfigFile] """ self.path = resource_path self.physical_path = physical_path self.config_files = config_files self.name = self.__get_name(resource_path) self.root_path = self.__getRoot(resource_path) @pyargs_validator.validate(basestring) def __get_name(self, path): """ :param path: resource path of folder :type path: str or unicode :return: last name of folder in the path :rtype: str or unicode """ if not path: return None s = path.rstrip("/") pos = s.rfind("/") if pos != -1 and pos != len(path) - 1: return s[pos + 1:] else: return s @pyargs_validator.validate(basestring) def __getRoot(self, path): """ :param path: resource path of folder :type path: str or unicode :return: first name of folder in the path :rtype: str or unicode """ if not path: return None s = path.rstrip("/") pos = s.rfind("/") if pos != -1 and pos != len(path) - 1: return s[:pos] or None else: return None def __repr__(self): return '%s(%s)' % (str(self.__class__), ', '.join( imap(repr, (self.path, self.physical_path, self.config_files))))
class FcHba( collections.namedtuple( 'FcHba', ('id', 'name', 'wwn', 'vendor', 'model', 'serial_number', 'driver_version', 'firmware_version'))): @validate(not_none, not_none, basestring, optional(wwn.WWN), optional(basestring), optional(basestring), optional(basestring), optional(basestring), optional(basestring)) def __new__(cls, id, name, wwn=None, vendor=None, model=None, serial_number=None, driver_version=None, firmware_version=None): return super(FcHba, cls).__new__(cls, id, name, wwn, vendor, model, serial_number, driver_version, firmware_version) def __key__(self): return (self.wwn, self.serial_number) def __hash__(self): return hash(self.__key__())
class Site(entity.Immutable): @pyargs_validator.validate(basestring, list, AppPool, pyargs_validator.optional(int), pyargs_validator.optional(basestring), pyargs_validator.optional(list), pyargs_validator.optional(list), pyargs_validator.optional(list), pyargs_validator.optional(list)) def __init__(self, name, bindings, app_pool, state=None, path=None, config_files=None, web_applications=None, virtual_dirs=None, web_services=None): """ :param name: Web site's name :type name: str or unicode :param bindings: list of list which include the 3 items - hostname, port, list of endpoint :type bindings: list[list] :param app_pool: App Pool information :type app_pool: iis.AppPool :param state: State :type state: int :param path: Physical path of the website :type path: str or unicode :param config_files: Config files which are using :type config_files: list(iis.ConfigFile) :param web_applications: List of application which are configured :type web_applications: list[iis.WebApplication] :param virtual_dirs: List of virtual dirs which are configured :type virtual_dirs: list[iis.VirtualDirectory] :param web_services: List of webservices which are configuref :type web_services: list[iis.WebService] """ self.name = name self.app_pool = app_pool self.bindings = bindings self.state = state self.path = path self.config_files = config_files self.web_applications = web_applications self.virtual_dirs = virtual_dirs self.web_services = web_services def is_ftp(self): protocols = imap(lambda obj: obj and obj[1].lower(), self.bindings) return 'ftp' in protocols def __repr__(self): return '%s(%s)' % (str(self.__class__), ', '.join( imap(repr, (self.name, self.bindings, self.app_pool, self.state, self.path, self.config_files, self.web_applications, self.virtual_dirs, self.web_services))))
class AppPool(entity.Immutable): @pyargs_validator.validate(basestring, basestring, pyargs_validator.optional(int)) def __init__(self, id, name, state=None): """ :param id: AppPool ID :type id: str or unicode :param name: AppPool :type name: str or unicode :param state: AppPool's state :type state: int """ self.name = name self.state = state self.id = id def __repr__(self): return '%s(%s)' % (str(self.__class__), ', '.join( imap(repr, (self.name, self.state))))
class WebService(WebApplication): @pyargs_validator.validate(basestring, basestring, basestring, pyargs_validator.optional(list)) def __init__(self, app_pool_name, resource_path, full_path, config_files=None): """ :param app_pool_name: AppPool's name which is used by WebService :type app_pool_name: str or unicode :param resource_path: resource path of application :type resource_path: str or unicode :param full_path: file system full path to the application :type full_path: str or unicode :param config_files: Config files which are using by the application :type config_files: list[iis.ConfigFile] """ WebApplication.__init__(self, app_pool_name, resource_path, full_path, config_files)
class Junction(collections.namedtuple('Junction', ('name', 'type'))): @validate(not_none, basestring, optional(basestring)) def __new__(cls, name, type=None): return super(Junction, cls).__new__(cls, name, type=type)
class Server(collections.namedtuple('Server', ('name', 'version'))): @validate(not_none, basestring, optional(basestring)) def __new__(cls, name, version=None): return super(Server, cls).__new__(cls, name, version=version)
# coding=utf-8 ''' Created on Feb 13, 2014 @author: ekondrashev ''' import entity from pyargs_validator import validate, optional import re @validate(basestring, optional(int)) def parse_from_str(wwn_in_str, base=None): ''' @types: str, int? -> wwn.WWN @raise: ValueError: on string to integer conversion failure ''' wwn_in_str = re.sub('[\:\-]', '', wwn_in_str) if not base: base = 16 if wwn_in_str.startswith("0x") or set(wwn_in_str) & set('abcdef' + 'ABCDEF'): base = 16 return WWN(int(wwn_in_str, base)) def normalize(wwn): ''' Creates wwn.WWN objects from:
class WebSiteCommand(PowerShellScriptCmd): @pyargs_validator.validate(basestring, pyargs_validator.optional(object)) def __init__(self, website_name, handler=None): PowerShellScriptCmd.__init__(self, handler=handler) self.cmdline = self.cmdline % website_name
# coding=utf-8 ''' Created on Feb 13, 2014 @author: ekondrashev ''' import entity from pyargs_validator import validate, optional import re @validate(basestring, optional(int)) def parse_from_str(wwn_in_str, base=None): ''' @types: str, int? -> wwn.WWN @raise: ValueError: on string to integer conversion failure ''' wwn_in_str = re.sub('[\:\-]', '', wwn_in_str) if not base: base = 16 if wwn_in_str.startswith("0x") or set(wwn_in_str) & set('abcdef' + 'ABCDEF'): base = 16 return WWN(int(wwn_in_str, base)) def normalize(wwn): ''' Creates wwn.WWN objects from: *string