Removed code duplication on cluster state change

Also changed str to six.text_type for py3 compatibility

Change-Id: Ic4dc280cc2dc59ecdc1df77b9c0737d35bfa984c
Merge "Removed code duplication on cluster state change"