Class: Volume

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/mkit/app/model/volume.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(service, volume) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mkit/app/model/volume.rb', line 9

def self.create(service, volume)
      case volume
      when /^docker:\/\//
        ctype = MKIt::CType::DOCKER_STORAGE
        paths = volume[9..].split(':')
        # vname="#{service.name}.#{service.application.name}.#{paths[0]}"
        vname = paths[0]
      when /^\//
        ctype = MKIt::CType::LOCAL_STORAGE
        paths = volume.split(':')
        vname = paths[0]
      end
      Volume.new(
        service: service,
        name: vname,
        path: paths[1],
        ctype: ctype
      )
end

Instance Method Details

#clean_upObject



49
50
51
# File 'lib/mkit/app/model/volume.rb', line 49

def clean_up
  # nop
end

#create_volumeObject



33
34
35
36
37
38
39
40
# File 'lib/mkit/app/model/volume.rb', line 33

def create_volume
  case self.ctype
  when MKIt::CType::DOCKER_STORAGE
    MKIt::DockerHelper.create_volume(self.name)
  when MKIt::CType::LOCAL_STORAGE
    # nop
  end
end

#delete_volumeObject



42
43
44
45
46
47
# File 'lib/mkit/app/model/volume.rb', line 42

def delete_volume
  case self.ctype
  when MKIt::CType::DOCKER_STORAGE
    MKIt::DockerHelper.delete_volume(self.name)
  end
end

#deployObject



29
30
31
# File 'lib/mkit/app/model/volume.rb', line 29

def deploy
  create_volume
end