diff --git a/cts/haresources2cib.py.in b/cts/haresources2cib.py.in
index f072e6f87b..eb4f694e69 100755
--- a/cts/haresources2cib.py.in
+++ b/cts/haresources2cib.py.in
@@ -1,244 +1,259 @@
 #!@PYTHON@
 
 '''haresources2cib.py.in, convert the haresources file of heartbeat 1.x
    to cib.xml for heartbeat 2.x
 '''
 
 __copyright__='''
 Author: Huang Zhen <zhenhltc@cn.ibm.com>
 Copyright (C) 2005 International Business Machines
 '''
 
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 import sys,string
 import xml.dom.minidom
 
 using_ocf = 1
 using_mon = 1
 
 ocf_ra_setting = {
 	"apache" :{"params":["configfile"],"time":["120s","60s"]},
 	"IPaddr" :{"params":["ip","netmask","nic","broadcast"],"time":["5s","5s"]},
 	"IPaddr2":{"params":["ip","netmask","nic","broadcast"],"time":["5s","5s"]},
 	"db2"    :{"params":["instance"],"time":["120s","60s"]}
 	}
 
 def create_cib() :
 	doc = xml.dom.minidom.Document()
 	cib = doc.createElement("cib")
 	doc.appendChild(cib)
 
 	configuration = doc.createElement("configuration")
 	cib.appendChild(configuration)
 
 	crm_config = doc.createElement("crm_config")
 	configuration.appendChild(crm_config)
 
 	nvpair = doc.createElement("nvpair")
 	crm_config.appendChild(nvpair)
 	nvpair.setAttribute("id","transition_idle_timeout")
 	nvpair.setAttribute("name","transition_idle_timeout")
 	nvpair.setAttribute("value","120s")
 
 	nvpair = doc.createElement("nvpair")
 	crm_config.appendChild(nvpair)
 	nvpair.setAttribute("id","symmetric_cluster")
 	nvpair.setAttribute("name","symmetric_cluster")
 	nvpair.setAttribute("value","true")
 
 	nvpair = doc.createElement("nvpair")
 	crm_config.appendChild(nvpair)
 	nvpair.setAttribute("id","no_quorum_policy")
 	nvpair.setAttribute("name","no_quorum_policy")
 	nvpair.setAttribute("value","stop")
 
 	configuration.appendChild(doc.createElement("nodes"))
 	resources = doc.createElement("resources")
 	configuration.appendChild(resources)
 	constraints = doc.createElement("constraints")
 	configuration.appendChild(constraints)
 
 	status = doc.createElement("status")
 	cib.appendChild(status)
 
 	return doc, resources, constraints
 
 def cib_resource(doc,index, rsc):
 
 	id, type, params = None, None, None
-
-	if len(string.split(string.split(rsc,'/')[0],'.')) == 4 :
-		id = "IPaddr_"+str(index)
-		type = "IPaddr"
-		params = [rsc]
+	
+	#if no parameters in rsc, like "apache", "192.168.0.11"
+	if string.find(rsc, "::") == -1 :
+		#if there is a IP address in rsc, like "192.168.0.11"
+		if len(string.split(string.split(rsc,'/')[0],'.')) == 4 :
+			type = "IPaddr"
+			params = [rsc]
+		#no IP address, like "apache"
+		else :
+			type = rsc
+	#else there have "::" in rsc,
+	#like "IPaddr::192.168.0.11", "IPaddr2::192.168.0.11"
 	else :
-		fields = string.split(rsc,"::")
-		id = fields[0]+"_"+str(index)
-		type = fields[0]
-		params = fields[1:]
-
+		if string.find(rsc, "IPaddr") == 0 :
+			type = string.split(rsc, "::")[0]
+			params = [string.split(rsc, "::")[1]]
+		else :			
+			fields = string.split(rsc,"::")
+			type = fields[0]
+			params = fields[1:]
+		
+	id = type+"_"+str(index)
+	
 	resource = doc.createElement("primitive")
 	resource.setAttribute("id",id)
 	resource.setAttribute("type",type)
 	if using_ocf and type in ocf_ra_setting:
 		resource.setAttribute("class","ocf")
 	else :
 		resource.setAttribute("class","heartbeat")
 	resource.setAttribute("provider","heartbeat")
 
 	if using_mon :
 		operations = doc.createElement("operations")
 		resource.appendChild(operations)
 		mon_op = doc.createElement("op")
 		operations.appendChild(mon_op)
-		mon_op.setAttribute("id","1")
+		mon_op.setAttribute("id", id + "_mon")
 		mon_op.setAttribute("name","monitor")
 		interval = "120s"
 		timeout = "60s"
 		if using_ocf and type in ocf_ra_setting :
 			interval = ocf_ra_setting[type]["time"][0]
 			timeout = ocf_ra_setting[type]["time"][1]
 		mon_op.setAttribute("interval", interval)
 		mon_op.setAttribute("timeout", timeout)
 
-	if len(params) != 0:
+	if params != None and len(params) != 0:
 		instance_attributes = doc.createElement("instance_attributes")
 		resource.appendChild(instance_attributes)
 		attributes = doc.createElement("attributes")
 		instance_attributes.appendChild(attributes)
 		if using_ocf and type in ocf_ra_setting :
 			if type in ["IPaddr", "IPaddr2"] :
 				unsort = string.split(params[0], "/")
 				params = [None, None, None, None]
 				#ip
 				params[0] = unsort[0]
 				for param in unsort[1:] :
 					if len(string.split(param, ".")) == 4 :
 						#broadcast
 						params[3] = param
 						break
 					try :
 						int(param)
 						#netmask bits
 						params[1] = param
 					except ValueError:
 						#nic
 						params[2] = param
 			index = 0
 			for param in params:
 				if param == None :
 					index += 1
 					continue
 				nvpair = doc.createElement("nvpair")
 				name = ocf_ra_setting[type]["params"][index]
+				nvpair.setAttribute("id",id + "_attr_" + str(index))
 				nvpair.setAttribute("name",name)
 				nvpair.setAttribute("value",str(param))
 				attributes.appendChild(nvpair)
 				index += 1
 		else :
 			index = 1
 			for param in params :
 				nvpair = doc.createElement("nvpair")
+				nvpair.setAttribute("id",id + "_attr_" + str(index))
 				nvpair.setAttribute("name",str(index))
 				nvpair.setAttribute("value",str(param))
 				attributes.appendChild(nvpair)
 				index += 1
 	return id, resource
 
 def cib_rsc_location(doc, id, node):
 	rsc_location = doc.createElement("rsc_location")
 	rsc_location.setAttribute("id","rsc_location_"+id)
 	rsc_location.setAttribute("rsc",id)
 	rule = doc.createElement("rule")
 	rule.setAttribute("id","prefered_location_"+id)
 	rule.setAttribute("score","100")
 	rsc_location.appendChild(rule)
 	expression = doc.createElement("expression")
+	expression.setAttribute("id","prefered_location_"+id+"_expr")
 	expression.setAttribute("attribute","#uname")
 	expression.setAttribute("operation","eq")
 	expression.setAttribute("value", node)
 	rule.appendChild(expression)
 	return rsc_location
 
 def cib_resource_group(doc, id):
 	resource_group = doc.createElement("group")
 	resource_group.setAttribute("id",id)
 	return resource_group
 
 def add_resource(cib,index,node,rsc):
 	id,resource = cib_resource(cib[0],index,rsc)
 	cib[1].appendChild(resource)
 	rsc_location = cib_rsc_location(cib[0],id,node)
 	cib[2].appendChild(rsc_location)
 
 def add_resource_group(cib,index,node,rscs):
 	groupid = "group_"+str(index)
 	resource_group = cib_resource_group(cib[0],groupid)
 	cib[1].appendChild(resource_group)
 	for rsc in rscs :
 		rid,resource = cib_resource(cib[0],index,rsc)
 		resource_group.appendChild(resource)
 		index += 1
 	rsc_location = cib_rsc_location(cib[0],groupid,node)
 	cib[2].appendChild(rsc_location)
 
 if __name__=="__main__" :
 	cib = create_cib()
 	resource_file = None
 	resource_file = "/etc/ha.d/haresources"
 
 	# Process arguments...
 	
 	for arg in sys.argv[1:]:
 		if arg == "--nu-ocf" :
 			using_ocf = 0
 		elif arg == "--nu-monitor" :
 			using_mon = 0
 		elif arg[0] == "-" :
 			print "usage: " + sys.argv[0]  \
 			+  " [--nu-ocf]"\
 			+  " [--nu-monitor]"\
 			+  " [--help|-h]"\
 			+  " [resourcefile]"
 			sys.exit(1)
 		else:
 			resource_file = arg
 	
 	file = open(resource_file, "r")
 	pre_line = ""
 	id_index = 1
 	for line in file.readlines() :
 		line = string.strip(line)
 		if len (line) == 0 or line[0] == '#' :
 			continue
 		if line[-1] == '\\' :
 			pre_line += line[:-1] + " "
 			continue
 		else :
 			line = pre_line + line
 			pre_line = ""
 		fields = string.split(line)
 		if len(fields) == 2 :
 			add_resource(cib, id_index, fields[0], fields[1])
 			id_index += 1
 		elif len(fields) > 2 :
 			add_resource_group(cib, id_index, fields[0], fields[1:])
-			id_index += len(fields) 
+			id_index += len(fields)
 		else :
 			print "can not parse this line:"+line
 
 	print cib[0].toprettyxml()