Sha256: f01cefe2b5555a0754fccce2646a9154b66b0cf44f3f25f0e5e966f9e294a6ce

Contents?: true

Size: 1.92 KB

Versions: 184

Compression:

Stored size: 1.92 KB

Contents

# Get the wanted content of the configuration file as a String, based on the node's metadata
#
# Parameters::
# * *node* (String): Node for which we configure our service
# Result::
# * String: The wanted content
def wanted_conf_for(node)
  # We will access the node's metadata using the NodesHandler API, through the @nodes_handler object
  @service_port = @nodes_handler.get_service_port_of(node)
  @service_timeout = @nodes_handler.get_service_timeout_of(node)
  # We use erubis to generate the configuration from our eRuby template, and return it directly
  Erubis::Eruby.new(File.read("#{@platform_handler.repository_path}/my-service.conf.erb")).result(binding)
end

# Get actions to check the node's service against the wanted content
#
# Parameters::
# * *node* (String): Node on which we check the service
# Result::
# * Array< Hash<Symbol,Object> >: The list of actions
def check(node)
  # We first dump the wanted content in a temporary file and then we diff it.
  [
    {
      remote_bash: <<~EOS
        cat <<EOF >/tmp/my-service.conf.wanted
        #{wanted_conf_for(node)}
        EOF
        echo Diffs on my-service.conf:
        if test -f ~/hpc_tutorial/node/my-service.conf; then
          diff ~/hpc_tutorial/node/my-service.conf /tmp/my-service.conf.wanted || true
        else
          echo "Create file from scratch"
          cat /tmp/my-service.conf.wanted
        fi
      EOS
    }
  ]
end

# Get actions to deploy the node's service against the wanted content
#
# Parameters::
# * *node* (String): Node on which we deploy the service
# Result::
# * Array< Hash<Symbol,Object> >: The list of actions
def deploy(node)
  # We first check, as this will display diffs and prepare the file to be copied.
  # And then we really deploy the file on our node.
  check(node) + [
    {
      remote_bash: <<~EOS
        mkdir -p ~/hpc_tutorial/node
        cp /tmp/my-service.conf.wanted ~/hpc_tutorial/node/my-service.conf
      EOS
    }
  ]
end

Version data entries

184 entries across 46 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-33.9.5 examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.5 examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.5 examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.5 examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.4 examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.4 examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.4 examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.4 examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.2 examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.2 examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.2 examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.2 examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.1 examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.1 examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.1 examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.1 examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.0 examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.0 examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.0 examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb
hybrid_platforms_conductor-33.9.0 examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb