コード例 #1
0
	def init_session_with_single_management(logger):
		connected = False
		api = None
		# try until able to connect to NVMesh Management
		print("Looking for a NVMesh Management server using {} from servers {}".format(Config.MANAGEMENT_PROTOCOL, Config.MANAGEMENT_SERVERS))
		while not connected:
			try:
				api, connected = NVMeshSDKHelper._try_to_connect_to_single_management(logger)
			except ManagementTimeout as ex:
				NVMeshSDKHelper.logger.info("Waiting for NVMesh Management servers on ({}) {}".format(Config.MANAGEMENT_PROTOCOL, Config.MANAGEMENT_SERVERS))
				Utils.interruptable_sleep(10)

			print("Connected to NVMesh Management server on ({}) {}".format(Config.MANAGEMENT_PROTOCOL, Config.MANAGEMENT_SERVERS))
		return api
コード例 #2
0
    def NodeExpandVolume(self, request, context):
        # if this function was called, assume the Controller checked that this volume is a FileSystem Mounted Volume.
        # So we will resize the File System here
        volume_id = request.volume_id
        volume_path = request.volume_path
        capacity_range = request.capacity_range

        reqJson = MessageToJson(request)
        self.logger.debug(
            'NodeExpandVolume called with request: {}'.format(reqJson))

        zone, nvmesh_vol_name = Utils.zone_and_vol_name_from_co_id(
            request.volume_id)
        block_device_path = Utils.get_nvmesh_block_device_path(nvmesh_vol_name)
        self.logger.debug(
            'NodeExpandVolume zone: {} nvmesh_vol_name: {} block_device_path: {}'
            .format(zone, nvmesh_vol_name, block_device_path))

        fs_type = FileSystemManager.get_fs_type(block_device_path)
        self.logger.debug('fs_type={}'.format(fs_type))

        attempts_left = 20
        resized = False
        while not resized and attempts_left:
            exit_code, stdout, stderr = FileSystemManager.expand_file_system(
                block_device_path, fs_type)
            if 'Nothing to do!' in stderr:
                block_device_size = FileSystemManager.get_block_device_size(
                    block_device_path)
                self.logger.warning(
                    'File System not resized. block device size is {}'.format(
                        block_device_size))
                attempts_left = attempts_left - 1
                Utils.interruptable_sleep(2)
            else:
                resized = True

        if not attempts_left:
            raise DriverError(
                StatusCode.INTERNAL,
                'Back-Off trying to expand {} FileSystem on volume {}'.format(
                    fs_type, block_device_path))

        self.logger.debug(
            'Finished Expanding File System of type {} on volume {}'.format(
                fs_type, block_device_path))
        return NodeExpandVolumeResponse()