def test_tty(self): """setup with a fake tty attached""" sys.stdout = FakeFile(True) # config.color == auto Globals().replace('color', 'auto') tbl = setup_table(DummyOptions('always', True)) self.assertTrue(tbl.color) tbl = setup_table(DummyOptions('never', True)) self.assertFalse(tbl.color) tbl = setup_table(DummyOptions('auto', True)) self.assertTrue(tbl.color) # config.color == never Globals().replace('color', 'never') tbl = setup_table(DummyOptions('always', True)) self.assertTrue(tbl.color) tbl = setup_table(DummyOptions('never', True)) self.assertFalse(tbl.color) tbl = setup_table(DummyOptions('auto', True)) self.assertFalse(tbl.color) # config.color == never Globals().replace('color', 'always') tbl = setup_table(DummyOptions('always', True)) self.assertTrue(tbl.color) tbl = setup_table(DummyOptions('never', True)) self.assertFalse(tbl.color) tbl = setup_table(DummyOptions('auto', True)) self.assertTrue(tbl.color)
def cmd_show_conf(self): """Show shine.conf""" tbl = setup_table(self.options, "%param %value") for key, value in Globals().as_dict().items(): tbl.append({'param': key, 'value': str(value)}) print str(tbl) return 0
def cmd_show_conf(self): """Show shine.conf""" tbl = setup_table(self.options, "%param %value") for key, value in Globals().as_dict().items(): tbl.append({'param': key, 'value': str(value)}) print(str(tbl)) return 0
def cmd_show_fs(self): """Show filesystems""" # XXX: Use a constant here verb = self.options.verbose >= 2 tbl = setup_table(self.options, "%fsname %description") for fsname in self.iter_fsname(): try: fs_conf = Configuration.load_from_cache(fsname) except: print "Error with FS ``%s'' configuration files." % fsname raise if not verb: print fs_conf.get_fs_name() else: tbl.append({'fsname': fs_conf.get_fs_name(), 'description': fs_conf.get_description()}) if verb: print str(tbl) return 0
def cmd_show_fs(self): """Show filesystems""" # XXX: Use a constant here verb = self.options.verbose >= 2 tbl = setup_table(self.options, "%fsname %description") for fsname in self.iter_fsname(): try: fs_conf = Configuration.load_from_cache(fsname) except: print("Error with FS ``%s'' configuration files." % fsname) raise if not verb: print(fs_conf.get_fs_name()) else: tbl.append({ 'fsname': fs_conf.get_fs_name(), 'description': fs_conf.get_description() }) if verb: print(str(tbl)) return 0
def test_show_headers(self): """setup of show_header""" tbl = setup_table(DummyOptions('auto', True)) self.assertTrue(tbl.show_header) tbl = setup_table(DummyOptions('auto', False)) self.assertFalse(tbl.show_header)
def cmd_show_info(self): """Show filesystem info""" # Walk through the list of file system managed # by the current node and specified by the user. for fsname in self.iter_fsname(): try: # Get the file system configuration structure fs_conf = Configuration.load_from_cache(fsname) except: # We fail to get current file system configuration information. # Display an error message. print "Error with FS ``%s'' configuration files." % fsname raise # Retrieve quota configuration information if Globals().lustre_version_is_smaller('2.4'): quota_info = '' if fs_conf.has_quota(): quota_info += 'type=%s ' % fs_conf.get_quota_type() qiunit = fs_conf.get_quota_iunit() or '[lustre_default]' quota_info += 'iunit=%s ' % qiunit qbunit = fs_conf.get_quota_bunit() or '[lustre_default]' quota_info += 'bunit=%s ' % qbunit qitune = fs_conf.get_quota_itune() or '[lustre_default]' quota_info += 'itune=%s ' % qitune qbtune = fs_conf.get_quota_btune() or '[lustre_default]' quota_info += 'btune=%s ' % qbtune else: quota_info = 'not activated' # Get file system stripping configuration information stripping = 'stripe_size=%s ' % fs_conf.get_stripesize() stripping += 'stripe_count=%s' % fs_conf.get_stripecount() # Get the device path used to mount the file system on client node mgsnodes = [fs_conf.get_target_mgt().get_nodename()] mgsnodes += fs_conf.get_target_mgt().ha_nodes() mgsnids = [ ','.join(fs_conf.get_nid(node)) for node in mgsnodes ] device_path = "%s:/%s" % (':'.join(mgsnids), fs_conf.get_fs_name()) tbl = setup_table(self.options, "%name %value") # Add configuration parameter to the list of element displayed in # the summary tab. tbl.append({'name': 'name', 'value': fs_conf.get_fs_name()}) tbl.append({'name': 'default mount path', 'value': fs_conf.get_mount_path()}) tbl.append({'name': 'device path', 'value': device_path}) tbl.append({'name': 'mount options', 'value': fs_conf.get_default_mount_options()}) if Globals().lustre_version_is_smaller('2.4'): tbl.append({'name': 'quotas', 'value': quota_info}) tbl.append({'name': 'stripping', 'value': stripping}) tbl.append({'name': 'tuning', 'value': Globals().get_tuning_file()}) tbl.append({'name': 'description', 'value': fs_conf.get_description()}) # Display the list of collected configuration information print str(tbl)
def cmd_show_info(self): """Show filesystem info""" # Walk through the list of file system managed # by the current node and specified by the user. for fsname in self.iter_fsname(): try: # Get the file system configuration structure fs_conf = Configuration.load_from_cache(fsname) except: # We fail to get current file system configuration information. # Display an error message. msg = "Error with FS ``%s'' configuration files." % fsname print(msg, file=sys.stderr) raise # Retrieve quota configuration information if Globals().lustre_version_is_smaller('2.4'): quota_info = '' if fs_conf.has_quota(): quota_info += 'type=%s ' % fs_conf.get_quota_type() qiunit = fs_conf.get_quota_iunit() or '[lustre_default]' quota_info += 'iunit=%s ' % qiunit qbunit = fs_conf.get_quota_bunit() or '[lustre_default]' quota_info += 'bunit=%s ' % qbunit qitune = fs_conf.get_quota_itune() or '[lustre_default]' quota_info += 'itune=%s ' % qitune qbtune = fs_conf.get_quota_btune() or '[lustre_default]' quota_info += 'btune=%s ' % qbtune else: quota_info = 'not activated' # Get file system stripping configuration information stripping = 'stripe_size=%s ' % fs_conf.get_stripesize() stripping += 'stripe_count=%s' % fs_conf.get_stripecount() # Get the device path used to mount the file system on client node mgsnodes = [fs_conf.get_target_mgt().get_nodename()] mgsnodes += fs_conf.get_target_mgt().ha_nodes() mgsnids = [','.join(fs_conf.get_nid(node)) for node in mgsnodes] device_path = "%s:/%s" % (':'.join(mgsnids), fs_conf.get_fs_name()) tbl = setup_table(self.options, "%name %value") # Add configuration parameter to the list of element displayed in # the summary tab. tbl.append({'name': 'name', 'value': fs_conf.get_fs_name()}) tbl.append({ 'name': 'default mount path', 'value': fs_conf.get_mount_path() }) tbl.append({'name': 'device path', 'value': device_path}) tbl.append({ 'name': 'mount options', 'value': fs_conf.get_default_mount_options() }) if Globals().lustre_version_is_smaller('2.4'): tbl.append({'name': 'quotas', 'value': quota_info}) tbl.append({'name': 'stripping', 'value': stripping}) tbl.append({ 'name': 'tuning', 'value': Globals().get_tuning_file() }) tbl.append({ 'name': 'description', 'value': fs_conf.get_description() }) # Display the list of collected configuration information print(str(tbl))