]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/netsplit.py
2 Functions to netsplit test machines.
4 At present, you must specify monitors to disconnect, and it
5 drops those IP pairs. This means OSDs etc on the hosts which use
6 the same IP will also be blocked! If you are using multiple IPs on the
7 same host within the cluster, daemons on those other IPs will get
13 log
= logging
.getLogger(__name__
)
15 def get_ip_and_ports(ctx
, daemon
):
16 assert daemon
.startswith('mon.')
17 addr
= ctx
.ceph
['ceph'].mons
['{a}'.format(a
=daemon
)]
18 ips
= re
.findall("[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[:[0-9]*]*", addr
)
20 plain_ip
= re
.match("[0-9\.]*", ips
[0]).group()
21 assert plain_ip
is not None
24 ip_str
, port_str
= re
.match("([0-9\.]*)([:[0-9]*]*)", ip
).groups()
25 assert ip_str
== plain_ip
27 port_list
.append(port_str
)
28 return (plain_ip
, port_list
)
30 def disconnect(ctx
, config
):
31 assert len(config
) == 2 # we can only disconnect pairs right now
32 # and we can only disconnect mons right now
33 assert config
[0].startswith('mon.')
34 assert config
[1].startswith('mon.')
35 (ip1
, _
) = get_ip_and_ports(ctx
, config
[0])
36 (ip2
, _
) = get_ip_and_ports(ctx
, config
[1])
38 (host1
,) = ctx
.cluster
.only(config
[0]).remotes
.iterkeys()
39 (host2
,) = ctx
.cluster
.only(config
[1]).remotes
.iterkeys()
40 assert host1
is not None
41 assert host2
is not None
44 args
= ["sudo", "iptables", "-A", "INPUT", "-p", "tcp", "-s",
48 args
= ["sudo", "iptables", "-A", "INPUT", "-p", "tcp", "-s",
52 def reconnect(ctx
, config
):
53 assert len(config
) == 2 # we can only disconnect pairs right now
54 # and we can only disconnect mons right now
55 assert config
[0].startswith('mon.')
56 assert config
[1].startswith('mon.')
58 (ip1
, _
) = get_ip_and_ports(ctx
, config
[0])
59 (ip2
, _
) = get_ip_and_ports(ctx
, config
[1])
61 (host1
,) = ctx
.cluster
.only(config
[0]).remotes
.iterkeys()
62 (host2
,) = ctx
.cluster
.only(config
[1]).remotes
.iterkeys()
63 assert host1
is not None
64 assert host2
is not None
67 args
= ["sudo", "iptables", "-D", "INPUT", "-p", "tcp", "-s",
71 args
= ["sudo", "iptables", "-D", "INPUT", "-p", "tcp", "-s",