diff --git a/scripts/gnt-node b/scripts/gnt-node index cf2419068f28f41454344592d7e1425fde155da5..1908c40a3a9e4e8870a40f5ce389927cc407cba6 100755 --- a/scripts/gnt-node +++ b/scripts/gnt-node @@ -67,6 +67,16 @@ _USER_STORAGE_TYPE = { } +def ConvertStorageType(user_storage_type): + """Converts a user storage type to its internal name. + + """ + try: + return _USER_STORAGE_TYPE[user_storage_type] + except KeyError: + raise errors.OpPrereqError("Unknown storage type: %s" % user_storage_type) + + @UsesRPC def AddNode(opts, args): """Add a node to the cluster. @@ -448,10 +458,7 @@ def ListPhysicalVolumes(opts, args): if opts.user_storage_type is None: opts.user_storage_type = constants.ST_LVM_PV - try: - storage_type = _USER_STORAGE_TYPE[opts.user_storage_type] - except KeyError: - raise errors.OpPrereqError("Unknown storage type: %s" % user_storage_type) + storage_type = ConvertStorageType(opts.user_storage_type) default_fields = { constants.ST_FILE: [ @@ -519,10 +526,7 @@ def ModifyVolume(opts, args): """ (node_name, user_storage_type, volume_name) = args - try: - storage_type = _USER_STORAGE_TYPE[user_storage_type] - except KeyError: - raise errors.OpPrereqError("Unknown storage type: %s" % user_storage_type) + storage_type = ConvertStorageType(user_storage_type) changes = {}