Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 939229 Details for
Bug 1081242
pcs should abort if required parameter is not present while creating a resource
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
proposed fix
0001-Require-force-when-creating-resource-without-mandato.patch (text/plain), 17.42 KB, created by
Tomas Jelinek
on 2014-09-19 11:17:45 UTC
(
hide
)
Description:
proposed fix
Filename:
MIME Type:
Creator:
Tomas Jelinek
Created:
2014-09-19 11:17:45 UTC
Size:
17.42 KB
patch
obsolete
>From b6c2e3864245630e32fb6cc6b4bada3d0a9b2b27 Mon Sep 17 00:00:00 2001 >From: Tomas Jelinek <tojeline@redhat.com> >Date: Fri, 19 Sep 2014 11:26:58 +0200 >Subject: [PATCH] Require --force when creating resource without mandatory > params > >--- > pcs/resource.py | 6 +- > pcs/test/test_resource.py | 16 +++-- > pcs/test/test_stonith.py | 145 ++++++++++++++++++++++++++++++---------------- > pcs/utils.py | 14 ++++- > 4 files changed, 125 insertions(+), 56 deletions(-) > >diff --git a/pcs/resource.py b/pcs/resource.py >index 90d7fe0..a710b40 100644 >--- a/pcs/resource.py >+++ b/pcs/resource.py >@@ -400,7 +400,11 @@ def resource_create(ra_id, ra_type, ra_values, op_values, meta_values=[], clone_ > utils.err ("resource option(s): '%s', are not recognized for resource type: '%s' (use --force to override)" \ > % (", ".join(bad_opts), get_full_ra_type(ra_type, True))) > if len(missing_req_opts) != 0: >- print "Warning: missing required option(s): '%s' for resource type: %s" % (", ".join(missing_req_opts),get_full_ra_type(ra_type,True)) >+ utils.err( >+ "missing required option(s): '%s' for resource type: %s" >+ " (use --force to override)" >+ % (", ".join(missing_req_opts), get_full_ra_type(ra_type, True)) >+ ) > > resource_elem = create_xml_element("primitive", primitive_values, instance_attributes + op_attributes + meta_attributes) > dom.getElementsByTagName("resources")[0].appendChild(resource_elem) >diff --git a/pcs/test/test_resource.py b/pcs/test/test_resource.py >index 0377e23..31a6e8a 100644 >--- a/pcs/test/test_resource.py >+++ b/pcs/test/test_resource.py >@@ -2007,7 +2007,11 @@ Deleting Resource (and group and M/S) - A2 > > def testResourceMissingValues(self): > o,r = pcs("resource create --no-default-ops myip IPaddr2") >- ac(o,"Warning: missing required option(s): 'ip' for resource type: ocf:heartbeat:IPaddr2\n") >+ ac(o,"Error: missing required option(s): 'ip' for resource type: ocf:heartbeat:IPaddr2 (use --force to override)\n") >+ assert r == 1 >+ >+ o,r = pcs("resource create --no-default-ops myip IPaddr2 --force") >+ ac(o,"") > assert r == 0 > > o,r = pcs("resource create --no-default-ops myip2 IPaddr2 ip=3.3.3.3") >@@ -2015,11 +2019,15 @@ Deleting Resource (and group and M/S) - A2 > assert r == 0 > > o,r = pcs("resource create --no-default-ops myfs Filesystem") >- ac(o,"Warning: missing required option(s): 'device, directory, fstype' for resource type: ocf:heartbeat:Filesystem\n") >+ ac(o,"Error: missing required option(s): 'device, directory, fstype' for resource type: ocf:heartbeat:Filesystem (use --force to override)\n") >+ assert r == 1 >+ >+ o,r = pcs("resource create --no-default-ops myfs Filesystem --force") >+ ac(o,"") > assert r == 0 > >- o,r = pcs("resource create --no-default-ops myfs2 Filesystem device=x directory=y") >- ac(o,"Warning: missing required option(s): 'fstype' for resource type: ocf:heartbeat:Filesystem\n") >+ o,r = pcs("resource create --no-default-ops myfs2 Filesystem device=x directory=y --force") >+ ac(o,"") > assert r == 0 > > o,r = pcs("resource create --no-default-ops myfs3 Filesystem device=x directory=y fstype=z") >diff --git a/pcs/test/test_stonith.py b/pcs/test/test_stonith.py >index cfeb7d0..7a73381 100644 >--- a/pcs/test/test_stonith.py >+++ b/pcs/test/test_stonith.py >@@ -23,16 +23,24 @@ class StonithTest(unittest.TestCase): > assert output == "" > > output, returnVal = pcs(temp_cib, "stonith create test2 fence_ilo") >+ assert returnVal == 1 >+ ac(output,"Error: missing required option(s): 'ipaddr, login, action' for resource type: stonith:fence_ilo (use --force to override)\n") >+ >+ output, returnVal = pcs(temp_cib, "stonith create test2 fence_ilo --force") > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'ipaddr, login, action' for resource type: stonith:fence_ilo\n") >+ ac(output,"") > > output, returnVal = pcs(temp_cib, "stonith create test3 fence_ilo bad_argument=test") > assert returnVal == 1 > assert output == "Error: resource option(s): 'bad_argument', are not recognized for resource type: 'stonith:fence_ilo' (use --force to override)\n",[output] > > output, returnVal = pcs(temp_cib, "stonith create test9 fence_ilo pcmk_status_action=xxx") >+ assert returnVal == 1 >+ ac(output,"Error: missing required option(s): 'ipaddr, login, action' for resource type: stonith:fence_ilo (use --force to override)\n") >+ >+ output, returnVal = pcs(temp_cib, "stonith create test9 fence_ilo pcmk_status_action=xxx --force") > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'ipaddr, login, action' for resource type: stonith:fence_ilo\n") >+ ac(output,"") > > output, returnVal = pcs(temp_cib, "stonith show test9") > assert returnVal == 0 >@@ -43,14 +51,18 @@ class StonithTest(unittest.TestCase): > assert output == "Deleting Resource - test9\n",[output] > > output, returnVal = pcs(temp_cib, "stonith create test3 fence_ilo ipaddr=test") >+ assert returnVal == 1 >+ ac(output,"Error: missing required option(s): 'login, action' for resource type: stonith:fence_ilo (use --force to override)\n") >+ >+ output, returnVal = pcs(temp_cib, "stonith create test3 fence_ilo ipaddr=test --force") > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'login, action' for resource type: stonith:fence_ilo\n") >+ ac(output,"") > > # Testing that pcmk_host_check, pcmk_host_list & pcmk_host_map are allowed for > # stonith agents > output, returnVal = pcs(temp_cib, 'stonith create apc-fencing fence_apc params ipaddr="morph-apc" login="apc" passwd="apc" switch="1" pcmk_host_map="buzz-01:1;buzz-02:2;buzz-03:3;buzz-04:4;buzz-05:5" action="reboot" debug="1" pcmk_host_check="static-list" pcmk_host_list="buzz-01,buzz-02,buzz-03,buzz-04,buzz-05"') > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'port' for resource type: stonith:fence_apc\n") >+ ac(output,"") > > output, returnVal = pcs(temp_cib, 'resource show apc-fencing') > assert returnVal == 1 >@@ -80,9 +92,9 @@ class StonithTest(unittest.TestCase): > assert returnVal == 0 > assert output == " Resource: test1 (class=stonith type=fence_noxist)\n Operations: monitor interval=60s (test1-monitor-interval-60s)\n Resource: test2 (class=stonith type=fence_ilo)\n Operations: monitor interval=60s (test2-monitor-interval-60s)\n Resource: test3 (class=stonith type=fence_ilo)\n Attributes: ipaddr=test login=testA \n Operations: monitor interval=60s (test3-monitor-interval-60s)\n",[output] > >- output, returnVal = pcs(temp_cib, 'stonith create test-fencing fence_apc pcmk_host_list="rhel7-node1 rhel7-node2" op monitor interval=61s') >+ output, returnVal = pcs(temp_cib, 'stonith create test-fencing fence_apc pcmk_host_list="rhel7-node1 rhel7-node2" op monitor interval=61s --force') > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc\n") >+ ac(output,"") > > output, returnVal = pcs(temp_cib, 'config show') > assert returnVal == 0 >@@ -98,14 +110,47 @@ class StonithTest(unittest.TestCase): > assert output == "Error: must specify one (and only one) node to confirm fenced\n" > > def testPcmkHostList(self): >- output, returnVal = pcs(temp_cib, "stonith create F1 fence_apc 'pcmk_host_list=nodea nodeb'") >+ output, returnVal = pcs(temp_cib, "stonith create F1 fence_apc 'pcmk_host_list=nodea nodeb' --force") > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc\n") >+ ac(output,"") > > output, returnVal = pcs(temp_cib, "stonith show F1") > assert returnVal == 0 > assert output == ' Resource: F1 (class=stonith type=fence_apc)\n Attributes: pcmk_host_list="nodea nodeb" \n Operations: monitor interval=60s (F1-monitor-interval-60s)\n',[output] > >+ def testPcmkHostAllowsMissingPort(self): >+ # Test that port is not required when pcmk_host_argument or >+ # pcmk_host_list or pcmk_host_map is specified >+ output, returnVal = pcs( >+ temp_cib, >+ 'stonith create apc-1 fence_apc params ipaddr="ip" login="apc" action="reboot"' >+ ) >+ ac(output, """\ >+Error: missing required option(s): 'port' for resource type: stonith:fence_apc (use --force to override) >+""") >+ self.assertEquals(returnVal, 1) >+ >+ output, returnVal = pcs( >+ temp_cib, >+ 'stonith create apc-2 fence_apc params ipaddr="ip" login="apc" action="reboot" pcmk_host_map="buzz-01:1;buzz-02:2"' >+ ) >+ ac(output, "") >+ self.assertEquals(returnVal, 0) >+ >+ output, returnVal = pcs( >+ temp_cib, >+ 'stonith create apc-3 fence_apc params ipaddr="ip" login="apc" action="reboot" pcmk_host_list="buzz-01,buzz-02"' >+ ) >+ ac(output, "") >+ self.assertEquals(returnVal, 0) >+ >+ output, returnVal = pcs( >+ temp_cib, >+ 'stonith create apc-4 fence_apc params ipaddr="ip" login="apc" action="reboot" pcmk_host_argument="buzz-01"' >+ ) >+ ac(output, "") >+ self.assertEquals(returnVal, 0) >+ > def testFenceLevels(self): > output, returnVal = pcs(temp_cib, "stonith level remove 1 rh7-2 F1") > assert returnVal == 1 >@@ -115,25 +160,25 @@ class StonithTest(unittest.TestCase): > assert returnVal == 0 > assert output == "" > >- output, returnVal = pcs(temp_cib, "stonith create F1 fence_apc 'pcmk_host_list=nodea nodeb'") >+ output, returnVal = pcs(temp_cib, "stonith create F1 fence_apc 'pcmk_host_list=nodea nodeb' ipaddr=ip login=lgn action=reboot") > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc\n") >+ ac(output,"") > >- output, returnVal = pcs(temp_cib, "stonith create F2 fence_apc 'pcmk_host_list=nodea nodeb'") >+ output, returnVal = pcs(temp_cib, "stonith create F2 fence_apc 'pcmk_host_list=nodea nodeb' ipaddr=ip login=lgn action=reboot") > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc\n") >+ ac(output,"") > >- output, returnVal = pcs(temp_cib, "stonith create F3 fence_apc 'pcmk_host_list=nodea nodeb'") >+ output, returnVal = pcs(temp_cib, "stonith create F3 fence_apc 'pcmk_host_list=nodea nodeb' ipaddr=ip login=lgn action=reboot") > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc\n") >+ ac(output,"") > >- output, returnVal = pcs(temp_cib, "stonith create F4 fence_apc 'pcmk_host_list=nodea nodeb'") >+ output, returnVal = pcs(temp_cib, "stonith create F4 fence_apc 'pcmk_host_list=nodea nodeb' ipaddr=ip login=lgn action=reboot") > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc\n") >+ ac(output,"") > >- output, returnVal = pcs(temp_cib, "stonith create F5 fence_apc 'pcmk_host_list=nodea nodeb'") >+ output, returnVal = pcs(temp_cib, "stonith create F5 fence_apc 'pcmk_host_list=nodea nodeb' ipaddr=ip login=lgn action=reboot") > assert returnVal == 0 >- ac(output,"Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc\n") >+ ac(output,"") > > output, returnVal = pcs(temp_cib, "stonith level add 1 rh7-1 F3,F4") > assert returnVal == 0 >@@ -352,47 +397,47 @@ class StonithTest(unittest.TestCase): > ac(o,"Error: FBad is not a stonith id\n") > > def testStonithDeleteRemovesLevel(self): >- output, returnVal = pcs(temp_cib, "stonith create n1-ipmi fence_ilo") >+ output, returnVal = pcs( >+ temp_cib, "stonith create n1-ipmi fence_ilo --force" >+ ) > self.assertEquals(returnVal, 0) >- ac(output, """\ >-Warning: missing required option(s): 'ipaddr, login, action' for resource type: stonith:fence_ilo >-""") >+ ac(output, "") > >- output, returnVal = pcs(temp_cib, "stonith create n2-ipmi fence_ilo") >+ output, returnVal = pcs( >+ temp_cib, "stonith create n2-ipmi fence_ilo --force" >+ ) > self.assertEquals(returnVal, 0) >- ac(output, """\ >-Warning: missing required option(s): 'ipaddr, login, action' for resource type: stonith:fence_ilo >-""") >+ ac(output, "") > >- output, returnVal = pcs(temp_cib, "stonith create n1-apc1 fence_apc") >+ output, returnVal = pcs( >+ temp_cib, "stonith create n1-apc1 fence_apc --force" >+ ) > self.assertEquals(returnVal, 0) >- ac(output, """\ >-Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc >-""") >+ ac(output, "") > >- output, returnVal = pcs(temp_cib, "stonith create n1-apc2 fence_apc") >+ output, returnVal = pcs( >+ temp_cib, "stonith create n1-apc2 fence_apc --force" >+ ) > self.assertEquals(returnVal, 0) >- ac(output, """\ >-Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc >-""") >+ ac(output, "") > >- output, returnVal = pcs(temp_cib, "stonith create n2-apc1 fence_apc") >+ output, returnVal = pcs( >+ temp_cib, "stonith create n2-apc1 fence_apc --force" >+ ) > self.assertEquals(returnVal, 0) >- ac(output, """\ >-Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc >-""") >+ ac(output, "") > >- output, returnVal = pcs(temp_cib, "stonith create n2-apc2 fence_apc") >+ output, returnVal = pcs( >+ temp_cib, "stonith create n2-apc2 fence_apc --force" >+ ) > self.assertEquals(returnVal, 0) >- ac(output, """\ >-Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc >-""") >+ ac(output, "") > >- output, returnVal = pcs(temp_cib, "stonith create n2-apc3 fence_apc") >+ output, returnVal = pcs( >+ temp_cib, "stonith create n2-apc3 fence_apc --force" >+ ) > self.assertEquals(returnVal, 0) >- ac(output, """\ >-Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc >-""") >+ ac(output, "") > > output, returnVal = pcs(temp_cib, "stonith level add 1 rh7-1 n1-ipmi") > self.assertEquals(returnVal, 0) >@@ -496,8 +541,8 @@ Warning: missing required option(s): 'ipaddr, login, port, action' for resource > assert "WARNING: no stonith devices and " in o > assert r == 0 > >- o,r = pcs("stonith create test_stonith fence_apc") >- ac(o,"Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc\n") >+ o,r = pcs("stonith create test_stonith fence_apc ipaddr=ip login=lgn, action=reboot, pcmk_host_argument=node1") >+ ac(o,"") > assert r == 0 > > o,r = pcs("status") >@@ -508,8 +553,8 @@ Warning: missing required option(s): 'ipaddr, login, port, action' for resource > ac(o,"Deleting Resource - test_stonith\n") > assert r == 0 > >- o,r = pcs("stonith create test_stonith fence_apc --clone") >- ac(o,"Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc\n") >+ o,r = pcs("stonith create test_stonith fence_apc ipaddr=ip login=lgn, action=reboot, pcmk_host_argument=node1 --clone") >+ ac(o,"") > assert r == 0 > > o,r = pcs("status") >diff --git a/pcs/utils.py b/pcs/utils.py >index 3b14abe..e46b0e5 100644 >--- a/pcs/utils.py >+++ b/pcs/utils.py >@@ -1366,6 +1366,7 @@ def getResourceType(resource): > # ra_values is an array of 2 item tuples (key, value) > # resource is a python minidom element of the resource from the cib > def validInstanceAttributes(res_id, ra_values, resource_type): >+ ra_values = dict(ra_values) > found = False > resSplit = resource_type.split(":") > if len(resSplit) == 2: >@@ -1397,12 +1398,23 @@ def validInstanceAttributes(res_id, ra_values, resource_type): > err("Unable to parse xml for '%s': %s" % (resource_type, e)) > except xml.etree.ElementTree.ParseError as e: > err("Unable to parse xml for '%s': %s" % (resource_type, e)) >- for key,value in ra_values: >+ for key,value in ra_values.items(): > if key not in valid_parameters: > bad_parameters.append(key) > if key in missing_required_parameters: > missing_required_parameters.remove(key) > >+ if missing_required_parameters: >+ if resClass == "stonith" and "port" in missing_required_parameters: >+ if ( >+ "pcmk_host_argument" in ra_values >+ or >+ "pcmk_host_map" in ra_values >+ or >+ "pcmk_host_list" in ra_values >+ ): >+ missing_required_parameters.remove("port") >+ > return bad_parameters, missing_required_parameters > > def generate_rrp_corosync_config(interface): >-- >1.9.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1081242
: 939229