Class: Y2Packager::StorageManagerProxy

Inherits:
Object
  • Object
show all
Includes:
Yast::Logger
Defined in:
src/lib/y2packager/storage_manager_proxy.rb

Overview

Class to safely access some useful methods usually provided by the instance of Y2Storage::StorageManager. If Y2Storage is available, all the calls will be forwarded to the mentioned object. Otherwise, safe defaults will be provided.

This class plays the same role than the storage_wrapper client that existed in the YCP era. Mainly allowing (limited) operation if yast2-storage is not available in order to break the strong dependency cycle.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStorageManagerProxy

Returns a new instance of StorageManagerProxy


39
40
41
42
43
44
45
# File 'src/lib/y2packager/storage_manager_proxy.rb', line 39

def initialize
  require "y2storage"
  @manager = Y2Storage::StorageManager.instance
rescue LoadError
  log.info("Y2Storage not available. Fallback values will be used")
  @manager = nil
end

Instance Attribute Details

#managerObject (readonly, protected)

Returns the value of attribute manager


67
68
69
# File 'src/lib/y2packager/storage_manager_proxy.rb', line 67

def manager
  @manager
end

Instance Method Details

#stagingStorage::Devicegraph

Staging devicegraph at Y2Storage::StorageManager or empty devicegraph if Y2Storage is not available

Returns:

  • (Storage::Devicegraph)

51
52
53
54
55
56
# File 'src/lib/y2packager/storage_manager_proxy.rb', line 51

def staging
  return manager.staging if manager

  log.info("Y2Storage not available. Instantiating an empty devicegraph")
  Storage::Devicegraph.new
end

#staging_revisionFixnum

Revision of the staging devicegraph if Y2Storage is available, 0 otherwise

Returns:

  • (Fixnum)

61
62
63
# File 'src/lib/y2packager/storage_manager_proxy.rb', line 61

def staging_revision
  manager ? manager.staging_revision : 0
end