How to use is_region_legacy method in avocado

Best Python code snippet using avocado_python

pmem.py

Source:pmem.py Github

copy

Full Screen

...170 first_dict = json_op[0]171 index_dict = self.run_ndctl_list_val(first_dict, 'index')[0]172 return self.run_ndctl_list_val(index_dict, 'nslot') - 2173 @staticmethod174 def is_region_legacy(region):175 """176 Check whether we have label index namespace. If legacy we can't create177 new namespaces.178 :param region: Region for which legacy check is made179 :return: True if given region is legacy, else False180 """181 nstype = genio.read_file("/sys/bus/nd/devices/%s"182 "/nstype" % region).rstrip("\n")183 if nstype == "4":184 return True185 return False186 @staticmethod187 def check_buses():188 """189 Get buses from sys subsystem to verify persistent devices exist190 :return: List of buses available191 :rtype: list192 """193 return glob.glob('/sys/bus/nd/drivers/nd_bus/ndbus*')194 def disable_region(self, name='all'):195 """196 Disable given region197 :param name: name of the region to be disabled198 :return: True on success199 :raise: :class:`PMemException`, if command fails.200 """201 if process.system('%s disable-region %s' % (self.ndctl, name),202 shell=True, ignore_status=True):203 raise PMemException("Failed to disable %s region(s)" % name)204 return True205 def enable_region(self, name='all'):206 """207 Enable given region208 :param name: name of the region to be enabled209 :return: True on success210 :raise: :class:`PMemException`, if command fails.211 """212 if process.system('%s enable-region %s' % (self.ndctl, name),213 shell=True, ignore_status=True):214 raise PMemException("Failed to enable %s region(s)" % name)215 return True216 def disable_namespace(self, namespace='all', region='', bus='',217 verbose=False):218 """219 Disable namespaces220 :param namespace: name of the namespace to be disabled221 :param region: Filter namespace by region222 :param bus: Filter namespace by bus223 :param verbose: Enable True command with debug information224 :return: True on success225 :raise: :class:`PMemException`, if command fails.226 """227 args = namespace228 if region:229 args = '%s -r %s' % (args, region)230 if bus:231 args = '%s -b %s' % (args, bus)232 if verbose:233 args = '%s -v' % args234 if process.system('%s disable-namespace %s' % (self.ndctl, args),235 shell=True, ignore_status=True):236 raise PMemException('Namespace disable failed for %s' % namespace)237 return True238 def enable_namespace(self, namespace='all', region='', bus='',239 verbose=False):240 """241 Enable namespaces242 :param namespace: name of the namespace to be enabled243 :param region: Filter namespace by region244 :param bus: Filter namespace by bus245 :param verbose: Enable True command with debug information246 return: True on success247 :raise: :class:`PMemException`, if command fails.248 """249 args = namespace250 if region:251 args = '%s -r %s' % (args, region)252 if bus:253 args = '%s -b %s' % (args, bus)254 if verbose:255 args = '%s -v' % args256 if process.system('%s enable-namespace %s' % (self.ndctl, args),257 shell=True, ignore_status=True):258 raise PMemException('Namespace enable failed for "%s"' % namespace)259 return True260 def create_namespace(self, region='', bus='', n_type='pmem', mode='fsdax',261 memmap='dev', name='', size='', uuid='',262 sector_size='', align='', reconfig='', force=False,263 autolabel=False):264 """265 Creates namespace with specified options266 :param region: Region on which namespace has to be created267 :param bus: Bus with which namespace has to be created268 :param n_type: Type of namespace to be created [pmem/blk]269 :param mode: Mode of namespace to be created, defaults to fsdax270 :param memmap: Metadata mapping for created namespace271 :param name: Optional name provided for namespace272 :param size: Size with which namespace has to be created273 :param uuid: Optional uuid provided for namespace274 :param sector_size: Sector size with which namespace has to be created275 :param align: Alignment with which namespace has to be created276 :param reconfig: Optionally reconfigure namespace providing existing277 namespace/region name278 :param force: Force creation of namespace279 :param autolabel: Optionally autolabel the namespace280 :return: True on success281 :raise: :class:`PMemException`, if command fails.282 """283 args_dict = {region: '-r', bus: '-b', name: '-n', size: '-s',284 uuid: '-u', sector_size: '-l', align: '-a',285 reconfig: '-e'}286 minor_dict = {force: '-f', autolabel: '-L'}287 args = '-t %s -m %s ' % (n_type, mode)288 if mode in ['fsdax', 'devdax']:289 args += ' -M %s' % memmap290 for option in list(args_dict.keys()):291 if option:292 args += ' %s %s' % (args_dict[option], option)293 for option in list(minor_dict.keys()):294 if option:295 args += ' %s' % minor_dict[option]296 if (self.is_region_legacy(region) and not reconfig):297 namespace = "namespace%s.0" % re.findall(r'\d+', region)[0]298 args += " -f -e " + namespace299 if process.system('%s create-namespace %s' % (self.ndctl, args),300 shell=True, ignore_status=True):301 raise PMemException('Namespace create command failed')302 return True303 def destroy_namespace(self, namespace='all', region='', bus='',304 force=False):305 """306 Destroy namespaces, skipped in case of legacy namespace307 :param namespace: name of the namespace to be destroyed308 :param region: Filter namespace by region309 :param bus: Filter namespace by bus310 :param force: Force a namespace to be destroyed311 :return: True on Success312 :raise: :class:`PMemException`, if command fails.313 """314 if (region and self.is_region_legacy(region)):315 return True316 args = namespace317 args_dict = {region: '-r', bus: '-b'}318 for option in list(args_dict.keys()):319 if option:320 args += ' %s %s' % (args_dict[option], option)321 if force:322 args += ' -f'323 if process.system('%s destroy-namespace %s' % (self.ndctl, args),324 shell=True, ignore_status=True):325 raise PMemException('Namespace destroy command failed')326 return True327 @staticmethod328 def _check_arg(key, kwargs):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful