Check the instance ID before creating it
Check the instance ID before creating it

At least with libvirt 1.x instance goes into shutdown state
before its ID is changed. This means that there's a race
condition during reboot where nova might try to create an
instance that's already defined. By checking if the ID of
the new and old instance is the same, we avoid that situation
and reiterate on the loop.

The tests for this are added in
I6215f80bd15820dac80151e7063916dbbc21d761

Change-Id: I493b828f0c6848fbadc591be2f47fd1b12fd3a51
Fixes: bug 1181924

bclau/nova,CloudServer/nova,cyx1231st/nova,yatinkumbhare/openstack-nova,Tehsmash/nova,OpenAcademy-OpenStack/nova-scheduler,vmturbo/nova,ted-gould/nova,scripnichenko/nova,phenoxim/nova,hanlind/nova,hanlind/nova,mgagne/nova,CloudServer/nova,spring-week-topos/nova-week,cloudbase/nova-virtualbox,angdraug/nova,klmitch/nova,bgxavier/nova,phenoxim/nova,dims/nova,ruslanloman/nova,LoHChina/nova,tudorvio/nova,badock/nova,luogangyi/bcec-nova,devoid/nova,spring-week-topos/nova-week,hanlind/nova,Yuriy-Leonov/nova,cloudbau/nova,felixma/nova,mikalstill/nova,edulramirez/nova,rajalokan/nova,berrange/nova,j-carpentier/nova,bgxavier/nova,LoHChina/nova,vladikr/nova_drafts,maelnor/nova,mikalstill/nova,tealover/nova,petrutlucian94/nova,cloudbase/nova,JioCloud/nova,orbitfp7/nova,cyx1231st/nova,rahulunair/nova,Francis-Liu/animated-broccoli,CCI-MOC/nova,ruslanloman/nova,rajalokan/nova,raildo/nova,scripnichenko/nova,shootstar/novatest,barnsnake351/nova,TieWei/nova,virtualopensystems/nova,virtualopensystems/nova,JianyuWang/nova,TwinkleChawla/nova,gooddata/openstack-nova,Juniper/nova,klmitch/nova,yatinkumbhare/openstack-nova,vmturbo/nova,CEG-FYP-OpenStack/scheduler,petrutlucian94/nova_dev,zaina/nova,kimjaejoong/nova,varunarya10/nova_test_latest,leilihh/novaha,zzicewind/nova,viggates/nova,MountainWei/nova,JianyuWang/nova,rrader/nova-docker-plugin,CiscoSystems/nova,badock/nova,varunarya10/nova_test_latest,blueboxgroup/nova,SUSE-Cloud/nova,zaina/nova,projectcalico/calico-nova,Juniper/nova,TwinkleChawla/nova,nikesh-mahalka/nova,citrix-openstack-build/nova,angdraug/nova,alexandrucoman/vbox-nova-driver,silenceli/nova,orbitfp7/nova,mahak/nova,dawnpower/nova,Yuriy-Leonov/nova,eayunstack/nova,double12gzh/nova,belmiromoreira/nova,isyippee/nova,bclau/nova,vmturbo/nova,rahulunair/nova,cloudbase/nova,bigswitch/nova,Stavitsky/nova,j-carpentier/nova,eonpatapon/nova,CiscoSystems/nova,Juniper/nova,rickerc/nova_audit,zzicewind/nova,mgagne/nova,mandeepdhami/nova,tangfeixiong/nova,devendermishrajio/nova_test_latest,ewindisch/nova,mahak/nova,apporc/nova,dawnpower/nova,eayunstack/nova,berrange/nova,iuliat/nova,ewindisch/nova,shahar-stratoscale/nova,OpenAcademy-OpenStack/nova-scheduler,alvarolopez/nova,cernops/nova,akash1808/nova_test_latest,belmiromoreira/nova,rickerc/nova_audit,alvarolopez/nova,SUSE-Cloud/nova,viggates/nova,petrutlucian94/nova,nikesh-mahalka/nova,watonyweng/nova,jianghuaw/nova,apporc/nova,yosshy/nova,shail2810/nova,tianweizhang/nova,sebrandon1/nova,shail2810/nova,NeCTAR-RC/nova,silenceli/nova,jianghuaw/nova,jianghuaw/nova,whitepages/nova,thomasem/nova,Yusuke1987/openstack_template,noironetworks/nova,alaski/nova,Yusuke1987/openstack_template,bigswitch/nova,redhat-openstack/nova,joker946/nova,alexandrucoman/vbox-nova-driver,tudorvio/nova,adelina-t/nova,eharney/nova,yosshy/nova,akash1808/nova,cernops/nova,alaski/nova,Brocade-OpenSource/OpenStack-DNRM-Nova,double12gzh/nova,openstack/nova,whitepages/nova,qwefi/nova,leilihh/nova,klmitch/nova,tianweizhang/nova,thomasem/nova,akash1808/nova,tangfeixiong/nova,rrader/nova-docker-plugin,akash1808/nova_test_latest,jianghuaw/nova,Metaswitch/calico-nova,adelina-t/nova,joker946/nova,saleemjaveds/https-github.com-openstack-nova,sacharya/nova,noironetworks/nova,Juniper/nova,watonyweng/nova,CCI-MOC/nova,affo/nova,rahulunair/nova,BeyondTheClouds/nova,klmitch/nova,MountainWei/nova,mmnelemane/nova,citrix-openstack-build/nova,cernops/nova,plumgrid/plumgrid-nova,gooddata/openstack-nova,iuliat/nova,isyippee/nova,mahak/nova,jeffrey4l/nova,mikalstill/nova,takeshineshiro/nova,CEG-FYP-OpenStack/scheduler,jeffrey4l/nova,Brocade-OpenSource/OpenStack-DNRM-Nova,openstack/nova,zhimin711/nova,eonpatapon/nova,Stavitsky/nova,ntt-sic/nova,barnsnake351/nova,petrutlucian94/nova_dev,JioCloud/nova_test_latest,devendermishrajio/nova_test_latest,raildo/nova,qwefi/nova,eharney/nova,TieWei/nova,takeshineshiro/nova,tanglei528/nova,BeyondTheClouds/nova,shootstar/novatest,saleemjaveds/https-github.com-openstack-nova,imsplitbit/nova,fnordahl/nova,devendermishrajio/nova,luogangyi/bcec-nova,edulramirez/nova,felixma/nova,NeCTAR-RC/nova,shahar-stratoscale/nova,mandeepdhami/nova,sacharya/nova,ted-gould/nova,zhimin711/nova,openstack/nova,dims/nova,sebrandon1/nova,mmnelemane/nova,tanglei528/nova,Francis-Liu/animated-broccoli,imsplitbit/nova,devendermishrajio/nova,JioCloud/nova_test_latest,cloudbase/nova-virtualbox,vmturbo/nova,maelnor/nova,sebrandon1/nova,rajalokan/nova,tealover/nova,fnordahl/nova,Metaswitch/calico-nova,cloudbase/nova,JioCloud/nova,affo/nova,gooddata/openstack-nova,leilihh/novaha,Tehsmash/nova,vladikr/nova_drafts,leilihh/nova,kimjaejoong/nova,redhat-openstack/nova,blueboxgroup/nova,projectcalico/calico-nova,BeyondTheClouds/nova,gooddata/openstack-nova,cloudbau/nova,plumgrid/plumgrid-nova,ntt-sic/nova,devoid/nova,rajalokan/nova