Ejemplo n.º 1
0
def test_existing_node_resource_2():
    obj = cibconfig.mkset_obj()
    assert obj is not None

    from crmsh import clidisplay
    with clidisplay.nopretty():
        text = obj.repr()
    text += "\nprimitive ha-one Dummy"
    ok = obj.save(text)
    assert ok

    obj = cibconfig.mkset_obj()
    assert obj is not None
    with clidisplay.nopretty():
        text2 = obj.repr()

    assert sorted(text.split('\n')) == sorted(text2.split('\n'))
Ejemplo n.º 2
0
def test_existing_node_resource_2():
    obj = cibconfig.mkset_obj()
    assert obj is not None

    from crmsh import clidisplay
    with clidisplay.nopretty():
        text = obj.repr()
    text += "\nprimitive ha-one Dummy"
    ok = obj.save(text)
    assert ok

    obj = cibconfig.mkset_obj()
    assert obj is not None
    with clidisplay.nopretty():
        text2 = obj.repr()

    assert sorted(text.split('\n')) == sorted(text2.split('\n'))
Ejemplo n.º 3
0
def test_id_collision_breakage_3():
    from crmsh import clidisplay

    obj = cibconfig.mkset_obj()
    assert obj is not None
    with clidisplay.nopretty():
        original_cib = obj.repr()
    print(original_cib)

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save("""node node1
primitive node1 Dummy params fake=something
    """)
    assert ok

    print("** baseline")
    obj = cibconfig.mkset_obj()
    assert obj is not None
    with clidisplay.nopretty():
        print(obj.repr())

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save("""primitive node1 Dummy params fake=something-else
    """,
                  remove=False,
                  method='update')
    assert ok

    print("** end")

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save(original_cib, remove=True, method='replace')
    assert ok
    obj = cibconfig.mkset_obj()
    with clidisplay.nopretty():
        print("*** ORIGINAL")
        print(original_cib)
        print("*** NOW")
        print(obj.repr())
        assert original_cib == obj.repr()
Ejemplo n.º 4
0
def test_id_collision_breakage_3():
    from crmsh import clidisplay

    obj = cibconfig.mkset_obj()
    assert obj is not None
    with clidisplay.nopretty():
        original_cib = obj.repr()
    print original_cib

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save("""node node1
primitive node1 Dummy params fake=something
    """)
    assert ok

    print "** baseline"
    obj = cibconfig.mkset_obj()
    assert obj is not None
    with clidisplay.nopretty():
        print obj.repr()

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save("""primitive node1 Dummy params fake=something-else
    """, no_remove=True, method='update')
    assert ok

    print "** end"

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save(original_cib, no_remove=False, method='replace')
    assert ok
    obj = cibconfig.mkset_obj()
    with clidisplay.nopretty():
        print "*** ORIGINAL"
        print original_cib
        print "*** NOW"
        print obj.repr()
        assert original_cib == obj.repr()
Ejemplo n.º 5
0
def test_reordering_resource_sets():
    """
    Can we reorder resource sets?
    """
    from crmsh import clidisplay
    obj1 = factory.create_object('primitive', 'p1', 'Dummy')
    assert obj1 is True
    obj2 = factory.create_object('primitive', 'p2', 'Dummy')
    assert obj2 is True
    obj3 = factory.create_object('primitive', 'p3', 'Dummy')
    assert obj3 is True
    obj4 = factory.create_object('primitive', 'p4', 'Dummy')
    assert obj4 is True
    o1 = factory.create_object('order', 'o1', 'p1', 'p2', 'p3', 'p4')
    assert o1 is True

    obj = cibconfig.mkset_obj('o1')
    assert obj is not None
    rc = obj.save('order o1 p4 p3 p2 p1')
    assert rc == True

    obj2 = cibconfig.mkset_obj('o1')
    with clidisplay.nopretty():
        assert "order o1 p4 p3 p2 p1" == obj2.repr().strip()
Ejemplo n.º 6
0
def test_reordering_resource_sets():
    """
    Can we reorder resource sets?
    """
    from crmsh import clidisplay
    obj1 = factory.create_object('primitive', 'p1', 'Dummy')
    assert obj1 is True
    obj2 = factory.create_object('primitive', 'p2', 'Dummy')
    assert obj2 is True
    obj3 = factory.create_object('primitive', 'p3', 'Dummy')
    assert obj3 is True
    obj4 = factory.create_object('primitive', 'p4', 'Dummy')
    assert obj4 is True
    o1 = factory.create_object('order', 'o1', 'p1', 'p2', 'p3', 'p4')
    assert o1 is True

    obj = cibconfig.mkset_obj('o1')
    assert obj is not None
    rc = obj.save('order o1 p4 p3 p2 p1')
    assert rc == True

    obj2 = cibconfig.mkset_obj('o1')
    with clidisplay.nopretty():
        assert "order o1 p4 p3 p2 p1" == obj2.repr().strip()
Ejemplo n.º 7
0
def test_id_collision_breakage_2():
    from crmsh import clidisplay

    obj = cibconfig.mkset_obj()
    assert obj is not None
    with clidisplay.nopretty():
        original_cib = obj.repr()
    print original_cib

    obj = cibconfig.mkset_obj()
    assert obj is not None

    ok = obj.save("""node 168633610: webui
node 168633611: node1
rsc_template web-server apache \
	params port=8000 \
	op monitor interval=10s
primitive d0 Dummy \
	meta target-role=Started
primitive d1 Dummy
primitive d2 Dummy
# Never use this STONITH agent in production!
primitive development-stonith stonith:null \
	params hostlist="webui node1 node2 node3"
primitive proxy systemd:haproxy \
	op monitor interval=10s
primitive proxy-vip IPaddr2 \
	params ip=10.13.37.20
primitive srv1 @web-server
primitive srv2 @web-server
primitive vip1 IPaddr2 \
	params ip=10.13.37.21 \
	op monitor interval=20s
primitive vip2 IPaddr2 \
	params ip=10.13.37.22 \
	op monitor interval=20s
primitive virtual-ip IPaddr2 \
	params ip=10.13.37.77 lvs_support=false \
	op start timeout=20 interval=0 \
	op stop timeout=20 interval=0 \
	op monitor interval=10 timeout=20
primitive yet-another-virtual-ip IPaddr2 \
	params ip=10.13.37.72 cidr_netmask=24 \
	op start interval=0 timeout=20 \
	op stop interval=0 timeout=20 \
	op monitor interval=10 timeout=20 \
	meta target-role=Started
group dovip d0 virtual-ip \
	meta target-role=Stopped
group g-proxy proxy-vip proxy
group g-serv1 vip1 srv1
group g-serv2 vip2 srv2
clone d2-clone d2 \
	meta target-role=Started
tag dummytag d0 d1 d1-on-node1 d2 d2-clone
# Never put the two web servers on the same node
colocation co-serv -inf: g-serv1 g-serv2
location d1-on-node1 d1 inf: node1
# Never put any web server or haproxy on webui
location l-avoid-webui { g-proxy g-serv1 g-serv2 } -inf: webui
# Prever to spread groups across nodes
location l-proxy g-proxy 200: node1
location l-serv1 g-serv1 200: node2
location l-serv2 g-serv2 200: node3
property cib-bootstrap-options: \
	have-watchdog=false \
	dc-version="1.1.13+git20150917.20c2178-224.2-1.1.13+git20150917.20c2178" \
	cluster-infrastructure=corosync \
	cluster-name=hacluster \
	stonith-enabled=true \
	no-quorum-policy=ignore \
	placement-strategy=balanced
rsc_defaults rsc-options: \
	resource-stickiness=1 \
	migration-threshold=3
op_defaults op-options: \
	timeout=600 \
	record-pending=true
""")
    assert ok

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save(original_cib)
    assert ok
    obj = cibconfig.mkset_obj()
    with clidisplay.nopretty():
        print "*** ORIGINAL"
        print original_cib
        print "*** NOW"
        print obj.repr()
        assert original_cib == obj.repr()
Ejemplo n.º 8
0
def test_id_collision_breakage_1():
    from crmsh import clidisplay

    obj = cibconfig.mkset_obj()
    assert obj is not None
    with clidisplay.nopretty():
        original_cib = obj.repr()
    print original_cib

    obj = cibconfig.mkset_obj()
    assert obj is not None

    ok = obj.save("""node node1
primitive p0 ocf:pacemaker:Dummy
primitive p1 ocf:pacemaker:Dummy
primitive p2 ocf:heartbeat:Delay \
    params startdelay=2 mondelay=2 stopdelay=2
primitive p3 ocf:pacemaker:Dummy
primitive st stonith:null params hostlist=node1
clone c1 p1
ms m1 p2
property default-action-timeout=60s
""")
    assert ok

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save("""property default-action-timeout=2m
node node1 \
    attributes mem=16G
primitive st stonith:null \
    params hostlist='node1' \
    meta description="some description here" \
    op start requires=nothing \
    op monitor interval=60m
primitive p1 ocf:heartbeat:Dummy \
    op monitor interval=60m \
    op monitor interval=120m OCF_CHECK_LEVEL=10
""")
    assert ok

    obj = cibconfig.mkset_obj()
    with clidisplay.nopretty():
        text = obj.repr()
    text = text + "\nprimitive p2 ocf:heartbeat:Dummy"
    ok = obj.save(text)
    assert ok

    obj = cibconfig.mkset_obj()
    with clidisplay.nopretty():
        text = obj.repr()
    text = text + "\ngroup g1 p1 p2"
    ok = obj.save(text)
    assert ok

    obj = cibconfig.mkset_obj("g1")
    with clidisplay.nopretty():
        text = obj.repr()
    text = text.replace("group g1 p1 p2", "group g1 p1 p3")
    text = text + "\nprimitive p3 ocf:heartbeat:Dummy"
    ok = obj.save(text)
    assert ok

    obj = cibconfig.mkset_obj("g1")
    with clidisplay.nopretty():
        print obj.repr().strip()
        assert obj.repr().strip() == "group g1 p1 p3"

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save(original_cib)
    assert ok
    obj = cibconfig.mkset_obj()
    with clidisplay.nopretty():
        print "*** ORIGINAL"
        print original_cib
        print "*** NOW"
        print obj.repr()
        assert original_cib == obj.repr()
Ejemplo n.º 9
0
def test_id_collision_breakage_2():
    from crmsh import clidisplay

    obj = cibconfig.mkset_obj()
    assert obj is not None
    with clidisplay.nopretty():
        original_cib = obj.repr()
    print(original_cib)

    obj = cibconfig.mkset_obj()
    assert obj is not None

    ok = obj.save("""node 168633610: webui
node 168633611: node1
rsc_template web-server apache \
	params port=8000 \
	op monitor interval=10s
primitive d0 Dummy \
	meta target-role=Started
primitive d1 Dummy
primitive d2 Dummy
# Never use this STONITH agent in production!
primitive development-stonith stonith:null \
	params hostlist="webui node1 node2 node3"
primitive proxy systemd:haproxy \
	op monitor interval=10s
primitive proxy-vip IPaddr2 \
	params ip=10.13.37.20
primitive srv1 @web-server
primitive srv2 @web-server
primitive vip1 IPaddr2 \
	params ip=10.13.37.21 \
	op monitor interval=20s
primitive vip2 IPaddr2 \
	params ip=10.13.37.22 \
	op monitor interval=20s
primitive virtual-ip IPaddr2 \
	params ip=10.13.37.77 lvs_support=false \
	op start timeout=20 interval=0 \
	op stop timeout=20 interval=0 \
	op monitor interval=10 timeout=20
primitive yet-another-virtual-ip IPaddr2 \
	params ip=10.13.37.72 cidr_netmask=24 \
	op start interval=0 timeout=20 \
	op stop interval=0 timeout=20 \
	op monitor interval=10 timeout=20 \
	meta target-role=Started
group dovip d0 virtual-ip \
	meta target-role=Stopped
group g-proxy proxy-vip proxy
group g-serv1 vip1 srv1
group g-serv2 vip2 srv2
clone d2-clone d2 \
	meta target-role=Started
tag dummytag d0 d1 d1-on-node1 d2 d2-clone
# Never put the two web servers on the same node
colocation co-serv -inf: g-serv1 g-serv2
location d1-on-node1 d1 inf: node1
# Never put any web server or haproxy on webui
location l-avoid-webui { g-proxy g-serv1 g-serv2 } -inf: webui
# Prever to spread groups across nodes
location l-proxy g-proxy 200: node1
location l-serv1 g-serv1 200: node2
location l-serv2 g-serv2 200: node3
property cib-bootstrap-options: \
	have-watchdog=false \
	dc-version="1.1.13+git20150917.20c2178-224.2-1.1.13+git20150917.20c2178" \
	cluster-infrastructure=corosync \
	cluster-name=hacluster \
	stonith-enabled=true \
	no-quorum-policy=ignore
rsc_defaults rsc-options: \
	resource-stickiness=1 \
	migration-threshold=3
op_defaults op-options: \
	timeout=600 \
	record-pending=true
""")
    assert ok

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save(original_cib)
    assert ok
    obj = cibconfig.mkset_obj()
    with clidisplay.nopretty():
        print("*** ORIGINAL")
        print(original_cib)
        print("*** NOW")
        print(obj.repr())
        assert original_cib == obj.repr()
Ejemplo n.º 10
0
def test_id_collision_breakage_1():
    from crmsh import clidisplay

    obj = cibconfig.mkset_obj()
    assert obj is not None
    with clidisplay.nopretty():
        original_cib = obj.repr()
    print(original_cib)

    obj = cibconfig.mkset_obj()
    assert obj is not None

    ok = obj.save("""node node1
primitive p0 ocf:pacemaker:Dummy
primitive p1 ocf:pacemaker:Dummy
primitive p2 ocf:heartbeat:Delay \
    params startdelay=2 mondelay=2 stopdelay=2
primitive p3 ocf:pacemaker:Dummy
primitive st stonith:null params hostlist=node1
clone c1 p1
ms m1 p2
op_defaults timeout=60s
""")
    assert ok

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save("""op_defaults timeout=2m
node node1 \
    attributes mem=16G
primitive st stonith:null \
    params hostlist='node1' \
    meta description="some description here" requires=nothing \
    op monitor interval=60m
primitive p1 ocf:heartbeat:Dummy \
    op monitor interval=60m \
    op monitor interval=120m OCF_CHECK_LEVEL=10
""")
    assert ok

    obj = cibconfig.mkset_obj()
    with clidisplay.nopretty():
        text = obj.repr()
    text = text + "\nprimitive p2 ocf:heartbeat:Dummy"
    ok = obj.save(text)
    assert ok

    obj = cibconfig.mkset_obj()
    with clidisplay.nopretty():
        text = obj.repr()
    text = text + "\ngroup g1 p1 p2"
    ok = obj.save(text)
    assert ok

    obj = cibconfig.mkset_obj("g1")
    with clidisplay.nopretty():
        text = obj.repr()
    text = text.replace("group g1 p1 p2", "group g1 p1 p3")
    text = text + "\nprimitive p3 ocf:heartbeat:Dummy"
    ok = obj.save(text)
    assert ok

    obj = cibconfig.mkset_obj("g1")
    with clidisplay.nopretty():
        print(obj.repr().strip())
        assert obj.repr().strip() == "group g1 p1 p3"

    obj = cibconfig.mkset_obj()
    assert obj is not None
    ok = obj.save(original_cib)
    assert ok
    obj = cibconfig.mkset_obj()
    with clidisplay.nopretty():
        print("*** ORIGINAL")
        print(original_cib)
        print("*** NOW")
        print(obj.repr())
        assert original_cib == obj.repr()