engineyard / core-client-rb

Engine Yard Core API Ruby client
MIT License
4 stars 22 forks source link

EYPP-1890 - giving the ability to send configuration options together with blueprint #104

Closed ramonpm closed 6 years ago

ramonpm commented 6 years ago

https://jira.devfactory.com/browse/EYPP-1890

ramonpm commented 6 years ago

With this branch:

From: /home/ramonpm/workspace/ey-awsm/app/models/cluster_configuration.rb @ line 72 ClusterConfiguration.attempt:

    64: def self.attempt(env, params)
    65:   if env.instances.provisioned.any?
    66:     raise AttemptFailure.new("Environment is already provisioned")
    67:   elsif !env.provider.remaining?(env.region, :addresses) && !params[:cluster_configuration].try(:[], :configuration).try(:[], :ip_id)
    68:     raise AttemptFailure.new("Too many provisioned addresses in this region.  Specify an ip_id in the configuration and retry.")
    69:   elsif params[:cluster_configuration].try(:[], :blueprint_id)
    70:     blueprint = env.account.blueprints.get!(params.require(:cluster_configuration).require(:blueprint_id))
    71:     binding.pry
 => 72:     cc = new_from_blueprint(blueprint, env, params[:cluster_configuration][:configuration][:ip_id])
    73:   else
    74:     cc = new_from_core(params[:cluster_configuration].merge(environment: env))
    75:   end
    76:   (cc.valid? && cc) || raise(AttemptFailure.new(cc.errors.full_messages))
    77: end

[1] ey-awsm(ClusterConfiguration)> params
=> {"cluster_configuration"=>{"blueprint_id"=>"a160eff2-2d68-4092-8b1a-21ff8ec9e447", "configuration"=>{"apps"=>{"snapshot_id"=>3}, "db_master"=>{"snapshot_id"=>4}}},
 "subdomain"=>"api-development.localdev",
 "controller"=>"core/environments",
 "action"=>"boot",
 "environment"=>"5"}

With released version:

From: /home/ramonpm/workspace/ey-awsm/app/models/cluster_configuration.rb @ line 72 ClusterConfiguration.attempt:

    64: def self.attempt(env, params)
    65:   if env.instances.provisioned.any?
    66:     raise AttemptFailure.new("Environment is already provisioned")
    67:   elsif !env.provider.remaining?(env.region, :addresses) && !params[:cluster_configuration].try(:[], :configuration).try(:[], :ip_id)
    68:     raise AttemptFailure.new("Too many provisioned addresses in this region.  Specify an ip_id in the configuration and retry.")
    69:   elsif params[:cluster_configuration].try(:[], :blueprint_id)
    70:     blueprint = env.account.blueprints.get!(params.require(:cluster_configuration).require(:blueprint_id))
    71:     binding.pry
 => 72:     cc = new_from_blueprint(blueprint, env, params[:cluster_configuration][:configuration][:ip_id])
    73:   else
    74:     cc = new_from_core(params[:cluster_configuration].merge(environment: env))
    75:   end
    76:   (cc.valid? && cc) || raise(AttemptFailure.new(cc.errors.full_messages))
    77: end

[1] ey-awsm(ClusterConfiguration)> params
=> {"cluster_configuration"=>{"blueprint_id"=>"a160eff2-2d68-4092-8b1a-21ff8ec9e447", "configuration"=>{}}, "subdomain"=>"api-development.localdev", "controller"=>"core/environments", "action"=>"boot", "environment"=>"5"}

The snapshot_ids are ignored...