find stack by name

This commit is contained in:
amartynov 2015-08-18 16:37:33 +03:00
parent 53a1e23864
commit 44ad70b01b
3 changed files with 11 additions and 4 deletions

View File

@ -56,8 +56,8 @@ module Devops
Devops::Db.connector.stack(id)
end
def delete_stack id
stack = self.stack(id)
def delete_stack name
stack = self.stack(naem)
stack.delete_stack_in_cloud!
Devops::Db.connector.stack_servers_delete(id)
Devops::Db.connector.stack_delete(id)

View File

@ -1,7 +1,7 @@
module Connectors
class Stack < Base
include Helpers::InsertCommand,
Helpers::ShowCommand,
# Helpers::ShowCommand,
Helpers::ListCommand,
Helpers::DeleteCommand,
Helpers::UpdateCommand
@ -18,6 +18,13 @@ module Connectors
collection.update({"_id" => id}, {"$set" => {"run_list" => run_list}})
end
def stack(name, options={})
query = {'name' => name}.merge(options)
bson = collection.find(query).to_a.first
raise RecordNotFound.new("'#{id}' not found") unless bson
model_from_bson(bson)
end
private
def model_from_bson(bson)

View File

@ -219,7 +219,7 @@ module Provider
}
)
body = response.body
out << "Body: #{body.inspect}"
out << "Body: #{body.inspect}\n"
stack.id = body['StackId']
out << "Stack id: #{stack.id}\n"
rescue Excon::Errors::Conflict => e