Class: Dcm4chee::FileSystem

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
app/models/dcm4chee/file_system.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.online ⇒ DataMapper::Collection

Returns All online file systems.

Returns:

  • (DataMapper::Collection) —

    All online file systems



79
80
81
# File 'app/models/dcm4chee/file_system.rb', line 79

def online
  all(availability: 0)
end

.repository(name = nil, &block) ⇒ Object



83
84
85
# File 'app/models/dcm4chee/file_system.rb', line 83

def repository(name = nil, &block)
  super(Dcm4chee.config.repository_name, &block)
end

Instance Method Details

#as_json(opts = {}) ⇒ Hash

Returns Serialized data.

Returns:

  • (Hash) —

    Serialized data



65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/dcm4chee/file_system.rb', line 65

def as_json(opts = {})
  opts[:exclude] ||= []
  opts[:exclude] << :availability

  opts[:methods] ||= []
  opts[:methods].concat([:path, :total_space, :free_space,
                         :used_space, :min_free_space,
                         :expected_space_per_day, :remaining_days])

  super(opts)
end

#availability ⇒ Integer

Returns type of the file system 0: ONLINE 1: NEARLINE 2: OFFLINE.

Returns:

  • (Integer) —

    type of the file system 0: ONLINE 1: NEARLINE 2: OFFLINE



18
# File 'app/models/dcm4chee/file_system.rb', line 18

property :availability, Integer, field: 'availability'

#expected_space_per_day ⇒ Integer

Returns Expected space per day(in bytes).

Returns:

  • (Integer) —

    Expected space per day(in bytes)



55
56
57
# File 'app/models/dcm4chee/file_system.rb', line 55

def expected_space_per_day
  @expected_space_per_day ||= Dcm4chee.file_system_management.expected_data_volume_per_day_bytes
end

#free_space ⇒ Integer

Returns Available space of the file system(in bytes).

Returns:

  • (Integer) —

    Available space of the file system(in bytes)



40
41
42
# File 'app/models/dcm4chee/file_system.rb', line 40

def free_space
  status.block_size * status.blocks_available
end

#id ⇒ Integer

Returns primary key.

Returns:

  • (Integer) —

    primary key



9
# File 'app/models/dcm4chee/file_system.rb', line 9

property :id, Serial, field: 'pk'

#min_free_space ⇒ Integer

Returns Minimum free space of the file system. If the free space is under the limit, dcm4chee will use the next one instead.

Returns:

  • (Integer) —

    Minimum free space of the file system. If the free space is under the limit, dcm4chee will use the next one instead.



50
51
52
# File 'app/models/dcm4chee/file_system.rb', line 50

def min_free_space
  @min_free_space ||= Dcm4chee.file_system_management.minimum_free_disk_space_bytes
end

#path ⇒ Object

Check whether the path is relative or absolute. The default path of the relative one is #{Dcm4chee.config.server_home}/server/default



12
# File 'app/models/dcm4chee/file_system.rb', line 12

property :path, String, field: 'dirpath'

#remaining_days ⇒ Integer

Returns Remaining days of the file system.

Returns:

  • (Integer) —

    Remaining days of the file system



60
61
62
# File 'app/models/dcm4chee/file_system.rb', line 60

def remaining_days
  @remaining_days ||= (free_space - min_free_space) / expected_space_per_day
end

#total_space ⇒ Integer

Returns Total space of the file system(in bytes).

Returns:

  • (Integer) —

    Total space of the file system(in bytes)



35
36
37
# File 'app/models/dcm4chee/file_system.rb', line 35

def total_space
  status.block_size * status.blocks
end

#used_space ⇒ Integer

Returns Used space of the file system(in bytes).

Returns:

  • (Integer) —

    Used space of the file system(in bytes)



45
46
47
# File 'app/models/dcm4chee/file_system.rb', line 45

def used_space
  total_space - free_space
end