Пример #1
0
 def getConfig(self, sectionNames=None):
     sectionNames = sectionNames or [self.mainSectionName]
     configDict = {
         '%s_%s' % (sectionName, k): v
         for sectionName in sectionNames
         for k, v in self.section(sectionName).items()
     }
     config = Enum(**configDict)
     return config
 def _initLogger(self, configuration):
     self.cfg.logger = logger
     level = Enum(**dict(CRITICAL=logging.CRITICAL,
                         FATAL=logging.CRITICAL,
                         ERROR=logging.ERROR,
                         WARNING=logging.WARNING,
                         WARN=logging.WARNING,
                         INFO=logging.INFO,
                         DEBUG=logging.DEBUG,
                         NOTSET=logging.NOTSET))
     self.cfg.LOG_LEVEL = level
     self.cfg.logger.setLevel(
         getattr(level, configuration.get('log', 'level')))
Пример #3
0
    def __init__(self, **kwargs):
        '''
        Constructor
        '''
        self.ENUM = Enum()
        self.template = Enum()
        self.params = Enum()
        self.template.fields = 'fields=%(fields)s'
        self.params.fields = []  #join on comma
        self.template.offset = 'offset=%(offset)s'
        self.params.offset = 0  #pagination offset
        self.template.limit = 'limit=%(limit)s'
        self.params.limit = 20  #pagination limit, max per page

        self.template.fieldName_searchTerm = 'qterm.field.%(fieldName)s=%(searchTerm)s'
        self.params.fieldName = ''
        self.params.searchTerm = ''
        self.template.fieldName_groupByValues = 'filter.group.%(fieldName)s=%(groupByValues)s'
        self.params.groupByValues = []  #join on comma
        #        self.getGroupByValues = lambda: ','.join(self._groupByValues)
        self.ENUM.ORDER_BY = Enum(**{'asc': 'ASC', 'desc': 'DESC'})
        self.template.fieldName_order = 'orderBy=%(fieldName)s %(order)s'
        self.params.order = self.ENUM.ORDER_BY.asc
        self.template.containerId = 'containerId=%(containerId)s'
        self.params.containerId = ''
        self.ENUM.VERSION_OPTIONS = Enum(
            **{
                'in_progress': 'VERSION_INPROGRESS_OPT',
                'head': 'VERSION_HEAD_OPT',
                'in_progress_head': 'VERSION_INPROGRESS_HEAD_OPT',
                'all': 'VERSION_ALL_OPT',
                'na': 'VERSION_NA_OPT'
            })

        self.template.version = 'versionOpt=%(version)s'
        self.params.version = self.ENUM.VERSION_OPTIONS.all
        self.template.deleted = 'deleteOpt=%(deleted)s'
        self.params.deleted = 'DELETED_FALSE_OPT'
        self.ENUM.USAGE_PERMISSION = Enum(**{'use': 'use', 'view': 'view'})
        self.template.usage = 'usage=%(usage)s'
        self.params.usage = self.ENUM.USAGE_PERMISSION.use

        self.params.__dict__.update(kwargs)
from core.base.enum import Enum

CredentialType = Enum(
    **{
        'Username/Password': '******',
        'Encrypt/Decrypt': 'Encrypt/Decrypt',
        'Certificate with Private Key': 'Certificate with Private Key',
        'SSH': 'SSH',
        'Certificate/PK': 'Certificate/PK'
    })
from core.base.enum import Enum

ScriptErrorAction = Enum(**{
    'Abort': 'Abort',
    'Continue': 'Continue',
    'SkipPackage': 'SkipPackage'
})
Пример #6
0
from core.base.enum import Enum

ProxyType = Enum(
    **{
        'PROXY_SOCKS5': 'PROXY_SOCKS5',
        'PROXY_HTTP': 'PROXY_HTTP',
        'PROXY_HTTPS': 'PROXY_HTTPS'
    })
from core.base.enum import Enum

ProxyUsage = Enum(
    **{
        'PROXY_MANAGER_CLOUD': 'PROXY_MANAGER_CLOUD',
        'PROXY_INSTANCE_PROVIDER': 'PROXY_INSTANCE_PROVIDER',
        'PROXY_MANAGER_INSTANCE': 'PROXY_MANAGER_INSTANCE',
        'PROXY_ALL': 'PROXY_ALL',
        'PROXY_CLIENTS_INSTANCE': 'PROXY_CLIENTS_INSTANCE'
    })
Пример #8
0
from core.base.enum import Enum

AuthType = Enum(
    **{
        'AUTH_SESSION': 'AUTH_SESSION',
        'AUTH_CONFIGURED': 'AUTH_CONFIGURED',
        'AUTH_NONE': 'AUTH_NONE'
    })
Пример #9
0
from core.base.enum import Enum

RaidLevel = Enum(**{'raid5': 'raid5', 'striped': 'striped', 'linear': 'linear', 'mirrored': 'mirrored'})
Пример #10
0
from core.base.enum import Enum

ImportMode = Enum(
    **{
        'Create': 'Create',
        'Lookup': 'Lookup',
        'Update': 'Update',
        'CreateOrUpdate': 'CreateOrUpdate',
        'Delete': 'Delete'
    })
from core.base.enum import Enum

ErrorLevel = Enum(
    **{
        'info': 'info',
        'fatal': 'fatal',
        'none': 'none',
        'warning': 'warning',
        'error': 'error'
    })
Пример #12
0
'''
Created on Nov 30, 2012

Basically a compensation for non straight forward or miss-spelled asset<->service name mappings

@author: dawood
'''
from collections import defaultdict
from core.base.enum import Enum
import re

SERVICE_ACTION = Enum(**{'GET': 'get', 'SEARCH': 'search'})


def lookup(asset, action=SERVICE_ACTION.GET):
    serviceName = None
    if action == SERVICE_ACTION.GET:
        serviceNameOrPattern = SERVICE_GET_NAMES[asset]
    elif action == SERVICE_ACTION.SEARCH:
        serviceNameOrPattern = SERVICE_SEARCH_NAMES[asset]
    if serviceNameOrPattern is None:
        raise RuntimeError('No %s service for asset %s' % (action, asset))
    if re.match('.*%\(.*\)s.*', serviceNameOrPattern):
        serviceName = serviceNameOrPattern % {'assetName': asset}
    return serviceName or serviceNameOrPattern


lookup.ACTION = SERVICE_ACTION

SERVICE_GET_NAMES = defaultdict(lambda: 'get%(assetName)s')
from core.base.enum import Enum

ResourceMetricType = Enum(
    **{
        'workload': 'workload',
        'inetaddr': 'inetaddr',
        'vcpu': 'vcpu',
        'cost': 'cost',
        'memory': 'memory',
        'disk': 'disk'
    })
Пример #14
0
                ]  #include leafs of ke.objectID
            else:
                [
                    flatmap.update([
                        ('%s%s%s.%s' %
                         (parentKey, '.' if parentKey else '', k, item[0]),
                         item[1])
                    ]) for item in idmap(v, keyField='id',
                                         defaultToIndex=True).items()
                ]
        else:
            flatmap['%s%s%s' % (parentKey, '.' if parentKey else '', k)] = v
    return flatmap


SELECT_FIELDS_MATCH = Enum(
    **dict(PREFIX='prefix', SUFFIX='suffix', REGEX='regex'))


def selectFields(item,
                 fields=None,
                 factory=dict,
                 ignore=False,
                 default=None,
                 match=SELECT_FIELDS_MATCH.PREFIX,
                 flatten=False):
    '''
    selects a subset of dict (key, value) pairs or object attribute (name, value) pairs
    behaves differently from selectFieldsWith[Prefix, Suffix, Regex] is that it selects the set of fields as provided in the args 
    in addition to expanding the field set with the matched fields, which is more suitable for reports since it will preserve the columns provided, and expand on them if applicable
    For example: 
    fields = ['id', 'name', 'properties'] and match=SUFFIX
Пример #15
0
from core.base.enum import Enum

ScriptState = Enum(
    **{
        'Unknown': 'Unknown',
        'Running': 'Running',
        'Success': 'Success',
        'Failed': 'Failed'
    })
Пример #16
0
from core.base.enum import Enum

RepositoryUsage = Enum(
    **{
        'VM_TEMPLATES': 'VM_TEMPLATES',
        'VM_STORAGE': 'VM_STORAGE',
        'VM_ATTACHMENTS': 'VM_ATTACHMENTS',
        'VM_NONE': 'VM_NONE',
        'VM_BACKUPS': 'VM_BACKUPS',
        'VM_ARTIFACTS': 'VM_ARTIFACTS',
        'VM_INSTANCES': 'VM_INSTANCES'
    })
from core.base.enum import Enum

LookupFailCode = Enum(**{'Fail': 'Fail', 'Continue': 'Continue'})
from core.base.enum import Enum

AccessListDirection = Enum(**{'Input': 'Input', 'Output': 'Output'})
Пример #19
0
from core.base.enum import Enum

ValueConstraintType = Enum(**{'tree': 'tree', 'none': 'none', 'list': 'list'})
Пример #20
0
from core.base.enum import Enum

State = Enum(**{'Destroyed': 'Destroyed', 'Unknown': 'Unknown', 'Paused': 'Paused', 'Failed': 'Failed', 'Running': 'Running', 'Stopped': 'Stopped', 'Stopping': 'Stopping', 'Degraded': 'Degraded', 'Starting': 'Starting'})
Пример #21
0
'''
Created on Nov 30, 2012

@author: dawood
'''
from agilityshell import agility
from logger import logger
from core.base.enum import Enum
__all__ = ['assignedResources', 'diffAssignedResources', 'diffAssignedDisks', 'disks', 'nics', 'processors', 'memory']


RESOURCE_TYPES = Enum(**{'ETHERNET_ADAPTER' : 'Ethernet Adapter',
                         'DISK_DRIVE' : 'Disk Drive',
                         'PROCESSOR' : 'Processor', 
                         'MEMORY' : 'Memory'
                         })
#aliases
getField = agility.tools.scripting.getField
selectFields = agility.tools.scripting.selectFields
#building blocks
asList = lambda r: r if isinstance(r, (tuple, list)) else [r]
resourcesOf = lambda compute, resourceType=RESOURCE_TYPES.DISK_DRIVE: [r for r in compute.get('resources', default=[], wrapper=asList) if getField(r, 'resourceType', '') == resourceType]
disks = lambda compute: resourcesOf(compute, RESOURCE_TYPES.DISK_DRIVE)
nics = lambda compute: resourcesOf(compute, RESOURCE_TYPES.ETHERNET_ADAPTER)
processors = lambda compute: resourcesOf(compute, RESOURCE_TYPES.PROCESSOR)
memory = lambda compute: resourcesOf(compute, RESOURCE_TYPES.MEMORY)
    
def assignedResources(computeList, resourceType=RESOURCE_TYPES.DISK_DRIVE, removeEmpty=True):
    '''
    returns a map of compute.id : list of resource entries where resourceType == 'Disk Drive'
    '''
Пример #22
0
from agilityshell import agility as a, agility
from logger import logger
import re
#some shorthands
idmap = a.tools.scripting.idmap
namemap = a.tools.scripting.namemap

validSymbol = a.tools.scripting.validSymbol

DEFAULT_TREE = {'container' : {
                               'container' : {}, 'customContainer' : {}, 'package' : {}, 'containerRight' : {}, 'policy' : {}, 'script' : {}, 'domain' : {}, 'project' : {}, 'stack' : {}
                               }
                }
TYPE = Enum(**{'ASSET_LIST' : 'AssetList',
               'ASSET_MAP' : 'AssetMap',
               'ASSET' : 'Asset',
               'ASSET_SUMMARY' : 'AssetSummary'
               })

containerTypes = ['Container', 'Project', 'Topology', 'Template', 'Stack', 'Package', 'Script', 'Instances', 'ContainerRight', 'Policy']

hasattrs = lambda obj, attrlist: all([getattr(obj, attr, None) for attr in attrlist])
allhaveattrs = lambda sequence, attrlist: all([hasattrs(item, attrlist) for item in sequence])


def deeptype(obj):
    idandtype = ['id', 'type']
    type_ = type(obj)
    if isinstance(obj, (list, tuple)):
        if allhaveattrs(obj, idandtype):
            type_ = TYPE.ASSET_LIST
Пример #23
0
from core.base.enum import Enum

Architecture = Enum(**{'x86_64': 'x86_64', 'i386': 'i386', 'Any': 'Any'})
from core.base.enum import Enum

LaunchItemState = Enum(
    **{
        'Ordered': 'Ordered',
        'Failed': 'Failed',
        'Unknown': 'Unknown',
        'DeployPending': 'DeployPending',
        'Deleting': 'Deleting',
        'Rejected': 'Rejected',
        'Paused': 'Paused',
        'Released': 'Released',
        'Running': 'Running',
        'Stopped': 'Stopped',
        'Deploying': 'Deploying',
        'DeployFailed': 'DeployFailed',
        'Stopping': 'Stopping',
        'OrderFailed': 'OrderFailed',
        'Degraded': 'Degraded',
        'OrderProvisioning': 'OrderProvisioning',
        'Starting': 'Starting',
        'OrderPending': 'OrderPending',
        'Deployed': 'Deployed'
    })
Пример #25
0
from core.base.enum import Enum

DeploymentState = Enum(
    **{
        'Failed': 'Failed',
        'Unknown': 'Unknown',
        'Released': 'Released',
        'Running': 'Running',
        'Stopped': 'Stopped',
        'Stopping': 'Stopping',
        'Starting': 'Starting',
        'Deployed': 'Deployed'
    })
ResourceType = Enum(
    **{
        'DVD Drive': 'DVD Drive',
        'Graphics Controller': 'Graphics Controller',
        'Other': 'Other',
        'Memory': 'Memory',
        'Other Storage': 'Other Storage',
        'Parallel SCSI HBA': 'Parallel SCSI HBA',
        'Other Network Adapter': 'Other Network Adapter',
        'IEEE 1394 Controller': 'IEEE 1394 Controller',
        'PCI Controller': 'PCI Controller',
        'Storage Extent': 'Storage Extent',
        'SIO Controller': 'SIO Controller',
        'PS2 Controller': 'PS2 Controller',
        'CD Drive': 'CD Drive',
        'None': 'None',
        'iSCSI HBA': 'iSCSI HBA',
        'Base Partitionable Unit': 'Base Partitionable Unit',
        'Keyboard': 'Keyboard',
        'Power Supply': 'Power Supply',
        'IB HCA': 'IB HCA',
        'Ethernet Adapter': 'Ethernet Adapter',
        'Processor': 'Processor',
        'Pointing Device': 'Pointing Device',
        'Disk Drive': 'Disk Drive',
        'Serial Port': 'Serial Port',
        'Floppy Drive': 'Floppy Drive',
        'Parallel Port': 'Parallel Port',
        'USB Controller': 'USB Controller',
        'I/O Device': 'I/O Device',
        'Tape Drive': 'Tape Drive',
        'Computer': 'Computer',
        'FC HBA': 'FC HBA',
        'I/O Slot': 'I/O Slot',
        'Cooling Device': 'Cooling Device',
        'Partitionable Unit': 'Partitionable Unit',
        'IDE Controller': 'IDE Controller'
    })
Пример #27
0
from core.base.enum import Enum

Product = Enum(
    **{
        'None': 'None',
        'Planner': 'Planner',
        'Factory': 'Factory',
        'Platform': 'Platform',
        'Manager': 'Manager',
        'CenterPoint': 'CenterPoint'
    })
from core.base.enum import Enum

ResourceAffinity = Enum(
    **{
        'None': 'None',
        'Host': 'Host',
        'Network': 'Network',
        'Cloud': 'Cloud',
        'Location': 'Location'
    })
Пример #29
0
import logging
import os
import reporter

from queries.exportcsv import customReport
from core.base.enum import Enum
from xlswriter import ExcelReport

from reporting import LOGGER_NAME
COMPONENT_NAME = LOGGER_NAME
import logger
logger = logger.getLogger('%s.%s' % (COMPONENT_NAME, __name__))

COMPARE_MODE = Enum(
    **{
        'EXACT': 'master_equal_slave',
        'MASTER_INTACT': 'master_subset_slave',
        'SLAVE_INTACT': 'slave_subset_master'
    })

DIFF_REPORT_INCLUDE = Enum(
    **{
        'ALL': 'delete_insert_replace',
        'DELETED': 'delete',
        'ADDED': 'insert',
        'MODIFIED': 'replace',
        'EQUAL': 'equal'
    })

COMPARE_OPCODES = Enum(**{
    'EQUAL': 'equal',
    'REPLACE': 'replace',
from core.base.enum import Enum

ScriptType = Enum(
    **{
        'Platform': 'Platform',
        'Configuration': 'Configuration',
        'Guest': 'Guest',
        'Provider': 'Provider'
    })