Sha256: f20b9ea095338ae807902e69d4a11e6055f715244069e1bd1b703e79172234a1

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

require 'cloud66_agent/utils/vital_signs'
require 'cloud66_agent/utils/version'
require 'cloud66_agent/utils/server'

module Cloud66
	module Commands
		class Configure
			def self.perform(server_uid, cloud)
				begin
					if cloud.nil? || cloud.empty?
						# try figure it out
						$config.is_aws = Utils::VitalSigns.is_aws?

						if $config.is_aws
							$config.is_gc = false
						else
							# try figure it out
							$config.is_gc = Utils::VitalSigns.is_gc?
						end
					else
						# use the passed in value
						$config.is_aws = (cloud == 'aws')

						# use the passed in value
						$config.is_gc = (cloud == 'googlecloud')
					end
					data = {
						:timezone => Time.new.zone,
						:server_uid => server_uid,
						:version => Utils::Version.current,
						:system => Utils::VitalSigns.system_info }

					address_info = Utils::VitalSigns.address_info
					data = data.merge(address_info)
				rescue => exc
					data = { error: exc.message }
				end
				result = Utils::Server.send_configure data
				$config.agent_uid = result['agent_uid']
				$config.disabled = false
				$config.save
				exit 0
			rescue => exc
				$logger.error "Command \"configure\" failed: #{exc.message}"
				exit -1
			end

		end
	end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cloud66_agent-1.3.1 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.3.0 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.2.8 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.2.7 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.2.6 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.2.5 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.2.5.beta2 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.2.5.beta1 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.2.4 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.2.4.beta1 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.2.3 lib/cloud66_agent/commands/configure.rb
cloud66_agent-1.2.2 lib/cloud66_agent/commands/configure.rb