2015-11-17 12:14:02 +03:00
|
|
|
require_relative "base"
|
|
|
|
|
|
|
|
|
|
module Validators
|
|
|
|
|
module FieldValidator
|
|
|
|
|
class Vpc < Base
|
|
|
|
|
|
|
|
|
|
def valid?
|
|
|
|
|
provider = ::Provider::ProviderFactory.get(@model.provider, @model.provider_account)
|
|
|
|
|
vpcs = provider.describe_vpcs
|
2016-02-08 15:07:46 +03:00
|
|
|
ids = vpcs.map{|v| v["vpc_id"]}
|
|
|
|
|
ids.include?(@value)
|
2015-11-17 12:14:02 +03:00
|
|
|
rescue
|
|
|
|
|
raise "Invalid provider account '#{@model.provider_account}'"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def message
|
|
|
|
|
"Invalid vpc '#{@value}'."
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|