kill_agent = "kill $SSH_AGENT_PID"
waitmaster = (
- "{ . ./.ssh-agent.sh ; "
+ "{ "
+ "echo 'Checking master reachability' ; "
+ "if ping -c 3 %(master_host)s ; then "
+ "echo 'Master node reachable' ; "
+ "else "
+ "echo 'MASTER NODE UNREACHABLE' && "
+ "exit 1 ; "
+ "fi ; "
+ ". ./.ssh-agent.sh ; "
"while [[ $(. ./.ssh-agent.sh > /dev/null ; ssh -q -o UserKnownHostsFile=%(hostkey)s %(sshopts)s %(master)s cat %(token_path)s.retcode || /bin/true) != %(token)s ]] ; do sleep 5 ; done ; "
"if [[ $(. ./.ssh-agent.sh > /dev/null ; ssh -q -o UserKnownHostsFile=%(hostkey)s %(sshopts)s %(master)s cat %(token_path)s || /bin/true) != %(token)s ]] ; then echo BAD TOKEN ; exit 1 ; fi ; "
"}"
) % {
'hostkey' : 'master_known_hosts',
'master' : "%s@%s" % (self._master.node.slicename, self._master.node.hostname),
+ 'master_host' : self._master.node.hostname,
'token_path' : os.path.join(self._master.home_path, 'build.token'),
'token' : server.shell_escape(self._master._master_token),
'sshopts' : sshopts,
r'The GPG keys listed for the ".*" repository are already installed but they are not correct for this package'
r'|Error: Cannot retrieve repository metadata (repomd.xml) for repository: .*[.] Please verify its path and try again'
r'|Error: disk I/O error'
+ r'|MASTER NODE UNREACHABLE'
r')',
re.I)
return badre.search(out) or badre.search(err)
# Generate an initial random cryptographic key to use for tunnelling
# Upon connection, both endpoints will agree on a common one based on
# this one.
- self.tun_key = os.urandom(32).encode("base64").strip()
+ self.tun_key = ( ''.join(map(chr, [
+ r.getrandbits(8)
+ for i in xrange(32)
+ for r in (random.SystemRandom(),) ])
+ ).encode("base64").strip() )
def __str__(self):
def unassign_node(self):
self._node_id = None
- self.__dict__.update(self.__orig_attrs)
+
+ try:
+ orig_attrs = self.__orig_attrs
+ except AttributeError:
+ return
+
+ for key, value in __orig_attrs.iteritems():
+ setattr(self, key, value)
+ del self.__orig_attrs
def rate_nodes(self, nodes):
rates = collections.defaultdict(int)
orig_attrs['server_key'] = self.server_key
self.server_key = info['ssh_rsa_key']
- self.__orig_attrs = orig_attrs
+ try:
+ self.__orig_attrs
+ except AttributeError:
+ self.__orig_attrs = orig_attrs
def validate(self):
if self.home_path is None: