@@ -78,7 +78,7 @@ def perform
7878 handle_not_detached_instance_plan
7979
8080 # desired state
81- if instance . state == ' stopped'
81+ if instance . stopped?
8282 # Command issued: `bosh stop`
8383 update_instance
8484 return
@@ -87,12 +87,12 @@ def perform
8787 handle_detached_instance_if_detached
8888 end
8989
90- converge_vm if instance . state != ' detached'
90+ converge_vm unless instance . detached?
9191 update_instance
9292 update_dns_if_changed
9393 update_vm_disk_metadata
9494
95- return if instance . state == ' detached'
95+ return if instance . detached?
9696
9797 @rendered_templates_persister . persist ( instance_plan )
9898 apply_state
@@ -119,19 +119,19 @@ def handle_not_detached_instance_plan
119119 @rendered_templates_persister . persist ( instance_plan )
120120 end
121121
122- unless instance_plan . needs_shutting_down? || instance . state == ' detached'
122+ unless instance_plan . needs_shutting_down? || instance . detached?
123123 DeploymentPlan ::Steps ::PrepareInstanceStep . new ( instance_plan ) . perform ( instance_report )
124124 end
125125
126126 # current state
127- return unless instance . model . state != ' stopped'
127+ return if instance . model . stopped?
128128
129129 stop
130130 take_snapshot
131131 end
132132
133133 def handle_detached_instance_if_detached
134- return unless instance . state == ' detached'
134+ return unless instance . detached?
135135
136136 # Command issued: `bosh stop --hard`
137137 @logger . info ( "Detaching instance #{ instance } " )
@@ -149,7 +149,7 @@ def update_instance
149149 def update_vm_disk_metadata
150150 return unless instance_plan . changes . include? ( :tags )
151151 return if instance_plan . new? || @needs_recreate
152- return if instance . state == ' detached' # disks will get a metadata update when attaching again
152+ return if instance . detached? # disks will get a metadata update when attaching again
153153
154154 @logger . debug ( "Updating instance #{ instance } VM and disk metadata with tags" )
155155 tags = instance_plan . tags
@@ -188,7 +188,7 @@ def stop
188188 end
189189
190190 def deleting_vm?
191- @needs_recreate || instance_plan . needs_shutting_down? || instance . state == ' detached' ||
191+ @needs_recreate || instance_plan . needs_shutting_down? || instance . detached? ||
192192 ( instance_plan . should_create_swap_delete? && instance_plan . instance . model . vms . count > 1 )
193193 end
194194
0 commit comments