merged with dev

This commit is contained in:
Anton Martynov 2015-02-18 11:00:24 +03:00
parent 3dee4b4b0b
commit d1a555d97e
20 changed files with 25 additions and 25 deletions

View File

@ -18,7 +18,7 @@ module Connectors
private
def model_from_bson(bson)
::Image.create_from_bson(bson)
::Image.build_from_bson(bson)
end
end

View File

@ -21,7 +21,7 @@ module Connectors
private
def model_from_bson(bson)
::Key.create_from_bson(bson)
::Key.build_from_bson(bson)
end
end

View File

@ -83,7 +83,7 @@ module Connectors
private
def model_from_bson(bson)
::Project.create_from_bson(bson)
::Project.build_from_bson(bson)
end
end

View File

@ -66,7 +66,7 @@ module Connectors
private
def model_from_bson(bson)
::Server.create_from_bson(bson)
::Server.build_from_bson(bson)
end
# couldn't be replaced with ShowCommand (_id doesn't neccesary appear in params)

View File

@ -18,7 +18,7 @@ module Connectors
def model_from_bson(bson)
provider = bson['provider']
::StackFactory.get_class(provider).create_from_bson(bson)
::StackFactory.get_class(provider).build_from_bson(bson)
end
end
end

View File

@ -18,7 +18,7 @@ module Connectors
def model_from_bson(bson)
provider = bson['provider']
::StackTemplateFactory.get_class(provider).create_from_bson(bson)
::StackTemplateFactory.get_class(provider).build_from_bson(bson)
end
end

View File

@ -50,7 +50,7 @@ module Connectors
private
def model_from_bson(bson)
::User.create_from_bson(bson)
::User.build_from_bson(bson)
end
end

View File

@ -85,7 +85,7 @@ class DeployEnvMulti < MongoModel
raise InvalidRecord.new("Subproject '#{spi}'. #{e.message}")
end
end
pdb = DevopsService.mongo.project_names_with_envs(server["subprojects"].map{|sp| sp["name"]})
pdb = ::Devops::Db.connector.project_names_with_envs(server["subprojects"].map{|sp| sp["name"]})
server["subprojects"].each_with_index do |sp, spi|
raise InvalidRecord.new("Subproject '#{spi}'. Project '#{sp["name"]}' with env '#{sp["env"]}' does not exist") if pdb[sp["name"]].nil? or !pdb[sp["name"]].include?(sp["env"])
end
@ -107,7 +107,7 @@ class DeployEnvMulti < MongoModel
}
end
def self.create_from_bson d
def self.build_from_bson d
DeployEnvMulti.new(d)
end

View File

@ -20,7 +20,7 @@ class Image < MongoModel
self.bootstrap_template = p["bootstrap_template"]
end
def self.create_from_bson args
def self.build_from_bson args
image = Image.new(args)
image.id = args["_id"]
image

View File

@ -21,7 +21,7 @@ class Key < MongoModel
self.scope = p["scope"] || USER
end
def self.create_from_bson s
def self.build_from_bson s
key = Key.new s
key.id = s["_id"]
key

View File

@ -126,7 +126,7 @@ class Project < MongoModel
self.type == MULTI_TYPE
end
def self.create_from_bson p
def self.build_from_bson p
p["name"] = p["_id"]
Project.new p
end

View File

@ -67,7 +67,7 @@ class Server < MongoModel
}
end
def self.create_from_bson s
def self.build_from_bson s
Server.new(s)
end

View File

@ -40,7 +40,7 @@ class StackBase < MongoModel
model
end
def self.create_from_bson(attrs)
def self.build_from_bson(attrs)
attrs['id'] = attrs["_id"]
self.new(attrs)
end

View File

@ -8,8 +8,8 @@ class StackFactory
get_class(provider).create(attrs)
end
def self.create_from_bson(provider, attrs)
get_class(provider).create_from_bson(attrs)
def self.build_from_bson(provider, attrs)
get_class(provider).build_from_bson(attrs)
end
def self.get_class(provider)

View File

@ -47,7 +47,7 @@ class StackTemplateBase < MongoModel
new(attrs)
end
def self.create_from_bson(attrs)
def self.build_from_bson(attrs)
attrs['id'] = attrs["_id"]
self.new(attrs)
end

View File

@ -8,8 +8,8 @@ class StackTemplateFactory
get_class(provider).create(attrs)
end
def self.create_from_bson(provider, attrs)
get_class(provider).create_from_bson(attrs)
def self.build_from_bson(provider, attrs)
get_class(provider).build_from_bson(attrs)
end
def self.get_class(provider)

View File

@ -49,7 +49,7 @@ class User < MongoModel
end
end
def self.create_from_bson s
def self.build_from_bson s
user = User.new s
user.id = s["_id"]
user

View File

@ -5,7 +5,7 @@ module Validators
include ::ImageCommands
def valid?
images = get_images(DevopsService.mongo, @model.provider)
images = get_images(::Devops::Db.connector, @model.provider)
images.detect do |image|
image["id"] == @model.image
end
@ -15,4 +15,4 @@ module Validators
"Invalid image '#{@model.image}'."
end
end
end
end

View File

@ -2,7 +2,7 @@ module Validators
class DeployEnv::Users < Base
def valid?
mongo_users = DevopsService.mongo.users_names(@model.users)
mongo_users = ::Devops::Db.connector.users_names(@model.users)
@nonexistent_users = @model.users - mongo_users
@nonexistent_users.empty?
end
@ -11,4 +11,4 @@ module Validators
"These users are missing in mongo: '#{@nonexistent_users.join("', '")}'."
end
end
end
end

View File

@ -5,7 +5,7 @@ module Validators
include ImageCommands
def valid?
images = get_images(DevopsService.mongo, @model.provider)
images = get_images(::Devops::Db.connector, @model.provider)
images.map{|i| i["id"]}.include?(@model.id)
end