547 |
547 |
"""
|
548 |
548 |
env = {
|
549 |
549 |
"CLUSTER": self.op.cluster_name,
|
550 |
|
"MASTER": self.hostname['hostname_full'],
|
|
550 |
"MASTER": self.hostname.name,
|
551 |
551 |
}
|
552 |
|
return env, [], [self.hostname['hostname_full']]
|
|
552 |
return env, [], [self.hostname.name]
|
553 |
553 |
|
554 |
554 |
def CheckPrereq(self):
|
555 |
555 |
"""Verify that the passed name is a valid one.
|
... | ... | |
564 |
564 |
raise errors.OpPrereqError("Cannot resolve my own hostname ('%s')" %
|
565 |
565 |
hostname_local)
|
566 |
566 |
|
567 |
|
if hostname["hostname_full"] != hostname_local:
|
|
567 |
if hostname.name != hostname_local:
|
568 |
568 |
raise errors.OpPrereqError("My own hostname (%s) does not match the"
|
569 |
569 |
" resolver (%s): probably not using FQDN"
|
570 |
570 |
" for hostname." %
|
571 |
|
(hostname_local, hostname["hostname_full"]))
|
|
571 |
(hostname_local, hostname.name))
|
572 |
572 |
|
573 |
|
if hostname["ip"].startswith("127."):
|
|
573 |
if hostname.ip.startswith("127."):
|
574 |
574 |
raise errors.OpPrereqError("This host's IP resolves to the private"
|
575 |
575 |
" range (%s). Please fix DNS or /etc/hosts." %
|
576 |
|
(hostname["ip"],))
|
|
576 |
(hostname.ip,))
|
577 |
577 |
|
578 |
578 |
self.clustername = clustername = utils.LookupHostname(self.op.cluster_name)
|
579 |
579 |
if not clustername:
|
580 |
580 |
raise errors.OpPrereqError("Cannot resolve given cluster name ('%s')"
|
581 |
581 |
% self.op.cluster_name)
|
582 |
582 |
|
583 |
|
result = utils.RunCmd(["fping", "-S127.0.0.1", "-q", hostname['ip']])
|
|
583 |
result = utils.RunCmd(["fping", "-S127.0.0.1", "-q", hostname.ip])
|
584 |
584 |
if result.failed:
|
585 |
585 |
raise errors.OpPrereqError("Inconsistency: this host's name resolves"
|
586 |
586 |
" to %s,\nbut this ip address does not"
|
587 |
587 |
" belong to this host."
|
588 |
|
" Aborting." % hostname['ip'])
|
|
588 |
" Aborting." % hostname.ip)
|
589 |
589 |
|
590 |
590 |
secondary_ip = getattr(self.op, "secondary_ip", None)
|
591 |
591 |
if secondary_ip and not utils.IsValidIP(secondary_ip):
|
592 |
592 |
raise errors.OpPrereqError("Invalid secondary ip given")
|
593 |
|
if secondary_ip and secondary_ip != hostname['ip']:
|
|
593 |
if secondary_ip and secondary_ip != hostname.ip:
|
594 |
594 |
result = utils.RunCmd(["fping", "-S127.0.0.1", "-q", secondary_ip])
|
595 |
595 |
if result.failed:
|
596 |
596 |
raise errors.OpPrereqError("You gave %s as secondary IP,\n"
|
... | ... | |
629 |
629 |
# set up the simple store
|
630 |
630 |
ss = ssconf.SimpleStore()
|
631 |
631 |
ss.SetKey(ss.SS_HYPERVISOR, self.op.hypervisor_type)
|
632 |
|
ss.SetKey(ss.SS_MASTER_NODE, hostname['hostname_full'])
|
633 |
|
ss.SetKey(ss.SS_MASTER_IP, clustername['ip'])
|
|
632 |
ss.SetKey(ss.SS_MASTER_NODE, hostname.name)
|
|
633 |
ss.SetKey(ss.SS_MASTER_IP, clustername.ip)
|
634 |
634 |
ss.SetKey(ss.SS_MASTER_NETDEV, self.op.master_netdev)
|
635 |
|
ss.SetKey(ss.SS_CLUSTER_NAME, clustername['hostname'])
|
|
635 |
ss.SetKey(ss.SS_CLUSTER_NAME, clustername.name)
|
636 |
636 |
|
637 |
637 |
# set up the inter-node password and certificate
|
638 |
638 |
_InitGanetiServerSetup(ss)
|
639 |
639 |
|
640 |
640 |
# start the master ip
|
641 |
|
rpc.call_node_start_master(hostname['hostname_full'])
|
|
641 |
rpc.call_node_start_master(hostname.name)
|
642 |
642 |
|
643 |
643 |
# set up ssh config and /etc/hosts
|
644 |
644 |
f = open('/etc/ssh/ssh_host_rsa_key.pub', 'r')
|
... | ... | |
648 |
648 |
f.close()
|
649 |
649 |
sshkey = sshline.split(" ")[1]
|
650 |
650 |
|
651 |
|
_UpdateEtcHosts(hostname['hostname_full'],
|
652 |
|
hostname['ip'],
|
653 |
|
)
|
|
651 |
_UpdateEtcHosts(hostname.name, hostname.ip)
|
654 |
652 |
|
655 |
|
_UpdateKnownHosts(hostname['hostname_full'],
|
656 |
|
hostname['ip'],
|
657 |
|
sshkey,
|
658 |
|
)
|
|
653 |
_UpdateKnownHosts(hostname.name, hostname.ip, sshkey)
|
659 |
654 |
|
660 |
|
_InitSSHSetup(hostname['hostname'])
|
|
655 |
_InitSSHSetup(hostname.name)
|
661 |
656 |
|
662 |
657 |
# init of cluster config file
|
663 |
658 |
cfgw = config.ConfigWriter()
|
664 |
|
cfgw.InitConfig(hostname['hostname'], hostname['ip'], self.secondary_ip,
|
|
659 |
cfgw.InitConfig(hostname.name, hostname.ip, self.secondary_ip,
|
665 |
660 |
sshkey, self.op.mac_prefix,
|
666 |
661 |
self.op.vg_name, self.op.def_bridge)
|
667 |
662 |
|
... | ... | |
971 |
966 |
raise errors.OpPrereqError("Cannot resolve the new cluster name ('%s')" %
|
972 |
967 |
self.op.name)
|
973 |
968 |
|
974 |
|
new_name = hostname["hostname"]
|
975 |
|
self.ip = new_ip = hostname["ip"]
|
|
969 |
new_name = hostname.name
|
|
970 |
self.ip = new_ip = hostname.ip
|
976 |
971 |
old_name = self.sstore.GetClusterName()
|
977 |
972 |
old_ip = self.sstore.GetMasterIP()
|
978 |
973 |
if new_name == old_name and new_ip == old_ip:
|
... | ... | |
1413 |
1408 |
if not dns_data:
|
1414 |
1409 |
raise errors.OpPrereqError("Node %s is not resolvable" % node_name)
|
1415 |
1410 |
|
1416 |
|
node = dns_data['hostname']
|
1417 |
|
primary_ip = self.op.primary_ip = dns_data['ip']
|
|
1411 |
node = dns_data.name
|
|
1412 |
primary_ip = self.op.primary_ip = dns_data.ip
|
1418 |
1413 |
secondary_ip = getattr(self.op, "secondary_ip", None)
|
1419 |
1414 |
if secondary_ip is None:
|
1420 |
1415 |
secondary_ip = primary_ip
|
... | ... | |
2162 |
2157 |
raise errors.OpPrereqError("New instance name '%s' not found in dns" %
|
2163 |
2158 |
self.op.new_name)
|
2164 |
2159 |
|
2165 |
|
self.op.new_name = new_name = hostname1['hostname']
|
|
2160 |
self.op.new_name = new_name = hostname1.name
|
2166 |
2161 |
if not getattr(self.op, "ignore_ip", False):
|
2167 |
|
command = ["fping", "-q", hostname1['ip']]
|
|
2162 |
command = ["fping", "-q", hostname1.ip]
|
2168 |
2163 |
result = utils.RunCmd(command)
|
2169 |
2164 |
if not result.failed:
|
2170 |
2165 |
raise errors.OpPrereqError("IP %s of instance %s already in use" %
|
2171 |
|
(hostname1['ip'], new_name))
|
|
2166 |
(hostname1.ip, new_name))
|
2172 |
2167 |
|
2173 |
2168 |
|
2174 |
2169 |
def Exec(self, feedback_fn):
|
... | ... | |
2849 |
2844 |
raise errors.OpPrereqError("Instance name '%s' not found in dns" %
|
2850 |
2845 |
self.op.instance_name)
|
2851 |
2846 |
|
2852 |
|
self.op.instance_name = instance_name = hostname1['hostname']
|
|
2847 |
self.op.instance_name = instance_name = hostname1.name
|
2853 |
2848 |
instance_list = self.cfg.GetInstanceList()
|
2854 |
2849 |
if instance_name in instance_list:
|
2855 |
2850 |
raise errors.OpPrereqError("Instance '%s' is already in the cluster" %
|
... | ... | |
2859 |
2854 |
if ip is None or ip.lower() == "none":
|
2860 |
2855 |
inst_ip = None
|
2861 |
2856 |
elif ip.lower() == "auto":
|
2862 |
|
inst_ip = hostname1['ip']
|
|
2857 |
inst_ip = hostname1.ip
|
2863 |
2858 |
else:
|
2864 |
2859 |
if not utils.IsValidIP(ip):
|
2865 |
2860 |
raise errors.OpPrereqError("given IP address '%s' doesn't look"
|
... | ... | |
2867 |
2862 |
inst_ip = ip
|
2868 |
2863 |
self.inst_ip = inst_ip
|
2869 |
2864 |
|
2870 |
|
command = ["fping", "-q", hostname1['ip']]
|
|
2865 |
command = ["fping", "-q", hostname1.ip]
|
2871 |
2866 |
result = utils.RunCmd(command)
|
2872 |
2867 |
if not result.failed:
|
2873 |
2868 |
raise errors.OpPrereqError("IP %s of instance %s already in use" %
|
2874 |
|
(hostname1['ip'], instance_name))
|
|
2869 |
(hostname1.ip, instance_name))
|
2875 |
2870 |
|
2876 |
2871 |
# bridge verification
|
2877 |
2872 |
bridge = getattr(self.op, "bridge", None)
|