diff --git a/devops-service/commands/stack.rb b/devops-service/commands/stack.rb index 86168bc..3d54805 100644 --- a/devops-service/commands/stack.rb +++ b/devops-service/commands/stack.rb @@ -13,6 +13,7 @@ module StackCommands sleep_times.each do |sleep_time| sleep sleep_time stack.sync_details! + puts stack.stack_status if stack.stack_status != 'CREATE_IN_PROGRESS' mongo.stack_update(stack) out << "Stack '#{stack.id}' status is now #{stack.stack_status}" diff --git a/devops-service/db/mongo/models/stack/stack_base.rb b/devops-service/db/mongo/models/stack/stack_base.rb index 99d13ec..cb8d297 100644 --- a/devops-service/db/mongo/models/stack/stack_base.rb +++ b/devops-service/db/mongo/models/stack/stack_base.rb @@ -59,7 +59,7 @@ module Devops end def sync_details! - self.details = provider_instance.stack_details(self).attributes + self.details = provider_instance.stack_details(self)#.attributes end def resources diff --git a/devops-service/db/mongo/models/stack/stack_ec2.rb b/devops-service/db/mongo/models/stack/stack_ec2.rb index a3cff24..97e18fa 100644 --- a/devops-service/db/mongo/models/stack/stack_ec2.rb +++ b/devops-service/db/mongo/models/stack/stack_ec2.rb @@ -7,6 +7,10 @@ module Devops super(attr) end + def stack_status + details['StackStatus'] if details + end + end end end diff --git a/devops-service/providers/ec2.rb b/devops-service/providers/ec2.rb index 3646df1..f55f6ee 100644 --- a/devops-service/providers/ec2.rb +++ b/devops-service/providers/ec2.rb @@ -235,15 +235,16 @@ module Provider end def delete_stack(stack) - fog_stack(stack).destroy + cloud_formation.delete_stack(stack.name) end def stack_details(stack) - fog_stack(stack).details + d = cloud_formation.describe_stacks({'StackName' => stack.name}).body['Stacks'][0]['stack'] + puts "Details: #{d.inspect}" end def stack_resources(stack) - fog_stack(stack).resources + cloud_formation.describe_stack_resources({'StackName' => stack.name}).body['StackResources'] end def stack_resource(stack, resource_id) @@ -252,7 +253,7 @@ module Provider end def stack_servers(stack) - fog_stack(stack).resources.map{|r| compute.servers.get(r.physical_resource_id)} + stack_resources(stack).map{|r| compute.servers.get(r.physical_resource_id)} end private @@ -306,8 +307,5 @@ module Provider r end - def fog_stack(stack) - cloud_formation.stacks.get(stack.name, stack.id) - end end end diff --git a/devops-service/providers/openstack.rb b/devops-service/providers/openstack.rb index 8602f9f..ed34fcc 100644 --- a/devops-service/providers/openstack.rb +++ b/devops-service/providers/openstack.rb @@ -200,12 +200,14 @@ module Provider out << "Stack template: #{stack.stack_template}\n" out << "Stack parameters: #{stack.parameters}\n" out << "Stack template: #{stack.template_body}\n" + out.flush response = orchestration.create_stack( stack_name: stack.name, template: stack.template_body, parameters: stack.parameters || {} ) stack.id = response[:body]['stack']['id'] + out << "Stack id: #{stack.id}\n" rescue Excon::Errors::Conflict => e raise ProviderErrors::NameConflict rescue Excon::Errors::BadRequest => br @@ -223,15 +225,15 @@ module Provider end def delete_stack(stack) - fog_stack(stack).destroy + orchestration.delete_stack(Fog::Orchestration::OpenStack::Stack.new({'id' => stack.id, 'stack_name' => stack.name})) end def stack_details(stack) - fog_stack(stack).details + orchestration.show_stack_details(stack.name, stack.id).body['stack'] end def stack_resources(stack) - fog_stack(stack).resources + orchestration.list_resources(Fog::Orchestration::OpenStack::Stack.new({'id' => stack.id, 'stack_name' => stack.name})).body['resources'] end def stack_resource(stack, resource_id) @@ -240,7 +242,7 @@ module Provider end def stack_servers(stack) - fog_stack(stack).resources.map{|r| compute.servers.get(r.physical_resource_id)} + stack_resources(stack).map{|r| compute.servers.get(r['physical_resource_id'])} end private @@ -268,9 +270,5 @@ module Provider @connection ||= Fog::Orchestration.new(connection_options) end - def fog_stack(stack) - orchestration.stacks.get(stack.name, stack.id) - end - end end