Revision 5a904197

b/lib/backend.py
778 778
  constants.ST_FILE: _GetFileStorageSpaceInfo,
779 779
  constants.ST_LVM_PV: _GetLvmPvSpaceInfo,
780 780
  constants.ST_LVM_VG: _GetLvmVgSpaceInfo,
781
  constants.ST_SHARED_FILE: None,
781 782
  constants.ST_RADOS: None,
782 783
}
783 784

  
b/lib/bootstrap.py
387 387
  @param default_dir: default file storage directory when C{file_storage_dir}
388 388
      is 'None'
389 389
  @type file_disk_template: string
390
  @param file_disk_template: a disk template whose storage type is 'ST_FILE'
390
  @param file_disk_template: a disk template whose storage type is 'ST_FILE' or
391
      'ST_SHARED_FILE'
391 392
  @rtype: string
392 393
  @returns: the name of the actual file storage directory
393 394

  
394 395
  """
395
  assert (file_disk_template in
396
          utils.storage.GetDiskTemplatesOfStorageType(constants.ST_FILE))
396
  assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes(
397
            constants.ST_FILE, constants.ST_SHARED_FILE
398
         ))
399

  
397 400
  if file_storage_dir is None:
398 401
    file_storage_dir = default_dir
399 402
  if not acceptance_fn:
b/lib/client/gnt_node.py
89 89
  constants.ST_FILE: "file",
90 90
  constants.ST_LVM_PV: "lvm-pv",
91 91
  constants.ST_LVM_VG: "lvm-vg",
92
  constants.ST_SHARED_FILE: "sharedfile",
92 93
  }
93 94

  
94 95
_STORAGE_TYPE_OPT = \
b/lib/cmdlib/cluster.py
654 654
      path should be checked
655 655

  
656 656
  """
657
  assert (file_disk_template in
658
          utils.storage.GetDiskTemplatesOfStorageType(constants.ST_FILE))
657
  assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes(
658
            constants.ST_FILE, constants.ST_SHARED_FILE
659
         ))
659 660
  file_storage_enabled = file_disk_template in enabled_disk_templates
660 661
  if file_storage_dir is not None:
661 662
    if file_storage_dir == "":
......
2576 2577
        in case something goes wrong in this verification step
2577 2578

  
2578 2579
    """
2579
    assert (file_disk_template in
2580
            utils.storage.GetDiskTemplatesOfStorageType(constants.ST_FILE))
2580
    assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes(
2581
              constants.ST_FILE, constants.ST_SHARED_FILE
2582
           ))
2583

  
2581 2584
    cluster = self.cfg.GetClusterInfo()
2582 2585
    if cluster.IsDiskTemplateEnabled(file_disk_template):
2583 2586
      self._ErrorIf(
b/lib/cmdlib/common.py
1104 1104
    CheckStorageTypeEnabled(cluster, constants.ST_LVM_VG)
1105 1105
  else:
1106 1106
    possible_disk_templates = \
1107
        utils.storage.GetDiskTemplatesOfStorageType(storage_type)
1107
        utils.storage.GetDiskTemplatesOfStorageTypes(storage_type)
1108 1108
    for disk_template in possible_disk_templates:
1109 1109
      if disk_template in cluster.enabled_disk_templates:
1110 1110
        return
......
1174 1174
    access = parameters[disk_template].get(constants.LDP_ACCESS,
1175 1175
                                           constants.DISK_KERNELSPACE)
1176 1176

  
1177
    if dt not in constants.DTS_HAVE_ACCESS
1177
    if disk_template not in constants.DTS_HAVE_ACCESS:
1178 1178
      continue
1179 1179

  
1180 1180
    #Check the combination of instance hypervisor, disk template and access
b/lib/cmdlib/node.py
1112 1112

  
1113 1113
  """
1114 1114
  # Special case for file storage
1115
  if storage_type == constants.ST_FILE:
1116
    # storage.FileStorage wants a list of storage directories
1117
    return [[cfg.GetFileStorageDir(), cfg.GetSharedFileStorageDir()]]
1118 1115

  
1119
  return []
1116
  if storage_type == constants.ST_FILE:
1117
    return [[cfg.GetFileStorageDir()]]
1118
  elif storage_type == constants.ST_SHARED_FILE:
1119
    dts = cfg.GetClusterInfo().enabled_disk_templates
1120
    paths = []
1121
    if constants.DT_SHARED_FILE in dts:
1122
      paths.append(cfg.GetSharedFileStorageDir())
1123
    if constants.DT_GLUSTER in dts:
1124
      paths.append(cfg.GetGlusterStorageDir())
1125
    return [paths]
1126
  else:
1127
    return []
1120 1128

  
1121 1129

  
1122 1130
class LUNodeModifyStorage(NoHooksLU):
......
1302 1310
      self.storage_type = self.op.storage_type
1303 1311
    else:
1304 1312
      self.storage_type = self._DetermineStorageType()
1305
      if self.storage_type not in constants.STS_REPORT:
1313
      supported_storage_types = constants.STS_REPORT_NODE_STORAGE
1314
      if self.storage_type not in supported_storage_types:
1306 1315
        raise errors.OpPrereqError(
1307 1316
            "Storage reporting for storage type '%s' is not supported. Please"
1308 1317
            " use the --storage-type option to specify one of the supported"
1309 1318
            " storage types (%s) or set the default disk template to one that"
1310 1319
            " supports storage reporting." %
1311
            (self.storage_type, utils.CommaJoin(constants.STS_REPORT)))
1320
            (self.storage_type, utils.CommaJoin(supported_storage_types)))
1312 1321

  
1313 1322
  def Exec(self, feedback_fn):
1314 1323
    """Computes the list of nodes and their attributes.
b/lib/storage/container.py
468 468
  constants.ST_FILE: FileStorage,
469 469
  constants.ST_LVM_PV: LvmPvStorage,
470 470
  constants.ST_LVM_VG: LvmVgStorage,
471
  constants.ST_SHARED_FILE: FileStorage,
471 472
  }
472 473

  
473 474

  
b/lib/utils/storage.py
27 27
from ganeti import constants
28 28

  
29 29

  
30
def GetDiskTemplatesOfStorageType(storage_type):
30
def GetDiskTemplatesOfStorageTypes(*storage_types):
31 31
  """Given the storage type, returns a list of disk templates based on that
32 32
     storage type."""
33 33
  return [dt for dt in constants.DISK_TEMPLATES
34
          if constants.MAP_DISK_TEMPLATE_STORAGE_TYPE[dt] == storage_type]
34
          if constants.MAP_DISK_TEMPLATE_STORAGE_TYPE[dt] in storage_types]
35 35

  
36 36

  
37 37
def IsDiskTemplateEnabled(disk_template, enabled_disk_templates):
b/qa/qa_cluster.py
519 519

  
520 520
  # Get some non-file-based disk template to disable file storage
521 521
  other_disk_template = _GetOtherEnabledDiskTemplate(
522
      utils.storage.GetDiskTemplatesOfStorageType(constants.ST_FILE),
523
      enabled_disk_templates)
522
    utils.storage.GetDiskTemplatesOfStorageTypes(constants.ST_FILE,
523
                                                 constants.ST_SHARED_FILE),
524
    enabled_disk_templates
525
  )
524 526

  
525 527
  file_storage_dir = qa_config.get(dir_config_key, default_dir)
526 528
  invalid_file_storage_dir = "/boot/"
b/qa/qa_config.py
480 480
    """
481 481
    enabled_disk_templates = self.GetEnabledDiskTemplates()
482 482
    if storage_type == constants.ST_LVM_PV:
483
      disk_templates = utils.GetDiskTemplatesOfStorageType(constants.ST_LVM_VG)
483
      disk_templates = utils.GetDiskTemplatesOfStorageTypes(constants.ST_LVM_VG)
484 484
    else:
485
      disk_templates = utils.GetDiskTemplatesOfStorageType(storage_type)
485
      disk_templates = utils.GetDiskTemplatesOfStorageTypes(storage_type)
486 486
    return bool(set(enabled_disk_templates).intersection(set(disk_templates)))
487 487

  
488 488
  def AreSpindlesSupported(self):
b/qa/qa_instance.py
135 135
    vols = info["volumes"]
136 136
    for node in info["nodes"]:
137 137
      AssertCommand(["lvremove", "-f"] + vols, node=node)
138
  elif info["storage-type"] == constants.ST_FILE:
138
  elif info["storage-type"] in (constants.ST_FILE, constants.ST_SHARED_FILE):
139 139
    # Note that this works for both file and sharedfile, and this is intended.
140 140
    storage_dir = qa_config.get("file-storage-dir",
141 141
                                pathutils.DEFAULT_FILE_STORAGE_DIR)
b/src/Ganeti/Constants.hs
659 659
stFile :: String
660 660
stFile = Types.storageTypeToRaw StorageFile
661 661

  
662
stSharedFile :: String
663
stSharedFile = Types.storageTypeToRaw StorageSharedFile
664

  
662 665
stLvmPv :: String
663 666
stLvmPv = Types.storageTypeToRaw StorageLvmPv
664 667

  
......
671 674
storageTypes :: FrozenSet String
672 675
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
673 676

  
674
-- | The set of storage types for which storage reporting is available
675
--
676
-- FIXME: Remove this, once storage reporting is available for all
677
-- types.
677
-- | The set of storage types for which full storage reporting is available
678 678
stsReport :: FrozenSet String
679 679
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
680 680

  
681
-- | The set of storage types for which node storage reporting is available
682
-- | (as used by LUQueryNodeStorage)
683
stsReportNodeStorage :: FrozenSet String
684
stsReportNodeStorage = ConstantUtils.union stsReport $
685
                                           ConstantUtils.mkSet [stSharedFile]
686

  
681 687
-- * Storage fields
682 688
-- ** First two are valid in LU context only, not passed to backend
683 689

  
......
818 824
  [(DTBlock, StorageBlock),
819 825
   (DTDrbd8, StorageLvmVg),
820 826
   (DTExt, StorageExt),
821
   (DTSharedFile, StorageFile),
827
   (DTSharedFile, StorageSharedFile),
822 828
   (DTFile, StorageFile),
823 829
   (DTDiskless, StorageDiskless),
824 830
   (DTPlain, StorageLvmVg),
825 831
   (DTRbd, StorageRados),
826
   (DTGluster, StorageFile)]
832
   (DTGluster, StorageSharedFile)]
827 833

  
828 834
-- | The set of network-mirrored disk templates
829 835
dtsIntMirror :: FrozenSet String
b/src/Ganeti/Storage/Utils.hs
44 44
getDefaultStorageKey cfg T.DTPlain = clusterVolumeGroupName $ configCluster cfg
45 45
getDefaultStorageKey cfg T.DTFile =
46 46
    Just (clusterFileStorageDir $ configCluster cfg)
47
getDefaultStorageKey cfg T.DTSharedFile =
48
    Just (clusterSharedFileStorageDir $ configCluster cfg)
49 47
getDefaultStorageKey _ _ = Nothing
50 48

  
51 49
-- | Get the cluster's default spindle storage unit
b/src/Ganeti/Types.hs
459 459
-- | Storage type.
460 460
$(THH.declareLADT ''String "StorageType"
461 461
  [ ("StorageFile", "file")
462
  , ("StorageSharedFile", "sharedfile")
462 463
  , ("StorageLvmPv", "lvm-pv")
463 464
  , ("StorageLvmVg", "lvm-vg")
464 465
  , ("StorageDiskless", "diskless")
......
481 482

  
482 483
-- | Full storage unit with storage-type-specific parameters
483 484
data StorageUnit = SUFile StorageKey
485
                 | SUSharedFile StorageKey
484 486
                 | SULvmPv StorageKey SPExclusiveStorage
485 487
                 | SULvmVg StorageKey SPExclusiveStorage
486 488
                 | SUDiskless StorageKey
......
491 493

  
492 494
instance Show StorageUnit where
493 495
  show (SUFile key) = showSUSimple StorageFile key
496
  show (SUSharedFile key) = showSUSimple StorageSharedFile key
494 497
  show (SULvmPv key es) = showSULvm StorageLvmPv key es
495 498
  show (SULvmVg key es) = showSULvm StorageLvmVg key es
496 499
  show (SUDiskless key) = showSUSimple StorageDiskless key
......
500 503

  
501 504
instance JSON StorageUnit where
502 505
  showJSON (SUFile key) = showJSON (StorageFile, key, []::[String])
506
  showJSON (SUSharedFile key) = showJSON (StorageSharedFile, key, []::[String])
503 507
  showJSON (SULvmPv key es) = showJSON (StorageLvmPv, key, [es])
504 508
  showJSON (SULvmVg key es) = showJSON (StorageLvmVg, key, [es])
505 509
  showJSON (SUDiskless key) = showJSON (StorageDiskless, key, []::[String])
......
525 529
diskTemplateToStorageType :: DiskTemplate -> StorageType
526 530
diskTemplateToStorageType DTExt = StorageExt
527 531
diskTemplateToStorageType DTFile = StorageFile
528
diskTemplateToStorageType DTSharedFile = StorageFile
532
diskTemplateToStorageType DTSharedFile = StorageSharedFile
529 533
diskTemplateToStorageType DTDrbd8 = StorageLvmVg
530 534
diskTemplateToStorageType DTPlain = StorageLvmVg
531 535
diskTemplateToStorageType DTRbd = StorageRados
532 536
diskTemplateToStorageType DTDiskless = StorageDiskless
533 537
diskTemplateToStorageType DTBlock = StorageBlock
534
diskTemplateToStorageType DTGluster = StorageFile
538
diskTemplateToStorageType DTGluster = StorageSharedFile
535 539

  
536 540
-- | Equips a raw storage unit with its parameters
537 541
addParamsToStorageUnit :: SPExclusiveStorage -> StorageUnitRaw -> StorageUnit
......
539 543
addParamsToStorageUnit _ (SURaw StorageDiskless key) = SUDiskless key
540 544
addParamsToStorageUnit _ (SURaw StorageExt key) = SUExt key
541 545
addParamsToStorageUnit _ (SURaw StorageFile key) = SUFile key
546
addParamsToStorageUnit _ (SURaw StorageSharedFile key) = SUSharedFile key
542 547
addParamsToStorageUnit es (SURaw StorageLvmPv key) = SULvmPv key es
543 548
addParamsToStorageUnit es (SURaw StorageLvmVg key) = SULvmVg key es
544 549
addParamsToStorageUnit _ (SURaw StorageRados key) = SURados key
b/test/py/ganeti.backend_unittest.py
839 839
class TestSpaceReportingConstants(unittest.TestCase):
840 840
  """Ensures consistency between STS_REPORT and backend.
841 841

  
842
  These tests ensure, that the constant 'STS_REPORT' is consitent
842
  These tests ensure, that the constant 'STS_REPORT' is consistent
843 843
  with the implementation of invoking space reporting functions
844 844
  in backend.py. Once space reporting is available for all types,
845 845
  the constant can be removed and these tests as well.
846 846

  
847 847
  """
848

  
849
  REPORTING = set(constants.STS_REPORT)
850
  NOT_REPORTING = set(constants.STORAGE_TYPES) - REPORTING
851

  
848 852
  def testAllReportingTypesHaveAReportingFunction(self):
849
    for storage_type in constants.STS_REPORT:
853
    for storage_type in TestSpaceReportingConstants.REPORTING:
850 854
      self.assertTrue(backend._STORAGE_TYPE_INFO_FN[storage_type] is not None)
851 855

  
852
  def testAllNotReportingTypesDoneHaveFunction(self):
853
    non_reporting_types = set(constants.STORAGE_TYPES)\
854
        - set(constants.STS_REPORT)
855
    for storage_type in non_reporting_types:
856
  def testAllNotReportingTypesDontHaveFunction(self):
857
    for storage_type in TestSpaceReportingConstants.NOT_REPORTING:
856 858
      self.assertEqual(None, backend._STORAGE_TYPE_INFO_FN[storage_type])
857 859

  
858 860

  
b/test/py/ganeti.utils.storage_unittest.py
61 61
    (storage_type, storage_key) = \
62 62
        storage._GetDefaultStorageUnitForDiskTemplate(self._cfg,
63 63
                                                      constants.DT_SHARED_FILE)
64
    self.assertEqual(storage_type, constants.ST_FILE)
64
    self.assertEqual(storage_type, constants.ST_SHARED_FILE)
65 65
    self.assertEqual(storage_key, self._cluster.shared_file_storage_dir)
66 66

  
67 67
  def testGetDefaultStorageUnitForDiskTemplateDiskless(self):
......
80 80
    self._cfg = mock.Mock()
81 81

  
82 82
  def testGetStorageUnits(self):
83
    disk_templates = constants.DTS_FILEBASED
83
    disk_templates = constants.DTS_FILEBASED - frozenset(
84
      storage.GetDiskTemplatesOfStorageTypes(constants.ST_SHARED_FILE)
85
    )
84 86
    storage_units = storage.GetStorageUnits(self._cfg, disk_templates)
85 87
    self.assertEqual(len(storage_units), len(disk_templates))
86 88

  

Also available in: Unified diff