Module: Yast::InstserverRoutinesInclude

Includes:
Logger
Defined in:
src/include/instserver/routines.rb

Instance Method Summary (collapse)

Instance Method Details

- (Hash<String,String>?) distro_map(distro)

Split CPE ID and distro label (separated by comma)

Parameters:

  • distro (String)

    “DISTRO” value from content file

Returns:

  • (Hash<String,String>, nil)

    parsed value, map: { “name” => <string>, “cpeid” => <string> } or nil if the input value is nil or does not contain a comma



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'src/include/instserver/routines.rb', line 32

def distro_map(distro)
  if !distro
    log.warn "Received nil distro value"
    return nil
  end

  # split at the first comma, resulting in 2 parts at max.
  cpeid, name = distro.split(",", 2)

  if !name
    log.warn "Cannot parse DISTRO value: #{distro}"
    return nil
  end

  { "cpeid" => cpeid, "name" => name }
end

- (Object) initialize_instserver_routines(include_target)



12
13
14
# File 'src/include/instserver/routines.rb', line 12

def initialize_instserver_routines(include_target)
  textdomain "instserver"
end

- (Object) ReadContentFile(content)



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'src/include/instserver/routines.rb', line 49

def ReadContentFile(content)
  Builtins.y2debug("Reading content %1", content)

  contentmap = SCR.Read(path(".content_file"), content)
  contentmap.values.each(&:strip!)

  # "DISTRO" flag is used in SLE12, "NAME" and "LABEL" are missing
  # format: "<cpeid>,<product_name>", CPE ID is defined here:
  # http://csrc.nist.gov/publications/nistir/ir7695/NISTIR-7695-CPE-Naming.pdf
  distro = contentmap["DISTRO"]

  if distro
    distro_values = distro_map(distro)

    if distro_values
      # name is displayed in overview
      contentmap["NAME"] = distro_values["name"]
      # label is written to SLP config
      contentmap["LABEL"] = distro_values["name"].dup

      contentmap["CPEID"] = distro_values["cpeid"]
    end
  end

  Builtins.y2milestone("Read content file %1: %2", content, contentmap)

  contentmap
end

- (Object) ReadMediaFile(media)



16
17
18
19
20
21
22
23
24
25
26
# File 'src/include/instserver/routines.rb', line 16

def ReadMediaFile(media)
  if SCR.Read(path(".target.size"), media) != -1
    media_contents = Convert.to_string(
      SCR.Read(path(".target.string"), media)
    )
    m = Builtins.splitstring(media_contents, "\n")
    return deep_copy(m)
  else
    return []
  end
end