app/controllers/api/v1/node/registrations_controller.rb
# GET /register
# Register node into cluster
GET /register
Register node into cluster
GET / register Register node into cluster
def register
    raise UnauthorizedException if !@cluster.authenticate(params[:password])
    @node = @cluster.nodes.find_by(hostname: params[:node_hostname])
    if @node.nil?
      @node = @cluster.nodes.create!(
        hostname: params[:node_hostname],
        ipaddress: (params[:node_ipaddress].blank?) ? request.remote_ip : params[:node_ipaddress],
        schedulable: true,
      )
    end
    authentication_token = @node.refresh_authentication_token
    attrs = {authentication_token: authentication_token}
    render json: ::Api::V1::Node::RegistrationSerializer.new(
      @node, attrs: attrs).to_h
  end
def register raise UnauthorizedException if ! @cluster . authenticate ( params [ :password ] ) @node = @cluster . nodes . find_by ( hostname : params [ :node_hostname ] ) if @node . nil? @node = @cluster . nodes . create! ( hostname : params [ :node_hostname ] , ipaddress : ( params [ :node_ipaddress ] . blank? ) ? request . remote_ip : params [ :node_ipaddress ] , schedulable : true , ) end authentication_token = @node . refresh_authentication_token attrs = { authentication_token : authentication_token } render json : :: Api :: V1 :: Node :: RegistrationSerializer . new ( @node , attrs : attrs ) . to_h end
GET /register
Register node into cluster
GET / register Register node into cluster
# Find or create the node # Generate new authentication token # Render the response