targetcli 3.0.1__py3-none-any.whl → 3.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
targetcli/targetclid.py CHANGED
@@ -153,7 +153,7 @@ class TargetCLI:
153
153
  connection.close()
154
154
  still_listen = False
155
155
  else:
156
- self.con._stdout = self.con._stderr = f = tempfile.NamedTemporaryFile(mode='w', delete=False)
156
+ self.con._stdout = self.con._stderr = f = tempfile.NamedTemporaryFile(mode='w', delete=False) # noqa: SIM115
157
157
  try:
158
158
  # extract multiple commands delimited with '%'
159
159
  list_data = data.decode().split('%')
targetcli/ui_backstore.py CHANGED
@@ -516,7 +516,9 @@ class UIFileIOBackstore(UIBackstore):
516
516
  '''
517
517
  if current_param != 'file_or_dev':
518
518
  return []
519
- completions = complete_path(text, lambda x: stat.S_ISREG(x) or stat.S_ISBLK(x))
519
+ completions = complete_path(
520
+ text, lambda x: stat.S_ISREG(x) or stat.S_ISBLK(x),
521
+ ) if text else []
520
522
  if len(completions) == 1 and not completions[0].endswith('/'):
521
523
  completions = [completions[0] + ' ']
522
524
  return completions
@@ -545,11 +547,10 @@ class UIBlockBackstore(UIBackstore):
545
547
  return False
546
548
 
547
549
  os.close(f)
548
- if struct.unpack('I', buf)[0] == 0:
549
- return False
550
- return True
550
+ return struct.unpack('I', buf)[0] != 0
551
551
 
552
- def ui_command_create(self, name, dev, readonly=None, wwn=None):
552
+ def ui_command_create(self, name, dev, readonly=None, wwn=None,
553
+ exclusive=None):
553
554
  '''
554
555
  Creates an Block Storage object. "dev" is the path to the TYPE_DISK
555
556
  block device to use.
@@ -561,7 +562,11 @@ class UIBlockBackstore(UIBackstore):
561
562
 
562
563
  wwn = self.ui_eval_param(wwn, 'string', None)
563
564
 
564
- so = BlockStorageObject(name, dev, readonly=readonly, wwn=wwn)
565
+ excl_string = self.ui_eval_param(exclusive, 'string', None)
566
+ exclusive = True if excl_string is None else self.ui_eval_param(exclusive, "bool", True)
567
+
568
+ so = BlockStorageObject(name, dev, readonly=readonly, wwn=wwn,
569
+ exclusive=exclusive)
565
570
  ui_so = UIBlockStorageObject(so, self)
566
571
  self.setup_model_alias(so)
567
572
  self.shell.log.info(f"Created block storage object {name} using {dev}.")
@@ -573,7 +578,7 @@ class UIBlockBackstore(UIBackstore):
573
578
  '''
574
579
  if current_param != 'dev':
575
580
  return []
576
- completions = complete_path(text, stat.S_ISBLK)
581
+ completions = complete_path(text, stat.S_ISBLK) if text else []
577
582
  if len(completions) == 1 and not completions[0].endswith('/'):
578
583
  completions = [completions[0] + ' ']
579
584
  return completions
targetcli/ui_root.py CHANGED
@@ -155,8 +155,7 @@ class UIRoot(UINode):
155
155
  prefs = Path(universal_prefs_file).read_text()
156
156
  backups = [line for line in prefs.splitlines() if re.match(
157
157
  r'^max_backup_files\s*=', line)]
158
- if max_backup_files < int(backups[0].split('=')[1].strip()):
159
- max_backup_files = int(backups[0].split('=')[1].strip())
158
+ max_backup_files = max(max_backup_files, int(backups[0].split('=')[1].strip()))
160
159
  except:
161
160
  self.shell.log.debug(f"No universal prefs file '{universal_prefs_file}'.")
162
161
 
@@ -200,8 +199,7 @@ class UIRoot(UINode):
200
199
  savefile = os.path.expanduser(savefile)
201
200
 
202
201
  if not os.path.isfile(savefile):
203
- self.shell.log.info(f"Restore file {savefile} not found")
204
- return
202
+ raise ExecutionError(f"Restore file {savefile} not found")
205
203
 
206
204
  target = self.ui_eval_param(target, 'string', None)
207
205
  storage_object = self.ui_eval_param(storage_object, 'string', None)
@@ -320,7 +318,7 @@ class UIRoot(UINode):
320
318
  else:
321
319
  printed_sessions = list(self.rtsroot.sessions)
322
320
 
323
- if len(printed_sessions):
321
+ if printed_sessions:
324
322
  for session in printed_sessions:
325
323
  print_session(session)
326
324
  elif sid is None:
targetcli/ui_target.py CHANGED
@@ -939,11 +939,15 @@ class UINodeACL(UIRTSLibNode):
939
939
  if current_param == 'tpg_lun_or_backstore':
940
940
  completions = []
941
941
  for backstore in self.get_node('/backstores').children:
942
- completions = [storage_object.path for storage_object in backstore.children]
942
+ completions.extend(storage_object.path
943
+ for storage_object in backstore.children)
943
944
 
944
- completions.extend(lun.name for lun in self.parent.parent.get_node("luns").children)
945
+ completions.extend(lun.name
946
+ for lun in self.parent.parent.get_node("luns").children)
945
947
 
946
- completions.extend(complete_path(text, lambda x: stat.S_ISREG(x) or stat.S_ISBLK(x)))
948
+ if text:
949
+ completions.extend(complete_path(text,
950
+ lambda x: stat.S_ISREG(x) or stat.S_ISBLK(x)))
947
951
 
948
952
  completions = [c for c in completions if c.startswith(text)]
949
953
  else:
@@ -1151,10 +1155,13 @@ class UILUNs(UINode):
1151
1155
  if current_param == 'storage_object':
1152
1156
  storage_objects = []
1153
1157
  for backstore in self.get_node('/backstores').children:
1154
- storage_objects = [storage_object.path for storage_object in backstore.children]
1158
+ storage_objects.extend(storage_object.path
1159
+ for storage_object in backstore.children)
1155
1160
  completions = [so for so in storage_objects if so.startswith(text)]
1156
1161
 
1157
- completions.extend(complete_path(text, lambda x: stat.S_ISREG(x) or stat.S_ISBLK(x)))
1162
+ if text:
1163
+ completions.extend(complete_path(text,
1164
+ lambda x: stat.S_ISREG(x) or stat.S_ISBLK(x)))
1158
1165
  else:
1159
1166
  completions = []
1160
1167
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: targetcli
3
- Version: 3.0.1
3
+ Version: 3.0.2
4
4
  Summary: A command shell for managing the Linux LIO kernel target
5
5
  Project-URL: Homepage, http://github.com/open-iscsi/targetcli-fb
6
6
  Author-email: Andy Grover <agrover@redhat.com>
@@ -0,0 +1,12 @@
1
+ targetcli/__init__.py,sha256=iZNlmonorHvJu0UpZfsv5etvmnrS2d-HkAF3b96HNZc,687
2
+ targetcli/targetcli_shell.py,sha256=FKElbb1kpMNfxPjDxA5IgJM_hESJie4lGH_goenbsVQ,10536
3
+ targetcli/targetclid.py,sha256=C8rPwJrQ7BFVuMTZRCuguUBU4q6wRb1GFQMdN1fffCU,8100
4
+ targetcli/ui_backstore.py,sha256=jvySMVhE0ACKk3JDraIGAtTO38CSAmGqu-uLivfDcAU,29093
5
+ targetcli/ui_node.py,sha256=qN_RlwwAXrIa7pqkj6IGtoWnlvldglwdg8xyFDYAC8s,8061
6
+ targetcli/ui_root.py,sha256=GK6LYsTfLlOqXpOEZA551j5INqFe_dVqX9sYAg5DnJM,11507
7
+ targetcli/ui_target.py,sha256=1llp6TD13sJ6qhF4aA_xeSO04phsym3akbIijXJ0zNw,52963
8
+ targetcli-3.0.2.dist-info/METADATA,sha256=CN2trxlb0KXPmAfFcMSCZvP-i0bi7sOFXcLL5Qm7nRI,2723
9
+ targetcli-3.0.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
+ targetcli-3.0.2.dist-info/entry_points.txt,sha256=MtQd0tPfd29i4LpVFHz5L6FNO6JiWE3_q4Ae8d4486Y,100
11
+ targetcli-3.0.2.dist-info/licenses/COPYING,sha256=CeipvOyAZxBGUsFoaFqwkx54aPnIKEtm9a5u2uXxEws,10142
12
+ targetcli-3.0.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,12 +0,0 @@
1
- targetcli/__init__.py,sha256=iZNlmonorHvJu0UpZfsv5etvmnrS2d-HkAF3b96HNZc,687
2
- targetcli/targetcli_shell.py,sha256=FKElbb1kpMNfxPjDxA5IgJM_hESJie4lGH_goenbsVQ,10536
3
- targetcli/targetclid.py,sha256=7yuNy_nSmjEdabQYMIozse94wZ5cfFcuXKTXLeSjCKk,8084
4
- targetcli/ui_backstore.py,sha256=bR413k_nHFiK1yvkWCwwXO4nl74Mmht3spk7oUjmihY,28819
5
- targetcli/ui_node.py,sha256=qN_RlwwAXrIa7pqkj6IGtoWnlvldglwdg8xyFDYAC8s,8061
6
- targetcli/ui_root.py,sha256=rhUMSA9cw7Jva0ygd3N2OsRjhafkKbKY_srLBSAibjI,11592
7
- targetcli/ui_target.py,sha256=S2Lb3d-PyeRHP1d9x8N_las5TnFE_dfknDNEu49YiV4,52702
8
- targetcli-3.0.1.dist-info/METADATA,sha256=HDPc5-yVKyxExstYYIY02CjMO8wxA9ptN5Kba-9UOYY,2723
9
- targetcli-3.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- targetcli-3.0.1.dist-info/entry_points.txt,sha256=MtQd0tPfd29i4LpVFHz5L6FNO6JiWE3_q4Ae8d4486Y,100
11
- targetcli-3.0.1.dist-info/licenses/COPYING,sha256=CeipvOyAZxBGUsFoaFqwkx54aPnIKEtm9a5u2uXxEws,10142
12
- targetcli-3.0.1.dist-info/RECORD,,