Module: OsCtld::Utils::Container

Included in:
Commands::Container::Create, Commands::Container::Reinstall
Defined in:
lib/osctld/utils/container.rb

Instance Method Summary collapse

Instance Method Details

#get_image_path(repos, tpl) ⇒ String?

Parameters:

Options Hash (tpl):

  • :distribution (String)
  • :version (String)
  • :arch (String)
  • :vendor (String)
  • :variant (String)

Returns:

  • (String, nil)


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/osctld/utils/container.rb', line 28

def get_image_path(repos, tpl)
  repos.each do |repo|
    osctl_repo = OsCtlRepo.new(repo)

    begin
      %i(zfs tar).each do |format|
        path = osctl_repo.get_image_path(tpl, format)
        return path if path
      end
    rescue ImageNotFound, ImageRepositoryUnavailable
      next
    end
  end

  nil
end

#get_repositories(pool) ⇒ Array<Repository>

Parameters:

Returns:



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/osctld/utils/container.rb', line 7

def get_repositories(pool)
  if opts[:repository]
    repo = DB::Repositories.find(opts[:repository], pool)
    error!('repository not found') unless repo
    [repo]

  else
    DB::Repositories.get.select do |repo|
      repo.enabled? && repo.pool == pool
    end
  end
end