class StorageDriverPartition(DataObject):
    """
    The StorageDriverPartition class represents the junction table between StorageDriver and Partitions.
    Examples:
    * my_storagedriver.partitions[0].partition
    * my_partition.storagedrivers[0].storagedriver
    """
    SUBROLE = DataObject.enumerator('Role', ['FCACHE', 'FD', 'MD', 'MDS', 'SCO', 'TLOG'])

    __properties = [Property('number', int, doc='Number of the service in case there is more than one'),
                    Property('size', long, mandatory=False, doc='Size in bytes configured for use'),
                    Property('role', DiskPartition.ROLES.keys(), doc='Role of the partition'),
                    Property('sub_role', SUBROLE.keys(), mandatory=False, doc='Sub-role of this StorageDriverPartition')]
    __relations = [Relation('partition', DiskPartition, 'storagedrivers'),
                   Relation('storagedriver', StorageDriver, 'partitions'),
                   Relation('mds_service', MDSService, 'storagedriver_partitions', mandatory=False)]
    __dynamics = [Dynamic('folder', str, 3600),
                  Dynamic('path', str, 3600)]

    def _folder(self):
        """
        Folder on the mountpoint
        """
        if self.sub_role:
            return '{0}_{1}_{2}_{3}'.format(self.storagedriver.vpool.name, self.role.lower(), self.sub_role.lower(), self.number)
        return '{0}_{1}_{2}'.format(self.storagedriver.vpool.name, self.role.lower(), self.number)

    def _path(self):
        """
        Actual path on filesystem, including mountpoint
        """
        return '{0}/{1}'.format(self.partition.folder, self.folder)
예제 #2
0
class Service(DataObject):
    """
    A Service represents some kind of service that needs to be managed by the framework.
    """
    __properties = [
        Property('name', str, indexed=True, doc='Name of the Service.'),
        Property('ports', list, doc='Port(s) of the Service.')
    ]
    __relations = [
        Relation('storagerouter',
                 StorageRouter,
                 'services',
                 mandatory=False,
                 doc='The Storage Router running the Service.'),
        Relation('type',
                 ServiceType,
                 'services',
                 doc='The type of the Service.')
    ]
    __dynamics = [Dynamic('is_internal', bool, 3600)]

    def _is_internal(self):
        """
        Returns whether a service is internally managed by OVS or externally managed by customer
        """
        return self.storagerouter is not None
예제 #3
0
class MDSService(DataObject):
    """
    The MDSService class represents the junction table between the (metadataserver)Service and VPool.
    Examples:
    * my_vpool.mds_services[0].service
    * my_service.mds_service.vpool
    """
    __properties = [Property('number', int, doc='The number of the service in case there are more than one'),
                    Property('capacity', int, default=-1, doc='The capacity of this MDS, negative means infinite')]
    __relations = [Relation('vpool', VPool, 'mds_services'),
                   Relation('service', Service, 'mds_service', onetoone=True)]
    __dynamics = []

    def __init__(self, *args, **kwargs):
        """
        Initializes a MDSService, setting up its additional helpers
        """
        DataObject.__init__(self, *args, **kwargs)
        self._frozen = False
        self.metadataserver_client = None
        self._frozen = True
        self.reload_client()

    def reload_client(self):
        """
        Reloads the StorageDriver Client
        """
        if self.service:
            self._frozen = False
            self.metadataserver_client = MetadataServerClient.load(self.service)
            self._frozen = True
예제 #4
0
class VDiskDomain(DataObject):
    """
    The VDiskDomain class represents the junction table between vDisk and Domain.
    """
    __properties = []
    __relations = [Relation('domain', Domain, 'vdisks_dtl'),
                   Relation('vdisk', VDisk, 'domains_dtl')]
    __dynamics = []
예제 #5
0
class StorageDriver(DataObject):
    """
    The StorageDriver class represents a Storage Driver. A Storage Driver is an application
    on a Storage Router to which the vDisks connect. The Storage Driver is the gateway to the Storage Backend.
    """
    __properties = [Property('name', str, doc='Name of the Storage Driver.'),
                    Property('description', str, mandatory=False, doc='Description of the Storage Driver.'),
                    Property('ports', list, doc='Ports on which the Storage Driver is listening [mgmt, xmlrpc, foc].'),
                    Property('cluster_ip', str, doc='IP address on which the Storage Driver is listening.'),
                    Property('storage_ip', str, doc='IP address on which the vpool is shared to hypervisor'),
                    Property('storagedriver_id', str, doc='ID of the Storage Driver as known by the Storage Drivers.'),
                    Property('mountpoint', str, doc='Mountpoint from which the Storage Driver serves data'),
                    Property('mountpoint_temp', str, doc='Mountpoint for temporary workload (scrubbing etc)'),
                    Property('mountpoint_bfs', str, doc='Mountpoint for the backend filesystem (used for local and distributed fs)'),
                    Property('mountpoint_md', str, doc='Mountpoint for metadata'),
                    Property('mountpoint_readcache1', str, doc='Mountpoint for read cache 1'),
                    Property('mountpoint_readcache2', str, doc='Mountpoint for read cache 2'),
                    Property('mountpoint_writecache', str, doc='Mountpoint for write cache'),
                    Property('mountpoint_foc', str, doc='Mountpoint for failover cache')]
    __relations = [Relation('vpool', VPool, 'storagedrivers'),
                   Relation('storagerouter', StorageRouter, 'storagedrivers')]
    __dynamics = [Dynamic('status', str, 30),
                  Dynamic('statistics', dict, 0),
                  Dynamic('stored_data', int, 60)]

    def _status(self):
        """
        Fetches the Status of the Storage Driver.
        """
        _ = self
        return None

    def _statistics(self):
        """
        Aggregates the Statistics (IOPS, Bandwidth, ...) of the vDisks connected to the Storage Driver.
        """
        client = StorageDriverClient()
        vdiskstatsdict = {}
        for key in client.stat_keys:
            vdiskstatsdict[key] = 0
            vdiskstatsdict['{0}_ps'.format(key)] = 0
        if self.vpool is not None:
            for disk in self.vpool.vdisks:
                if disk.storagedriver_id == self.storagedriver_id:
                    for key, value in disk.statistics.iteritems():
                        if key != 'timestamp':
                            vdiskstatsdict[key] += value
        vdiskstatsdict['timestamp'] = time.time()
        return vdiskstatsdict

    def _stored_data(self):
        """
        Aggregates the Stored Data in Bytes of the vDisks connected to the Storage Driver.
        """
        if self.vpool is not None:
            return sum([disk.info['stored'] for disk in self.vpool.vdisks])
        return 0
예제 #6
0
class RoleClient(DataObject):
    """
    The RoleClient class represents the junction table between Role and Client.
    """
    __properties = []
    __relations = [
        Relation('role', Role, 'clients'),
        Relation('client', Client, 'roles')
    ]
    __dynamics = []
예제 #7
0
class RoleGroup(DataObject):
    """
    The RoleGroup class represents the junction table between Role and Group.
    """
    __properties = []
    __relations = [
        Relation('role', Role, 'groups'),
        Relation('group', Group, 'roles')
    ]
    __dynamics = []
예제 #8
0
class BackendDomain(DataObject):
    """
    The BackendDomain class represents the junction table between Backend and Domain.
    """
    __properties = []
    __relations = [
        Relation('domain', Domain, 'backends'),
        Relation('backend', Backend, 'domains')
    ]
    __dynamics = []
예제 #9
0
class RoleBearerToken(DataObject):
    """
    The RoleBearerToken class represents the junction table between Role and BearerToken.
    """
    __properties = []
    __relations = [
        Relation('role', Role, 'tokens'),
        Relation('token', BearerToken, 'roles')
    ]
    __dynamics = []
예제 #10
0
class BackendClient(DataObject):
    """
    The BackendClient class represents the junction table between a Client and a Backend, setting granted/deny rights
    Examples:
    * my_backend.client_rights[0].client
    * my_client.backend_rights[0].backend
    """
    __properties = [Property('grant', bool, doc='Whether the rights are granted (True) or denied (False)')]
    __relations = [Relation('backend', Backend, 'client_rights'),
                   Relation('client', Client, 'backend_rights')]
    __dynamics = []
예제 #11
0
class AlbaProxy(DataObject):
    """
    The AlbaProxy class represents the junction table between the (alba)Service and VPool.
    Examples:
    * my_storagedriver.alba_proxies[0].service
    * my_service.alba_proxy.storagedriver
    """
    __properties = []
    __relations = [
        Relation('storagedriver', StorageDriver, 'alba_proxies'),
        Relation('service', Service, 'alba_proxy', onetoone=True)
    ]
    __dynamics = []
class S3TransactionService(DataObject):
    """
    Represent the junction between the S3Transaction cluster and all its services.
    A service can represent any cluster and a cluster can have multiple services representing it
    Each ALBA ABM cluster can have several ABM services which each represent an ALBA Manager Arakoon cluster.
    This ABM cluster has 1 service representing a node of the ALBA Manager Arakoon cluster.
    """
    __properties = []
    __relations = [
        Relation('s3_transaction_cluster', S3TransactionCluster,
                 's3_transaction_services'),
        Relation('service', Service, 's3_transaction_service', onetoone=True)
    ]
    __dynamics = []
예제 #13
0
class NSMService(DataObject):
    """
    The NSMService class represents the junction table between the (Namespace Manager)Service and AlbaBackend.
    Each ALBA NSM cluster can have several NSM services which each represent a Namespace Manager Arakoon cluster.
    Each NSM service has 1 service representing a node of a Namespace Manager Arakoon cluster.
    Examples:
    * my_alba_backend.nsm_clusters[0].nsm_services
    * my_service.nsm_service.nsm_cluster.alba_backend
    """
    __properties = []
    __relations = [
        Relation('nsm_cluster', NSMCluster, 'nsm_services'),
        Relation('service', Service, 'nsm_service', onetoone=True)
    ]
    __dynamics = []
class ABMService(DataObject):
    """
    The ABMService class represents the junction table between the (ALBA Manager)Service and the ALBA Manager Arakoon cluster.
    Each ALBA ABM cluster can have several ABM services which each represent an ALBA Manager Arakoon cluster.
    This ABM cluster has 1 service representing a node of the ALBA Manager Arakoon cluster.
    Examples:
    * my_alba_backend.abm_cluster.abm_services
    * my_service.abm_service.abm_cluster.alba_backend
    """
    __properties = []
    __relations = [
        Relation('abm_cluster', ABMCluster, 'abm_services'),
        Relation('service', Service, 'abm_service', onetoone=True)
    ]
    __dynamics = []
class NSMCluster(DataObject):
    """
    The NSMCluster class represents the relation between an ALBA Backend and the Namespace Manager services.
    Each ALBA Backend has at least 1 Namespace Manager Arakoon cluster.
    Each NSM cluster has several services representing the nodes of the ALBA Namespace Manager Arakoon cluster.
    Examples:
    * my_alba_backend.nsm_clusters[0].nsm_services
    * my_service.nsm_service.nsm_cluster.alba_backend
    """
    __properties = [
        Property('name',
                 str,
                 unique=True,
                 doc='Name of the ALBA Namespace Manager Arakoon cluster'),
        Property(
            'number',
            int,
            doc='The number of the service in case there is more than one'),
        Property('capacity',
                 int,
                 default=50,
                 doc='The capacity of this NSM, negative means infinite'),
        Property(
            'config_location',
            str,
            unique=True,
            doc='Location of the ALBA Namespace Manager Arakoon configuration')
    ]
    __relations = [Relation('alba_backend', AlbaBackend, 'nsm_clusters')]
    __dynamics = []
예제 #16
0
class PMachine(DataObject):
    """
    The PMachine class represents a pMachine. A pMachine is the physical machine
    running the Hypervisor.
    """
    __properties = {Property('name', str, doc='Name of the pMachine.'),
                    Property('description', str, mandatory=False, doc='Description of the pMachine.'),
                    Property('username', str, doc='Username of the pMachine.'),
                    Property('password', str, mandatory=False, doc='Password of the pMachine.'),
                    Property('ip', str, doc='IP address of the pMachine.'),
                    Property('hvtype', ['HYPERV', 'VMWARE', 'XEN', 'KVM'], doc='Hypervisor type running on the pMachine.'),
                    Property('hypervisor_id', str, mandatory=False, doc='Hypervisor id - primary key on Management Center')}
    __relations = [Relation('mgmtcenter', MgmtCenter, 'pmachines', mandatory=False)]
    __dynamics = [Dynamic('host_status', str, 60)]

    def _host_status(self):
        """
        Returns the host status as reported by the management center (e.g. vCenter Server)
        """
        mgmtcentersdk = Factory.get_mgmtcenter(self)
        if mgmtcentersdk:
            if self.hypervisor_id:
                return mgmtcentersdk.get_host_status_by_pk(self.hypervisor_id)
            if self.ip:
                return mgmtcentersdk.get_host_status_by_ip(self.ip)
        return 'UNKNOWN'
예제 #17
0
class Backend(DataObject):
    """
    A Backend represents an instance of the supported backend types that has been setup with the OVS GUI
    """
    __properties = [Property('name', str, doc='Name of the Backend.'),
                    Property('status', ['NEW', 'INSTALLING', 'RUNNING', 'STOPPED', 'FAILURE', 'UNKNOWN'], default='NEW', doc='State of the backend')]
    __relations = [Relation('backend_type', BackendType, 'backends', doc='Type of the backend.')]
    __dynamics = [Dynamic('linked_guid', str, 3600),
                  Dynamic('available', bool, 60)]

    def _linked_guid(self):
        """
        Returns the GUID of the detail object that's linked to this particular backend. This depends on the backend type.
        This requires that the backlink from that object to this object is named <backend_type>_backend and is a
        one-to-one relation
        """
        if self.backend_type.has_plugin is False:
            return None
        return getattr(self, '{0}_backend_guid'.format(self.backend_type.code))

    def _available(self):
        """
        Returns True if the backend can be used
        """
        if self.backend_type.has_plugin is False:
            return False
        linked_backend = getattr(self, '{0}_backend'.format(self.backend_type.code))
        if linked_backend is not None:
            return linked_backend.available
        return False
예제 #18
0
class TestDisk(DataObject):
    """
    This TestDisk object is used for running unittests.
    WARNING: These properties should not be changed
    """
    __properties = [Property('name', str, doc='Name of the test disk'),
                    Property('description', str, mandatory=False, doc='Description of the test disk'),
                    Property('size', float, default=0, doc='Size of the test disk'),
                    Property('order', int, default=0, doc='Order of the test disk'),
                    Property('type', ['ONE', 'TWO'], mandatory=False, doc='Type of the test disk')]
    __relations = [Relation('machine', TestMachine, 'disks', mandatory=False),
                   Relation('storage', TestMachine, 'stored_disks', mandatory=False),
                   Relation('one', TestMachine, 'one', mandatory=False, onetoone=True),
                   Relation('parent', None, 'children', mandatory=False)]
    __dynamics = [Dynamic('used_size', int, 5),
                  Dynamic('wrong_type', int, 5),
                  Dynamic('updatable', int, 5),
                  Dynamic('predictable', int, 5)]

    # For testing purposes
    wrong_type_data = 0
    dynamic_value = 0

    def _used_size(self):
        """
        Returns a certain fake used_size value
        """
        from random import randint
        return randint(0, self._data['size'])

    def _wrong_type(self):
        """
        Returns the wrong type, should always fail
        """
        return self.wrong_type_data

    def _updatable(self):
        """
        Returns an external settable value
        """
        return self.dynamic_value

    def _predictable(self):
        """
        A predictable dynamic property
        """
        return self.size
예제 #19
0
class TestEMachine(TestMachine):
    """
    This ExtendedDisk object is used for running unittests.
    WARNING: These properties should not be changed
    """
    __properties = [Property('extended', str, mandatory=False, doc='Extended property')]
    __relations = [Relation('the_disk', TestDisk, 'the_machines', mandatory=False)]
    __dynamics = []
예제 #20
0
class StorageRouterDomain(DataObject):
    """
    The StorageRouterDomain class represents the junction table between StorageRouter and Domain.
    """
    __properties = [
        Property(
            'backup',
            bool,
            doc=
            'Indicator whether the StorageRouterDomain is used as failure domain or regular domain'
        )
    ]
    __relations = [
        Relation('domain', Domain, 'storagerouters'),
        Relation('storagerouter', StorageRouter, 'domains')
    ]
    __dynamics = []
예제 #21
0
class BackendUser(DataObject):
    """
    The BackendUser class represents the junction table between a User and Backend, setting granted/deny rights
    Examples:
    * my_backend.user_rights[0].user
    * my_user.backend_rights[0].backend
    """
    __properties = [
        Property('grant',
                 bool,
                 doc='Whether the rights is granted (True) or denied (False)')
    ]
    __relations = [
        Relation('backend', Backend, 'user_rights'),
        Relation('user', User, 'backend_rights')
    ]
    __dynamics = []
예제 #22
0
class BearerToken(DataObject):
    """
    The Bearer Token class represents the Bearer tokens used by the API by means of OAuth 2.0
    """
    __properties = [Property('access_token', str, mandatory=False, doc='Access token'),
                    Property('refresh_token', str, mandatory=False, doc='Refresh token'),
                    Property('expiration', int, doc='Expiration timestamp')]
    __relations = [Relation('client', Client, 'tokens')]
    __dynamics = []
예제 #23
0
class MDSServiceVDisk(DataObject):
    """
    The MDSServiceVDisk class represents the junction table between the MetadataServerService and VDisk.
    Examples:
    * my_vdisk.mds_services[0].mds_service
    * my_mds_service.vdisks[0].vdisk
    """
    __properties = [
        Property('is_master',
                 bool,
                 default=False,
                 doc='Is this the master MDSService for this VDisk.')
    ]
    __relations = [
        Relation('vdisk', VDisk, 'mds_services'),
        Relation('mds_service', MDSService, 'vdisks')
    ]
    __dynamics = []
예제 #24
0
class Service(DataObject):
    """
    A Service represents some kind of service that needs to be managed by the framework.
    """
    __properties = [
        Property('name', str, doc='Name of the Service.'),
        Property('ports', list, doc='Port(s) of the Service.')
    ]
    __relations = [
        Relation('storagerouter',
                 StorageRouter,
                 'services',
                 doc='The StorageRouter running the Service.'),
        Relation('type',
                 ServiceType,
                 'services',
                 doc='The type of the Service.')
    ]
    __dynamics = []
예제 #25
0
class User(DataObject):
    """
    The User class represents a User.  A user is an individual who can perform actions
    on objects in Open vStorage.
    """
    __properties = [Property('username', str, doc='Username of the User.'),
                    Property('password', str, doc='Password of the User.'),
                    Property('is_active', bool, doc='Indicates whether the User is active.'),
                    Property('language', ['en-US', 'nl-NL'], default='en-US', doc='Language of the User.')]
    __relations = [Relation('group', Group, 'users')]
    __dynamics = []
예제 #26
0
class Log(DataObject):
    """
    The Log class.
    """
    __properties = {
        Property('source', ['API', 'VOLUMEDRIVER_EVENT', 'VOLUMEDRIVER_TASK'],
                 doc='Source of the call'),
        Property('module', str, doc='Module containing the method.'),
        Property('method', str, doc='Method name that has been called.'),
        Property('method_args', list, mandatory=False, doc='Method args.'),
        Property('method_kwargs', dict, mandatory=False, doc='Method kwargs.'),
        Property('time', float, doc='Timestamp of the event'),
        Property('metadata',
                 dict,
                 mandatory=False,
                 doc='Extra metadata about the entry')
    }
    __relations = [
        Relation('user', User, 'logs', mandatory=False),
        Relation('storagedriver', StorageDriver, 'logs', mandatory=False)
    ]
예제 #27
0
class Backend(DataObject):
    """
    A Backend represents an instance of the supported backend types that has been setup with the OVS GUI
    """
    __properties = [Property('name', str, doc='Name of the Backend.')]
    __relations = [
        Relation('backend_type',
                 BackendType,
                 'backends',
                 doc='Type of the backend.')
    ]
    __dynamics = []
예제 #28
0
class DiskPartition(DataObject):
    """
    The DiskPartition class represents a partition on a physical Disk
    """
    ROLES = DataObject.enumerator('Role',
                                  ['DB', 'READ', 'SCRUB', 'WRITE', 'BACKEND'])
    VIRTUAL_STORAGE_LOCATION = '/mnt/storage'

    __properties = [
        Property('id', str, doc='The partition identifier'),
        Property('filesystem',
                 str,
                 mandatory=False,
                 doc='The filesystem used on the partition'),
        Property('state', ['OK', 'FAILURE', 'MISSING'],
                 doc='State of the partition'),
        Property('inode', int, mandatory=False, doc='The partitions inode'),
        Property('offset', int, doc='Offset of the partition'),
        Property('size', int, doc='Size of the partition'),
        Property('mountpoint',
                 str,
                 mandatory=False,
                 doc='Mountpoint of the partition, None if not mounted'),
        Property('path', str, doc='The partition path'),
        Property('roles', list, default=[], doc='A list of claimed roles')
    ]
    __relations = [Relation('disk', Disk, 'partitions')]
    __dynamics = [Dynamic('usage', list, 120), Dynamic('folder', str, 3600)]

    def _usage(self):
        """
        A dict representing this partition's usage in a more user-friendly form
        """
        dataset = []
        for junction in self.storagedrivers:
            dataset.append({
                'type': 'storagedriver',
                'role': junction.role,
                'size': junction.size,
                'relation': junction.storagedriver_guid,
                'folder': junction.folder
            })
        return dataset

    def _folder(self):
        """
        Corrected mountpoint
        """
        return DiskPartition.VIRTUAL_STORAGE_LOCATION if self.mountpoint == '/' else self.mountpoint
예제 #29
0
파일: disk.py 프로젝트: winglq/framework
class Disk(DataObject):
    """
    The Disk class represents physical disks that are available to a storagerouter (technically, they can be
    virtual disks, but from the OS (and framework) point of view, they're considered physical)
    """
    STATES = DataObject.enumerator('state', ['OK', 'FAILURE', 'MISSING'])

    __properties = [Property('aliases', list, doc='The device aliases'),
                    Property('model', str, mandatory=False, doc='The disks model'),
                    Property('state', STATES.keys(), doc='The state of the disk'),
                    Property('name', str, doc='Name of the disk (e.g. sda)'),
                    Property('size', int, doc='Size of the disk, in bytes'),
                    Property('is_ssd', bool, doc='The type of the disk')]
    __relations = [Relation('storagerouter', StorageRouter, 'disks')]
    __dynamics = []
예제 #30
0
class Disk(DataObject):
    """
    The Disk class represents physical disks that are available to a storagerouter (technically, they can be
    a virtual disk, but from the OS (and framework) point of view, they're considered physical)
    """
    __properties = [
        Property('path', str, doc='The device path'),
        Property('vendor', str, mandatory=False, doc='The disks vendor'),
        Property('model', str, mandatory=False, doc='The disks model'),
        Property('state', ['OK', 'ERROR', 'MISSING'],
                 doc='The state of the disk'),
        Property('name', str, doc='Name of the disk (e.g. sda)'),
        Property('size', int, doc='Size of the disk, in bytes'),
        Property('is_ssd', bool, doc='The type of the disk')
    ]
    __relations = [Relation('storagerouter', StorageRouter, 'disks')]
    __dynamics = []