Example #1
0
    def pulse():
        """
        Update the heartbeats for the Current Routers
        :return: None
        """
        logger = Logger('extensions-generic')
        machine_id = System.get_my_machine_id()
        current_time = int(time.time())

        routers = StorageRouterList.get_storagerouters()
        for node in routers:
            if node.machine_id == machine_id:
                with volatile_mutex('storagerouter_heartbeat_{0}'.format(
                        node.guid)):
                    node_save = StorageRouter(node.guid)
                    node_save.heartbeats['process'] = current_time
                    node_save.save()
                StorageRouterController.ping.s(
                    node.guid, current_time).apply_async(
                        routing_key='sr.{0}'.format(machine_id))
            else:
                try:
                    # check timeout of other nodes and clear arp cache
                    if node.heartbeats and 'process' in node.heartbeats:
                        if current_time - node.heartbeats[
                                'process'] >= HeartBeat.ARP_TIMEOUT:
                            check_output("/usr/sbin/arp -d '{0}'".format(
                                node.name.replace(r"'", r"'\''")),
                                         shell=True)
                except CalledProcessError:
                    logger.exception('Error clearing ARP cache')
Example #2
0
 def list(self, vpoolguid=None, storagerouterguid=None):
     """
     Overview of all vDisks
     :param vpoolguid: Guid of the vPool to retrieve its disks
     :type vpoolguid: str
     :param storagerouterguid: Guid of the StorageRouter to retrieve its disks
     :type storagerouterguid: str
     :return: List of vDisks matching the parameters specified
     :rtype: list[ovs.dal.hybrids.vdisk.VDisk]
     """
     if vpoolguid is not None:
         vpool = VPool(vpoolguid)
         vdisks = vpool.vdisks
     elif storagerouterguid is not None:
         storagerouter = StorageRouter(storagerouterguid)
         vdisks = DataList(
             VDisk, {
                 'type':
                 DataList.where_operator.AND,
                 'items': [('guid', DataList.operator.IN,
                            storagerouter.vdisks_guids)]
             })
     else:
         vdisks = VDiskList.get_vdisks()
     return vdisks
Example #3
0
 def list(self, vpoolguid=None, storagerouterguid=None, query=None):
     """
     Overview of all vDisks
     :param vpoolguid: Guid of the vPool to retrieve its disks
     :type vpoolguid: str
     :param storagerouterguid: Guid of the StorageRouter to retrieve its disks
     :type storagerouterguid: str
     :param query: A query to be executed if required
     :type query: DataQuery
     """
     if vpoolguid is not None:
         vpool = VPool(vpoolguid)
         vdisks = vpool.vdisks
     elif storagerouterguid is not None:
         storagerouter = StorageRouter(storagerouterguid)
         vdisks = DataList(
             VDisk, {
                 'type':
                 DataList.where_operator.AND,
                 'items': [('guid', DataList.operator.IN,
                            storagerouter.vdisks_guids)]
             })
     else:
         vdisks = VDiskList.get_vdisks()
     if query is not None:
         query_vdisk_guids = DataList(VDisk, query).guids
         vdisks = [
             vdisk for vdisk in vdisks if vdisk.guid in query_vdisk_guids
         ]
     return vdisks
    def get_physical_metadata(files, storagerouter_guid):
        """
        Gets physical information about the machine this task is running on
        """
        from ovs.lib.vpool import VPoolController

        storagerouter = StorageRouter(storagerouter_guid)
        mountpoints = check_output('mount -v', shell=True).strip().split('\n')
        mountpoints = [p.split(' ')[2] for p in mountpoints if len(p.split(' ')) > 2
                       and not p.split(' ')[2].startswith('/dev') and not p.split(' ')[2].startswith('/proc')
                       and not p.split(' ')[2].startswith('/sys') and not p.split(' ')[2].startswith('/run')
                       and p.split(' ')[2] != '/']
        arakoon_mountpoint = Configuration.get('ovs.core.db.arakoon.location')
        if arakoon_mountpoint in mountpoints:
            mountpoints.remove(arakoon_mountpoint)
        if storagerouter.pmachine.hvtype == 'KVM':
            ipaddresses = ['127.0.0.1']
        else:
            ip_path = Configuration.get('ovs.core.ip.path')
            if ip_path is None:
                ip_path = "`which ip`"
            ipaddresses = check_output("{0} a | grep 'inet ' | sed 's/\s\s*/ /g' | cut -d ' ' -f 3 | cut -d '/' -f 1".format(ip_path), shell=True).strip().split('\n')
            ipaddresses = [ip.strip() for ip in ipaddresses]
            ipaddresses.remove('127.0.0.1')
        allow_vpool = VPoolController.can_be_served_on(storagerouter_guid)
        file_existence = {}
        for check_file in files:
            file_existence[check_file] = os.path.exists(check_file) and os.path.isfile(check_file)
        return {'mountpoints': mountpoints,
                'ipaddresses': ipaddresses,
                'files': file_existence,
                'allow_vpool': allow_vpool}
Example #5
0
    def shrink_vpool(self, vpool, storagerouter_guid):
        """
        Remove the storagedriver linking the specified vPool and storagerouter_guid
        :param vpool: vPool to shrink (or delete if its the last storagerouter linked to it)
        :type vpool: VPool
        :param storagerouter_guid: Guid of the Storage Router
        :type storagerouter_guid: str
        """
        if len(vpool.vdisks) > 0:  # Check to prevent obsolete testing
            backend_info = vpool.metadata['backend']['backend_info']
            preset_name = backend_info['preset']
            # Check if the policy is satisfiable before shrinking - Doing it here so the issue is transparent in the GUI
            alba_backend_guid = backend_info['alba_backend_guid']
            api_url = 'alba/backends/{0}'.format(alba_backend_guid)
            connection_info = backend_info['connection_info']
            ovs_client = OVSClient.get_instance(connection_info=connection_info, cache_store=VolatileFactory.get_client())
            _presets = ovs_client.get(api_url, params={'contents': 'presets'})['presets']
            try:
                _preset = filter(lambda p: p['name'] == preset_name, _presets)[0]
                if _preset['is_available'] is False:
                    raise RuntimeError('Policy is currently not satisfied: cannot shrink vPool {0} according to preset {1}'.format(vpool.name, preset_name))
            except IndexError:
                pass

        # Raise if not satisfied
        sr = StorageRouter(storagerouter_guid)
        intersection = set(vpool.storagedrivers_guids).intersection(set(sr.storagedrivers_guids))
        if not intersection:
            raise HttpNotAcceptableException(error='impossible_request',
                                             error_description='Storage Router {0} is not a member of vPool {1}'.format(sr.name, vpool.name))
        return VPoolController.shrink_vpool.delay(VPoolController, list(intersection)[0])
Example #6
0
    def get_logfiles(albanode_guid, local_storagerouter_guid):
        """
        Collects logs, moves them to a web-accessible location and returns log tgz's filename
        :param albanode_guid: Alba Node guid to retrieve log files on
        :type albanode_guid: str
        :param local_storagerouter_guid: Guid of the StorageRouter on which the collect logs was initiated, eg: through the GUI
        :type local_storagerouter_guid: str
        :return: Name of tgz containing the logs
        :rtype: str
        """
        web_path = '/opt/OpenvStorage/webapps/frontend/downloads'
        alba_node = AlbaNode(albanode_guid)
        logfile_name = alba_node.client.get_logs()['filename']
        download_url = 'https://{0}:{1}@{2}:{3}/downloads/{4}'.format(
            alba_node.username, alba_node.password, alba_node.ip,
            alba_node.port, logfile_name)

        client = SSHClient(endpoint=StorageRouter(local_storagerouter_guid),
                           username='******')
        client.dir_create(web_path)
        client.run([
            'wget', download_url, '--directory-prefix', web_path,
            '--no-check-certificate'
        ])
        client.run(['chmod', '666', '{0}/{1}'.format(web_path, logfile_name)])
        return logfile_name
Example #7
0
 def set_rdma_capability(storagerouter_guid):
     """
     Check if the StorageRouter has been reconfigured to be able to support RDMA
     :param storagerouter_guid: Guid of the StorageRouter to check and set
     :type storagerouter_guid: str
     :return: None
     :rtype: NoneType
     """
     storagerouter = StorageRouter(storagerouter_guid)
     client = SSHClient(storagerouter, username='******')
     rdma_capable = False
     with remote(client.ip, [os], username='******') as rem:
         for root, dirs, files in rem.os.walk('/sys/class/infiniband'):
             for directory in dirs:
                 ports_dir = '/'.join([root, directory, 'ports'])
                 if not rem.os.path.exists(ports_dir):
                     continue
                 for sub_root, sub_dirs, _ in rem.os.walk(ports_dir):
                     if sub_root != ports_dir:
                         continue
                     for sub_directory in sub_dirs:
                         state_file = '/'.join(
                             [sub_root, sub_directory, 'state'])
                         if rem.os.path.exists(state_file):
                             if 'ACTIVE' in client.run(['cat', state_file]):
                                 rdma_capable = True
     storagerouter.rdma_capable = rdma_capable
     storagerouter.save()
Example #8
0
 def create(self, name, size, vpool_guid, storagerouter_guid, pagecache_ratio=1.0, cache_quota=None):
     """
     Create a new vdisk
     :param name: Name of the new vdisk
     :type name: str
     :param size: Size of  virtual disk in bytes
     :type size: int
     :param vpool_guid: Guid of vPool to create new vdisk on
     :type vpool_guid: str
     :param storagerouter_guid: Guid of the storagerouter to assign disk to
     :type storagerouter_guid: str
     :param pagecache_ratio: Ratio (0 < x <= 1) of the pagecache size related to the size
     :type pagecache_ratio: float
     :param cache_quota: Maximum caching space(s) the new volume can consume (in Bytes) per cache type.
     :type cache_quota: dict
     :return: Asynchronous result of a CeleryTask
     :rtype: celery.result.AsyncResult
     """
     storagerouter = StorageRouter(storagerouter_guid)
     for storagedriver in storagerouter.storagedrivers:
         if storagedriver.vpool_guid == vpool_guid:
             return VDiskController.create_new.delay(volume_name=name,
                                                     volume_size=size,
                                                     storagedriver_guid=storagedriver.guid,
                                                     pagecache_ratio=pagecache_ratio,
                                                     cache_quota=cache_quota)
     raise HttpNotAcceptableException(error_description='No storagedriver found for vPool: {0} and StorageRouter: {1}'.format(vpool_guid, storagerouter_guid),
                                      error='impossible_request')
Example #9
0
    def validate_vdisk(self):
        """
        Validates if the vDisk is ready for ensuring the MDS safety
        :raises SRCObjectNotFoundException: If the vDisk is no associated with a StorageRouter
        :raises RuntimeError: if
        - Current host is in the excluded storagerouters
        - vDisk is in a different state than running
        :return: None
        :rtype: NoneType
        """
        self.vdisk.invalidate_dynamics(['info', 'storagerouter_guid'])

        if self.vdisk.storagerouter_guid is None:
            raise SRCObjectNotFoundException(
                'Cannot ensure MDS safety for vDisk {0} with guid {1} because vDisk is not attached to any StorageRouter'
                .format(self.vdisk.name, self.vdisk.guid))

        vdisk_storagerouter = StorageRouter(self.vdisk.storagerouter_guid)
        if vdisk_storagerouter in self.excluded_storagerouters:
            raise RuntimeError(
                'Current host ({0}) of vDisk {1} is in the list of excluded StorageRouters'
                .format(vdisk_storagerouter.ip, self.vdisk.guid))

        if self.vdisk.info['live_status'] != VDisk.STATUSES.RUNNING:
            raise RuntimeError(
                'vDisk {0} is not {1}, cannot update MDS configuration'.format(
                    self.vdisk.guid, VDisk.STATUSES.RUNNING))

        self.metadata_backend_config_start = self.vdisk.info[
            'metadata_backend_config']
        if self.vdisk.info['metadata_backend_config'] == {}:
            raise RuntimeError(
                'Configured MDS layout for vDisk {0} could not be retrieved}, cannot update MDS configuration'
                .format(self.vdisk.guid))
Example #10
0
 def delete(self, vdisk):
     """
     Delete vdisk
     @param vdisk Guid of the vdisk to delete:
     """
     storagerouter = StorageRouter(vdisk.storagerouter_guid)
     return VDiskController.delete.s(diskguid=vdisk.guid).apply_async(
         routing_key="sr.{0}".format(storagerouter.machine_id))
 def get_storagerouter_ip(storagerouter_guid):
     """
     :param storagerouter_guid: guid of a storagerouter
     :type storagerouter_guid: str
     :return: storagerouter ip
     :rtype: str
     """
     return StorageRouter(storagerouter_guid).ip
 def get_storagerouter_by_guid(storagerouter_guid):
     """
     :param storagerouter_guid: guid of a storagerouter
     :type storagerouter_guid: str
     :return: storagerouter guid
     :rtype: ovs.dal.hybrids.storagerouter.StorageRouter
     """
     return StorageRouter(storagerouter_guid)
Example #13
0
 def list(self, storagerouterguid=None):
     """
     Overview of all disks
     """
     if storagerouterguid is not None:
         storagerouter = StorageRouter(storagerouterguid)
         return storagerouter.disks
     return DiskList.get_disks()
Example #14
0
 def list(self, storagerouterguid=None):
     """
     Overview of all disks
     :param storagerouterguid: The StorageRouter to get the disks from
     :type storagerouterguid: guid
     """
     if storagerouterguid is not None:
         storagerouter = StorageRouter(storagerouterguid)
         return storagerouter.disks
     return DiskList.get_disks()
Example #15
0
 def is_volume_synced_up_to_tlog(self, vdisk, tlog_name):
     """
     Verify if volume is synced to backend up to a specific tlog
     :param vdisk: vdisk to verify
     :param tlog_name: TLogName to verify
     """
     storagerouter = StorageRouter(vdisk.storagerouter_guid)
     return VDiskController.is_volume_synced_up_to_tlog.s(
         vdisk_guid=vdisk.guid, tlog_name=tlog_name).apply_async(
             routing_key="sr.{0}".format(storagerouter.machine_id))
Example #16
0
 def schedule_backend_sync(self, vdisk):
     """
     Schedule a backend sync on a vdisk
     :param vdisk: vdisk to schedule a backend sync to
     :return: TLogName associated with the data sent off to the backend
     """
     storagerouter = StorageRouter(vdisk.storagerouter_guid)
     return VDiskController.schedule_backend_sync.s(
         vdisk_guid=vdisk.guid).apply_async(
             routing_key="sr.{0}".format(storagerouter.machine_id))
Example #17
0
 def is_volume_synced_up_to_snapshot(self, vdisk, snapshot_id):
     """
     Verify if volume is synced to backend up to a specific snapshot
     :param vdisk: vdisk to verify
     :param snapshot_id: Snapshot to verify
     """
     storagerouter = StorageRouter(vdisk.storagerouter_guid)
     return VDiskController.is_volume_synced_up_to_snapshot.s(
         vdisk_guid=vdisk.guid, snapshot_id=snapshot_id).apply_async(
             routing_key="sr.{0}".format(storagerouter.machine_id))
    def check_recovery_domains(result_handler):
        result_handler.info('Checking recovery domains:')
        prim_domains = [domain.name for domain in DomainList.get_domains() if len(domain.storage_router_layout['regular']) >= 1]
        for domain in DomainList.get_domains():
            layout = domain.storage_router_layout
            recovery = layout['recovery']
            regular = layout['regular']
            # Check recovery usage
            if len(recovery) >= 1 and domain.name not in prim_domains:
                sr_ips = ', '.join([StorageRouter(guid).ip for guid in recovery])
                result_handler.warning('Domain {0} set as recovery domain on storagerouter(s) {1}, but nowhere as regular domain'.format(domain.name, sr_ips))
            else:
                result_handler.info('Domain {0} passed test, set {1} time(s) as regular domain'.format(domain.name, len(regular)))

            # Check for double usage
            intersection = set(recovery).intersection(regular)
            if intersection:
                sr_ips = ', '.join([StorageRouter(guid).ip for guid in intersection])
                result_handler.warning('Recovery domain {0} is also found to be a regular domain in {1}.'.format(domain.name, sr_ips))
Example #19
0
 def get_ip_addresses(storagerouter_guid):
     """
     Retrieves the IP addresses of a StorageRouter
     :param storagerouter_guid: Guid of the StorageRouter
     :return: List of IP addresses
     :rtype: list
     """
     client = SSHClient(endpoint=StorageRouter(storagerouter_guid))
     return StorageRouterController._os_manager.get_ip_addresses(
         client=client)
Example #20
0
    def __init__(self, endpoint, username='******', password=None):
        """
        Initializes an SSHClient
        """
        if isinstance(endpoint, basestring):
            ip = endpoint
            if not re.findall(SSHClient.IP_REGEX, ip):
                raise ValueError('Incorrect IP {0} specified'.format(ip))
        elif Descriptor.isinstance(endpoint, StorageRouter):
            # Refresh the object before checking its attributes
            endpoint = StorageRouter(endpoint.guid)
            process_heartbeat = endpoint.heartbeats.get('process')
            ip = endpoint.ip
            if process_heartbeat is not None:
                if time.time() - process_heartbeat > 300:
                    message = 'StorageRouter {0} process heartbeat > 300s'.format(
                        ip)
                    logger.error(message)
                    raise UnableToConnectException(message)
        else:
            raise ValueError(
                'The endpoint parameter should be either an ip address or a StorageRouter'
            )

        logging.getLogger('paramiko').setLevel(logging.WARNING)
        self.client = paramiko.SSHClient()
        self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        self.ip = ip
        local_ips = check_output(
            "ip a | grep 'inet ' | sed 's/\s\s*/ /g' | cut -d ' ' -f 3 | cut -d '/' -f 1",
            shell=True).strip().splitlines()
        self.local_ips = [ip.strip() for ip in local_ips]
        self.is_local = self.ip in self.local_ips

        current_user = check_output('whoami', shell=True).strip()
        if username is None:
            self.username = current_user
        else:
            self.username = username
            if username != current_user:
                self.is_local = False  # If specified user differs from current executing user, we always use the paramiko SSHClient
        self.password = password

        if not self.is_local:
            try:
                self._connect()
            except socket.error, ex:
                if 'No route to host' in str(ex):
                    message = 'SocketException: No route to host {0}'.format(
                        ip)
                    logger.error(message)
                    raise UnableToConnectException(message)
                raise
Example #21
0
 def move_away(storagerouter_guid):
     """
     Moves away all vDisks from all Storage Drivers this Storage Router is serving
     """
     storagedrivers = StorageRouter(storagerouter_guid).storagedrivers
     if len(storagedrivers) > 0:
         storagedriver_client = StorageDriverClient.load(
             storagedrivers[0].vpool)
         for storagedriver in storagedrivers:
             storagedriver_client.mark_node_offline(
                 str(storagedriver.storagedriver_id))
Example #22
0
 def mark_offline(storagerouter_guid):
     """
     Marks all StorageDrivers on this StorageRouter offline
     :param storagerouter_guid: Guid of the Storage Router
     :type storagerouter_guid: str
     :return: None
     """
     for storagedriver in StorageRouter(storagerouter_guid).storagedrivers:
         vpool = storagedriver.vpool
         if len(vpool.storagedrivers) > 1:
             storagedriver_client = StorageDriverClient.load(vpool, excluded_storagedrivers=[storagedriver])
             storagedriver_client.mark_node_offline(str(storagedriver.storagedriver_id))
Example #23
0
 def mountpoint_exists(name, storagerouter_guid):
     """
     Checks whether a given mount point for a vPool exists
     :param name: Name of the mount point to check
     :type name: str
     :param storagerouter_guid: Guid of the StorageRouter on which to check for mount point existence
     :type storagerouter_guid: str
     :return: True if mount point not in use else False
     :rtype: bool
     """
     client = SSHClient(StorageRouter(storagerouter_guid))
     return client.dir_exists(directory='/mnt/{0}'.format(name))
Example #24
0
    def setUpClass(cls):
        """
        Sets up the unittest, mocking a certain set of 3rd party libraries and extensions.
        This makes sure the unittests can be executed without those libraries installed
        """
        # Load dummy stores
        PersistentFactory.store = DummyPersistentStore()
        VolatileFactory.store = DummyVolatileStore()
        # Replace mocked classes
        sys.modules[
            'ovs.extensions.storageserver.storagedriver'] = StorageDriverModule
        # Import required modules/classes after mocking is done
        from ovs.dal.hybrids.vdisk import VDisk
        from ovs.dal.hybrids.service import Service
        from ovs.dal.hybrids.vpool import VPool
        from ovs.dal.hybrids.storagerouter import StorageRouter
        from ovs.dal.hybrids.pmachine import PMachine
        from ovs.dal.hybrids.servicetype import ServiceType
        from ovs.dal.hybrids.storagedriver import StorageDriver
        from ovs.dal.hybrids.backendtype import BackendType
        from ovs.dal.hybrids.j_mdsservice import MDSService
        from ovs.dal.hybrids.j_mdsservicevdisk import MDSServiceVDisk
        from ovs.extensions.generic.volatilemutex import VolatileMutex
        from ovs.lib.mdsservice import MDSServiceController
        # Globalize mocked classes
        global VDisk
        global VPool
        global Service
        global StorageRouter
        global StorageDriver
        global BackendType
        global PMachine
        global MDSService
        global ServiceType
        global MDSServiceVDisk
        global VolatileMutex
        global MDSServiceController
        _ = VDisk(), VPool(), Service(), MDSService(), MDSServiceVDisk(), ServiceType(), \
            StorageRouter(), StorageDriver(), BackendType(), PMachine(), \
            VolatileMutex('dummy'), MDSServiceController

        # Configuration
        def _get(key):
            c = PersistentFactory.get_client()
            if c.exists(key):
                return c.get(key)
            return None

        Configuration.get = staticmethod(_get)

        # Cleaning storage
        VolatileFactory.store.clean()
        PersistentFactory.store.clean()
Example #25
0
    def update_storagedrivers(self,
                              vpool,
                              storagedriver_guid,
                              storagerouter_guids=None,
                              storagedriver_guids=None):
        """
        Update Storage Drivers for a given vPool (both adding and removing Storage Drivers)
        """
        storagerouters = []
        if storagerouter_guids is not None:
            if storagerouter_guids.strip() != '':
                for storagerouter_guid in storagerouter_guids.strip().split(
                        ','):
                    storagerouter = StorageRouter(storagerouter_guid)
                    storagerouters.append(
                        (storagerouter.ip, storagerouter.machine_id))
        valid_storagedriver_guids = []
        if storagedriver_guids is not None:
            if storagedriver_guids.strip() != '':
                for storagedriver_guid in storagedriver_guids.strip().split(
                        ','):
                    storagedriver = StorageDriver(storagedriver_guid)
                    if storagedriver.vpool_guid != vpool.guid:
                        raise NotAcceptable(
                            'Given Storage Driver does not belong to this vPool'
                        )
                    valid_storagedriver_guids.append(storagedriver.guid)

        storagedriver = StorageDriver(storagedriver_guid)
        parameters = {
            'connection_host':
            None
            if vpool.connection is None else vpool.connection.split(':')[0],
            'connection_port':
            None if vpool.connection is None else int(
                vpool.connection.split(':')[1]),
            'connection_username':
            vpool.login,
            'connection_password':
            vpool.password,
            'storage_ip':
            storagedriver.storage_ip,
            'type':
            vpool.backend_type.code,
            'vpool_name':
            vpool.name
        }
        for field in parameters:
            if isinstance(parameters[field], basestring):
                parameters[field] = str(parameters[field])

        return StorageRouterController.update_storagedrivers.delay(
            valid_storagedriver_guids, storagerouters, parameters)
Example #26
0
    def get_my_storagerouter():
        """
        Returns unique machine storagerouter id
        """

        from ovs.dal.hybrids.storagerouter import StorageRouter
        from ovs.dal.lists.storagerouterlist import StorageRouterList

        if not System.my_storagerouter_guid:
            for storagerouter in StorageRouterList.get_storagerouters():
                if storagerouter.machine_id == System.get_my_machine_id():
                    System.my_storagerouter_guid = storagerouter.guid
        return StorageRouter(System.my_storagerouter_guid)
Example #27
0
    def test_from_single_node_to_multi_node(self):
        """
        Deploy a vDisk on a single node --> This should result in no DTL configured
        Add an additional node and verify DTL will be set
        """
        # || StorageRouter || vDisk | Regular Domain || Recovery Domain || DTL Target ||
        #  |      sr 1      |   1   |                 |                  |             |
        structure = DalHelper.build_dal_structure(
            {'vpools': [1],
             'vdisks': [(1, 1, 1, 1)],  # (<id>, <storagedriver_id>, <vpool_id>, <mds_service_id>)
             'mds_services': [(1, 1)],  # (<id>, <storagedriver_id>)
             'storagerouters': [1],
             'storagedrivers': [(1, 1, 1)]}  # (<id>, <vpool_id>, <sr_id>)
        )
        vpool = structure['vpools'][1]
        vdisk = structure['vdisks'][1]
        storagerouters = structure['storagerouters']

        self._roll_out_dtl_services(vpool=vpool, storagerouters=storagerouters)
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'config', 'value': None}])

        # Add a Storage Router
        # || StorageRouter || vDisk | Regular Domain || Recovery Domain || DTL Target ||
        #  |      sr 1      |   1   |                 |                  |             |
        #  |      sr 2      |       |                 |                  |      1      |
        storagerouter = StorageRouter()
        storagerouter.name = '2'
        storagerouter.ip = '10.0.0.2'
        storagerouter.rdma_capable = False
        storagerouter.save()
        storagerouters[2] = storagerouter
        self._roll_out_dtl_services(vpool=vpool, storagerouters=storagerouters)

        storagedriver = StorageDriver()
        storagedriver.vpool = vpool
        storagedriver.storagerouter = storagerouter
        storagedriver.name = '2'
        storagedriver.mountpoint = '/'
        storagedriver.cluster_ip = storagerouter.ip
        storagedriver.storage_ip = '10.0.1.2'
        storagedriver.storagedriver_id = '2'
        storagedriver.ports = {'management': 1,
                               'xmlrpc': 2,
                               'dtl': 3,
                               'edge': 4}
        storagedriver.save()
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'host', 'value': storagerouters[2].storagedrivers[0].storage_ip},
                                                        {'key': 'port', 'value': 3},
                                                        {'key': 'mode', 'value': DTLMode.ASYNCHRONOUS}])
Example #28
0
 def clone(self, vdisk, name, storagerouter_guid, snapshot_id=None):
     """
     Clones a vDisk
     :param vdisk: Guid of the virtual disk to clone
     :param name: Name for the clone
     :param storagerouter_guid: Guid of the storagerouter hosting the virtual disk
     :param snapshot_id: ID of the snapshot to clone from
     """
     storagerouter = StorageRouter(storagerouter_guid)
     return VDiskController.clone.delay(
         diskguid=vdisk.guid,
         snapshotid=snapshot_id,
         devicename=name,
         pmachineguid=storagerouter.pmachine_guid,
         detached=True)
Example #29
0
 def ping(storagerouter_guid, timestamp):
     """
     Update a StorageRouter's celery heartbeat
     :param storagerouter_guid: Guid of the StorageRouter to update
     :type storagerouter_guid: str
     :param timestamp: Timestamp to compare to
     :type timestamp: float
     :return: None
     :rtype: NoneType
     """
     with volatile_mutex(
             'storagerouter_heartbeat_{0}'.format(storagerouter_guid)):
         storagerouter = StorageRouter(storagerouter_guid)
         if timestamp > storagerouter.heartbeats.get('celery', 0):
             storagerouter.heartbeats['celery'] = timestamp
             storagerouter.save()
Example #30
0
 def get_version_info(storagerouter_guid):
     """
     Returns version information regarding a given StorageRouter
     :param storagerouter_guid: StorageRouter guid to get version information for
     :type storagerouter_guid: str
     :return: Version information
     :rtype: dict
     """
     package_manager = PackageFactory.get_manager()
     client = SSHClient(StorageRouter(storagerouter_guid))
     return {
         'storagerouter_guid':
         storagerouter_guid,
         'versions':
         dict((pkg_name, str(version)) for pkg_name, version in
              package_manager.get_installed_versions(client).iteritems())
     }