From bf4277e053fd3916c39c80daa7d72f951fd5179a Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Jan 22 2015 13:23:29 +0000 Subject: import pcs-0.9.115-32.el7_0.1 --- diff --git a/.gitignore b/.gitignore index 07ba4c7..ae6f95b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -SOURCES/pcs-withgems-0.9.115.tar.gz SOURCES/HAM-logo.png +SOURCES/pcs-withgems-0.9.115.tar.gz diff --git a/.pcs.metadata b/.pcs.metadata index cae3232..2c535af 100644 --- a/.pcs.metadata +++ b/.pcs.metadata @@ -1,2 +1,2 @@ -d722cc45738b913dc4f74257596db8788ba089ed SOURCES/pcs-withgems-0.9.115.tar.gz 80dc7788a3468fb7dd362a4b8bedd9efb373de89 SOURCES/HAM-logo.png +d722cc45738b913dc4f74257596db8788ba089ed SOURCES/pcs-withgems-0.9.115.tar.gz diff --git a/SOURCES/bz1184223-clone-one-step-fix.patch b/SOURCES/bz1184223-clone-one-step-fix.patch new file mode 100644 index 0000000..1f77759 --- /dev/null +++ b/SOURCES/bz1184223-clone-one-step-fix.patch @@ -0,0 +1,261 @@ +--- pcs-0.9.115/pcs/resource.py.cloneonestepfix 2015-01-20 14:02:56.312974531 -0600 ++++ pcs-0.9.115/pcs/resource.py 2015-01-20 15:45:56.066239316 -0600 +@@ -379,26 +379,34 @@ def resource_create(ra_id, ra_type, ra_v + % (", ".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)) +- xml_resource_string = create_xml_string("primitive", primitive_values, instance_attributes + op_attributes + meta_attributes) +- args = ["cibadmin"] +- args = args + ["-o", "resources", "-C", "-X", xml_resource_string] +- output,retval = utils.run(args) +- if retval != 0: +- utils.err ("Unable to create resource/fence device\n" + output) ++ ++ resource_elem = create_xml_element("primitive", primitive_values, instance_attributes + op_attributes + meta_attributes) ++ ++ dom = utils.get_cib_dom() ++ dom.getElementsByTagName("resources")[0].appendChild(resource_elem) + + if "--clone" in utils.pcs_options or len(clone_opts) > 0: +- resource_clone_create([ra_id] + clone_opts) ++ dom = resource_clone_create_dom(dom, [ra_id] + clone_opts) + if "--group" in utils.pcs_options: + print "Warning: --group ignored when creating a clone" + if "--master" in utils.pcs_options: + print "Warning: --master ignored when creating a clone" + elif "--master" in utils.pcs_options: +- resource_master_create([ra_id+"-master",ra_id]+ master_meta_values) ++ dom = resource_master_create_dom(dom, [ra_id+"-master",ra_id]+ master_meta_values) + if "--group" in utils.pcs_options: + print "Warning: --group ignored when creating a master" + elif "--group" in utils.pcs_options: + groupname = utils.pcs_options["--group"] +- resource_group_add(groupname,[ra_id]) ++ dom = resource_group_add_dom(dom, groupname,[ra_id]) ++ ++ xml_resource_string = dom.documentElement.getElementsByTagName("resources")[0].toprettyxml() ++ args = ["cibadmin"] ++ args = args + ["-o", "resources", "-M", "-X", xml_resource_string] ++ output,retval = utils.run(args) ++ if retval != 0: ++ utils.err ("Unable to create resource/fence device\n" + output) ++ ++# utils.replace_cib_configuration(dom) + + def resource_move(argv,clear=False,ban=False): + other_options = [] +@@ -1087,6 +1095,57 @@ def resource_clone_create(argv, update = + if retval != 0: + utils.err("unable to create clone\n" + output) + ++def resource_clone_create_dom(cib_dom, argv, update = False): ++ name = argv.pop(0) ++ element = None ++ dom = cib_dom ++ re = dom.documentElement.getElementsByTagName("resources")[0] ++ for res in re.getElementsByTagName("primitive") + re.getElementsByTagName("group"): ++ if res.getAttribute("id") == name: ++ element = res ++ break ++ ++ if element == None: ++ utils.err("unable to find group or resource: %s" % name) ++ ++ if utils.is_resource_clone(name): ++ utils.err("%s is already a clone resource" % name) ++ ++ if utils.is_group_clone(name): ++ utils.err("cannot clone a group that has already been cloned") ++ ++ if utils.is_resource_masterslave(name): ++ utils.err("%s is already a master/slave resource" % name) ++ ++ # If element is currently in a group and it's the last member, we get rid of the group ++ if element.parentNode.tagName == "group" and element.parentNode.getElementsByTagName("primitive").length <= 1: ++ element.parentNode.parentNode.removeChild(element.parentNode) ++ ++ if update == True: ++ if element.parentNode.tagName != "clone": ++ utils.err("%s is not currently a clone" % name) ++ clone = element.parentNode ++ for ma in clone.getElementsByTagName("meta_attributes"): ++ clone.removeChild(ma) ++ else: ++ clone = dom.createElement("clone") ++ clone.setAttribute("id",name + "-clone") ++ clone.appendChild(element) ++ re.appendChild(clone) ++ ++ meta = dom.createElement("meta_attributes") ++ meta.setAttribute("id",name + "-clone-meta") ++ args = convert_args_to_tuples(argv) ++ for arg in args: ++ nvpair = dom.createElement("nvpair") ++ nvpair.setAttribute("id", name+"-"+arg[0]) ++ nvpair.setAttribute("name", arg[0]) ++ nvpair.setAttribute("value", arg[1]) ++ meta.appendChild(nvpair) ++ clone.appendChild(meta) ++ ++ return dom ++ + def resource_clone_master_remove(argv): + if len(argv) != 1: + usage.resource() +@@ -1218,6 +1277,90 @@ def resource_master_create(argv, update= + if not update: + constraint.constraint_resource_update(rg_id) + ++def resource_master_create_dom(dom, argv, update=False): ++ non_option_args_count = 0 ++ for arg in argv: ++ if arg.find("=") == -1: ++ non_option_args_count += 1 ++ ++ if (non_option_args_count < 1): ++ usage.resource() ++ sys.exit(1) ++ ++ if non_option_args_count == 1 and not update: ++ argv.insert(0,argv[0]+"-master") ++ ++ master_id = argv.pop(0) ++ ++ if (update): ++ master_found = False ++ for master in dom.getElementsByTagName("master"): ++ if master.getAttribute("id") == master_id: ++ master_element = master ++ master_found = True ++ break ++ if not master_found: ++ utils.err("Unable to find multi-state resource with id %s" % master_id) ++ else: ++ rg_id = argv.pop(0) ++ if utils.does_id_exist(dom, master_id): ++ utils.err("%s already exists in the cib" % master_id) ++ ++ if utils.is_resource_clone(rg_id): ++ utils.err("%s is already a clone resource" % rg_id) ++ ++ if utils.is_resource_masterslave(rg_id): ++ utils.err("%s is already a master/slave resource" % rg_id) ++ ++ resources = dom.getElementsByTagName("resources")[0] ++ rg_found = False ++ for resource in (resources.getElementsByTagName("primitive") + ++ resources.getElementsByTagName("group")): ++ if resource.getAttribute("id") == rg_id: ++ rg_found = True ++ break ++ if not rg_found: ++ utils.err("Unable to find resource or group with id %s" % rg_id) ++ # If the resource elements parent is a group, and it's the last ++ # element in the group, we remove the group ++ if resource.parentNode.tagName == "group" and resource.parentNode.getElementsByTagName("primitive").length <= 1: ++ resource.parentNode.parentNode.removeChild(resource.parentNode) ++ ++ master_element = dom.createElement("master") ++ master_element.setAttribute("id", master_id) ++ resource.parentNode.removeChild(resource) ++ master_element.appendChild(resource) ++ resources.appendChild(master_element) ++ ++ if len(argv) > 0: ++ meta = None ++ for child in master_element.childNodes: ++ if child.nodeType != xml.dom.Node.ELEMENT_NODE: ++ continue ++ if child.tagName == "meta_attributes": ++ meta = child ++ if meta == None: ++ meta = dom.createElement("meta_attributes") ++ meta.setAttribute("id", master_id + "-meta_attributes") ++ master_element.appendChild(meta) ++ ++ for arg in convert_args_to_tuples(argv): ++ for nvpair in meta.getElementsByTagName("nvpair"): ++ if nvpair.getAttribute("name") == arg[0]: ++ meta.removeChild(nvpair) ++ break ++ if arg[1] == "": ++ continue ++ nvpair = dom.createElement("nvpair") ++ nvpair.setAttribute("id", meta.getAttribute("id") + "-" + arg[0]) ++ nvpair.setAttribute("name", arg[0]) ++ nvpair.setAttribute("value", arg[1]) ++ meta.appendChild(nvpair) ++ if len(meta.getElementsByTagName("nvpair")) == 0: ++ master_element.removeChild(meta) ++ ++ return dom ++ + def resource_master_remove(argv): + if len(argv) < 1: + usage.resource() +@@ -1465,6 +1608,65 @@ def resource_group_add(group_name, resou + else: + utils.err("No resources to add.") + ++def resource_group_add_dom(dom, group_name, resource_ids): ++ top_element = dom.documentElement ++ resources_element = top_element.getElementsByTagName("resources")[0] ++ group_found = False ++ ++ if group_name == "": ++ utils.err("group name cannot be empty") ++ ++ for resource in top_element.getElementsByTagName("primitive"): ++ if resource.getAttribute("id") == group_name: ++ utils.err("Error: %s is already a resource" % group_name) ++ ++ for group in top_element.getElementsByTagName("group"): ++ if group.getAttribute("id") == group_name: ++ group_found = True ++ mygroup = group ++ ++ if group_found == False: ++ mygroup = dom.createElement("group") ++ mygroup.setAttribute("id", group_name) ++ resources_element.appendChild(mygroup) ++ ++ ++ resources_to_move = [] ++ for resource_id in resource_ids: ++ already_exists = False ++ for resource in mygroup.getElementsByTagName("primitive"): ++ # If resource already exists in group then we skip ++ if resource.getAttribute("id") == resource_id: ++ utils.err(resource_id + " already exists in " + group_name) ++ ++ resource_found = False ++ for resource in resources_element.getElementsByTagName("primitive"): ++ if resource.nodeType == xml.dom.minidom.Node.TEXT_NODE: ++ continue ++ if resource.getAttribute("id") == resource_id: ++ if resource.parentNode.tagName == "master": ++ utils.err("cannot group master/slave resources") ++ if resource.parentNode.tagName == "clone": ++ utils.err("cannot group clone resources") ++ resources_to_move.append(resource) ++ resource_found = True ++ break ++ ++ if resource_found == False: ++ utils.err("Unable to find resource: " + resource_id) ++ continue ++ ++ if resources_to_move: ++ for resource in resources_to_move: ++ oldParent = resource.parentNode ++ mygroup.appendChild(resource) ++ if oldParent.tagName == "group" and len(oldParent.getElementsByTagName("primitive")) == 0: ++ oldParent.parentNode.removeChild(oldParent) ++ ++ return dom ++ else: ++ utils.err("No resources to add.") ++ + def resource_group_list(argv): + group_xpath = "//group" + group_xml = utils.get_cib_xpath(group_xpath) diff --git a/SPECS/pcs.spec b/SPECS/pcs.spec index 6421cbf..d845417 100644 --- a/SPECS/pcs.spec +++ b/SPECS/pcs.spec @@ -1,6 +1,6 @@ Name: pcs Version: 0.9.115 -Release: 32%{?dist} +Release: 32%{?dist}.1 License: GPLv2 URL: http://github.com/feist/pcs Group: System Environment/Base @@ -11,6 +11,7 @@ Source0: http://people.redhat.com/cfeist/pcs/pcs-withgems-%{version}.tar.gz Source1: HAM-logo.png Patch1: rebase.patch Patch2: bz1078343-Add-support-for-setting-certain-corosync-totem-optio.patch +Patch3: bz1184223-clone-one-step-fix.patch BuildRequires: ruby >= 2.0.0 ruby-devel rubygems pam-devel git BuildRequires: systemd-units rubygem-bundler Requires(post): systemd @@ -68,6 +69,11 @@ chmod 755 $RPM_BUILD_ROOT/%{python_sitelib}/pcs/pcs.py %doc COPYING README %changelog +* Tue Jan 20 2015 Chris Feist - 0.9.115-32.el7_0.1 +- Do pcs resource create --clone/--master/--group in one step instead of + two to prevent race conditions +- Resolves: rhbz#1184223 + * Tue Mar 25 2014 Chris Feist - 0.9.115-32 - Add ability to set totem options with pcs during cluster setup