-class Node < OrvosModel
+class Node < ArvadosModel
include AssignUuid
include KindAndEtag
include CommonApiTemplate
@@domain = Rails.configuration.compute_node_domain rescue `hostname --domain`.strip
@@nameservers = Rails.configuration.compute_node_nameservers
- api_accessible :superuser, :extend => :common do |t|
+ api_accessible :user, :extend => :common do |t|
t.add :hostname
t.add :domain
t.add :ip_address
- t.add :first_ping_at
t.add :last_ping_at
- t.add :info
+ t.add :slot_number
t.add :status
+ t.add :crunch_worker_state
+ end
+ api_accessible :superuser, :extend => :user do |t|
+ t.add :first_ping_at
+ t.add :info
t.add lambda { |x| @@nameservers }, :as => :nameservers
end
super || @@domain
end
+ def crunch_worker_state
+ case self.info.andand[:slurm_state]
+ when 'alloc', 'comp'
+ 'busy'
+ when 'idle'
+ 'idle'
+ else
+ 'down'
+ end
+ end
+
def status
if !self.last_ping_at
if Time.now - self.created_at > 5.minutes
if o[:ping_secret] != self.info[:ping_secret]
logger.info "Ping: secret mismatch: received \"#{o[:ping_secret]}\" != \"#{self.info[:ping_secret]}\""
- return nil
+ raise ArvadosModel::UnauthorizedError.new("Incorrect ping_secret")
end
self.last_ping_at = Time.now
- @bypass_orvos_authorization = true
+ @bypass_arvados_authorization = true
# Record IP address
if self.ip_address.nil?
if o[:ec2_instance_id]
if !self.info[:ec2_instance_id]
self.info[:ec2_instance_id] = o[:ec2_instance_id]
- `ec2-create-tags #{o[:ec2_instance_id]} --tag 'Name=#{self.uuid}'`
+ if (Rails.configuration.compute_node_ec2_tag_enable rescue true)
+ tag_cmd = ("ec2-create-tags #{o[:ec2_instance_id]} " +
+ "--tag 'Name=#{self.uuid}'")
+ `#{tag_cmd}`
+ end
elsif self.info[:ec2_instance_id] != o[:ec2_instance_id]
logger.debug "Multiple nodes have credentials for #{self.uuid}"
raise "#{self.uuid} is already running at #{self.info[:ec2_instance_id]} so rejecting ping from #{o[:ec2_instance_id]}"
end while true
self.hostname = self.class.hostname_for_slot(self.slot_number)
if info[:ec2_instance_id]
- `ec2-create-tags #{self.info[:ec2_instance_id]} --tag 'hostname=#{self.hostname}'`
+ if (Rails.configuration.compute_node_ec2_tag_enable rescue true)
+ `ec2-create-tags #{self.info[:ec2_instance_id]} --tag 'hostname=#{self.hostname}'`
+ end
end
end
ping_url = ping_url_method.call({ uuid: self.uuid, ping_secret: self.info[:ping_secret] })
ec2_args = ["--user-data '#{ping_url}'",
"-t c1.xlarge -n 1",
- "-g", Rails.configuration.compute_node_security_group,
+ Rails.configuration.compute_node_ec2run_args,
Rails.configuration.compute_node_ami
]
ec2run_cmd = ["ec2-run-instances",
result.match(/INSTANCE\s*(i-[0-9a-f]+)/) do |m|
instance_id = m[1]
self.info[:ec2_instance_id] = instance_id
- `ec2-create-tags #{instance_id} --tag 'Name=#{self.uuid}'`
+ if (Rails.configuration.compute_node_ec2_tag_enable rescue true)
+ `ec2-create-tags #{instance_id} --tag 'Name=#{self.uuid}'`
+ end
end
result.match(/SPOTINSTANCEREQUEST\s*(sir-[0-9a-f]+)/) do |m|
sir_id = m[1]
self.info[:ec2_sir_id] = sir_id
- `ec2-create-tags #{sir_id} --tag 'Name=#{self.uuid}'`
+ if (Rails.configuration.compute_node_ec2_tag_enable rescue true)
+ `ec2-create-tags #{sir_id} --tag 'Name=#{self.uuid}'`
+ end
end
self.save!
end
end
def permission_to_update
- @bypass_orvos_authorization or super
+ @bypass_arvados_authorization or super
end
def permission_to_create