Revision a9542a4f

b/lib/bootstrap.py
577 577
                               errors.ECODE_INVAL)
578 578

  
579 579
  # set up ssh config and /etc/hosts
580
  sshline = utils.ReadFile(pathutils.SSH_HOST_RSA_PUB)
581
  sshkey = sshline.split(" ")[1]
580
  rsa_sshkey = ""
581
  dsa_sshkey = ""
582
  if os.path.isfile(pathutils.SSH_HOST_RSA_PUB):
583
    sshline = utils.ReadFile(pathutils.SSH_HOST_RSA_PUB)
584
    rsa_sshkey = sshline.split(" ")[1]
585
  if os.path.isfile(pathutils.SSH_HOST_DSA_PUB):
586
    sshline = utils.ReadFile(pathutils.SSH_HOST_DSA_PUB)
587
    dsa_sshkey = sshline.split(" ")[1]
588
  if not rsa_sshkey and not dsa_sshkey:
589
    raise errors.OpPrereqError("Failed to find SSH public keys",
590
                               errors.ECODE_ENVIRON)
582 591

  
583 592
  if modify_etc_hosts:
584 593
    utils.AddHostToEtcHosts(hostname.name, hostname.ip)
......
606 615
  # init of cluster config file
607 616
  cluster_config = objects.Cluster(
608 617
    serial_no=1,
609
    rsahostkeypub=sshkey,
618
    rsahostkeypub=rsa_sshkey,
619
    dsahostkeypub=dsa_sshkey,
610 620
    highest_used_port=(constants.FIRST_DRBD_PORT - 1),
611 621
    mac_prefix=mac_prefix,
612 622
    volume_group_name=vg_name,
b/lib/config.py
1190 1190
    return self._config_data.cluster.enabled_hypervisors[0]
1191 1191

  
1192 1192
  @locking.ssynchronized(_config_lock, shared=1)
1193
  def GetHostKey(self):
1193
  def GetRsaHostKey(self):
1194 1194
    """Return the rsa hostkey from the config.
1195 1195

  
1196 1196
    @rtype: string
......
1200 1200
    return self._config_data.cluster.rsahostkeypub
1201 1201

  
1202 1202
  @locking.ssynchronized(_config_lock, shared=1)
1203
  def GetDsaHostKey(self):
1204
    """Return the dsa hostkey from the config.
1205

  
1206
    @rtype: string
1207
    @return: the dsa hostkey
1208

  
1209
    """
1210
    return self._config_data.cluster.dsahostkeypub
1211

  
1212
  @locking.ssynchronized(_config_lock, shared=1)
1203 1213
  def GetDefaultIAllocator(self):
1204 1214
    """Get the default instance allocator for this cluster.
1205 1215

  
b/lib/objects.py
1519 1519
  __slots__ = [
1520 1520
    "serial_no",
1521 1521
    "rsahostkeypub",
1522
    "dsahostkeypub",
1522 1523
    "highest_used_port",
1523 1524
    "tcpudp_port_pool",
1524 1525
    "mac_prefix",
b/lib/ssh.py
328 328
  """Writes the cluster-wide equally known_hosts file.
329 329

  
330 330
  """
331
  utils.WriteFile(file_name, mode=0600,
332
                  data="%s ssh-rsa %s\n" % (cfg.GetClusterName(),
333
                                            cfg.GetHostKey()))
331
  data = ""
332
  if cfg.GetRsaHostKey():
333
    data += "%s ssh-rsa %s\n" % (cfg.GetClusterName(), cfg.GetRsaHostKey())
334
  if cfg.GetDsaHostKey():
335
    data += "%s ssh-dss %s\n" % (cfg.GetClusterName(), cfg.GetDsaHostKey())
336

  
337
  utils.WriteFile(file_name, mode=0600, data=data)
b/src/Ganeti/Objects.hs
669 669
-- * Cluster definitions
670 670
$(buildObject "Cluster" "cluster" $
671 671
  [ simpleField "rsahostkeypub"           [t| String           |]
672
  , simpleField "dsahostkeypub"           [t| String           |]
672 673
  , simpleField "highest_used_port"       [t| Int              |]
673 674
  , simpleField "tcpudp_port_pool"        [t| [Int]            |]
674 675
  , simpleField "mac_prefix"              [t| String           |]
b/test/py/ganeti.config_unittest.py
76 76
    cluster_config = objects.Cluster(
77 77
      serial_no=1,
78 78
      rsahostkeypub="",
79
      dsahostkeypub="",
79 80
      highest_used_port=(constants.FIRST_DRBD_PORT - 1),
80 81
      mac_prefix="aa:00:00",
81 82
      volume_group_name="xenvg",
b/test/py/ganeti.ssh_unittest.py
46 46
    cfg = mocks.FakeConfig()
47 47
    ssh.WriteKnownHostsFile(cfg, self.tmpfile)
48 48
    self.assertFileContent(self.tmpfile,
49
        "%s ssh-rsa %s\n" % (cfg.GetClusterName(),
50
                             mocks.FAKE_CLUSTER_KEY))
49
        "%s ssh-rsa %s\n%s ssh-dss %s\n" %
50
        (cfg.GetClusterName(), mocks.FAKE_CLUSTER_KEY,
51
         cfg.GetClusterName(), mocks.FAKE_CLUSTER_KEY))
51 52

  
52 53

  
53 54
class TestGetUserFiles(unittest.TestCase):
b/test/py/mocks.py
46 46
  def GetNodeList(self):
47 47
    return ["a", "b", "c"]
48 48

  
49
  def GetHostKey(self):
49
  def GetRsaHostKey(self):
50
    return FAKE_CLUSTER_KEY
51

  
52
  def GetDsaHostKey(self):
50 53
    return FAKE_CLUSTER_KEY
51 54

  
52 55
  def GetClusterName(self):
b/tools/sanitize-config
85 85

  
86 86
  """
87 87
  cfg["cluster"]["rsahostkeypub"] = ""
88
  cfg["cluster"]["dsahostkeypub"] = ""
88 89
  for instance in cfg["instances"].values():
89 90
    for disk in instance["disks"]:
90 91
      RandomizeDiskSecrets(disk)

Also available in: Unified diff