Sha256: 1b1037e45fca58ace599f0dd6ce1249e3f9f2465ed995ffd348ca25a92d93733

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

module CORL
module Action
class Provision < Plugin::CloudAction
 
  #-----------------------------------------------------------------------------
  # Settings
  
  def configure
    super do
      codes :network_failure,
            :provision_failure
            
      register :dry_run, :bool, false
      register :color, :bool, true
    end
  end
  
  #-----------------------------------------------------------------------------
  # Operations
  
  def execute
    super do |node, network|
      if network && node
        info('corl.actions.provision.start')
        
        success = true
        
        if CORL.admin?
          unless node.build_time && File.directory?(network.build_directory)
            success = node.build
          end
        
          if success
            provisioner_info = node.provisioner_info   
        
            node.provisioners.each do |provider, collection|
              provider_info = provisioner_info[provider]
              profiles      = provider_info[:profiles]
          
              collection.each do |name, provisioner|
                if supported_profiles = provisioner.supported_profiles(profiles)
                  profile_success = provisioner.provision(supported_profiles, settings)
                  success         = false unless profile_success
                end
              end
            end
            myself.status = code.provision_failure unless success
          end
        end
      else
        myself.status = code.network_failure  
      end
    end
  end
end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
corl-0.4.4 lib/CORL/action/provision.rb