Class: UU::CloudRuntime::Host

Inherits:
RuntimeBaseClass
  • Object
show all
Defined in:
lib/uu/cloud_runtime/host.rb

Overview

Host class.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session = nil) ⇒ Host

Creates a new instance of Host.

Parameters:

  • session (UU::OS::Security::Session) (defaults to: nil)

    Instance of session representing authenticated user (can be obtained with OS::Security::Session#current_session method).



19
20
21
# File 'lib/uu/cloud_runtime/host.rb', line 19

def initialize(session = nil)
  @client = UU::OS::CMD::CommandClient.new(PATH, session)
end

Class Method Details

.get_status(host_uri) ⇒ Hash

Note:

get_status is not allowed for SWARM hosts.

Returns general info about a target host and info about running containers on the host.

Examples:

require 'uu_c3'
UU::OS::Security::Session.('...')

host_uri = UU::OS::UESURI.new("ues:OT-BT:PLUS4U_CLOUD")

host_status = UU::CloudRuntime::Host.get_status(host_uri)

Response


{
  "uri": "ues:OT-BT[99923616732452117]:h-ygt2i0tk[571fb9c82792890902e2281c]",
  "name": "h-ygt2i0tk",
  "reinitStrategy": "SUPPORTED",
  "hostname": "h-ygt2i0tk.rg-fae1x1l0.uu-os8-apps2.eu-n-1.cloud.plus4u.net",
  "resourceGroupUri": "ues:OT-BT[99923616732452117]:fae1x1l0[571fb9c52792890902e22804]",
  "totalCapacity": {
    "cpu": 20,
    "mem": 10000,
    "storage": 20000
  },
  "freeCapacity": {
    "cpu": 3,
    "mem": 0,
    "storage": 3000
  },
  "state": "ACTIVE",
  "containers": [
    {
      "uri": "ues:OT-BT[99923616732452117]:57285a3d279289124ce23666[57285a3d279289124ce23666]",
      "status": "RUNNING",
      "runParams": {
        "action": "createUUNode",
        "dhost": "h-ygt2i0tk.rg-fae1x1l0.uu-os8-apps2.eu-n-1.cloud.plus4u.net",
        "name": "dev0126_bt-ucl_embpla-widget-0_0_28-57285a3d279289124ce23666",
        "image": "ucl_embpla-widget:0.0.28",
        "memory": 500,
        "cpu-shares": 1,
        "app-deployment-uri": "ues:DEV0126-BT[84723967990088710]:DEV[571fb9da2792891f35e22915]:UCL.EMBPLA[5720be5327928991ffe22dda]",
        "app-version": "0.0.28",
        "host-id": "571fb9c82792890902e2281c",
        "host-name": "h-ygt2i0tk.rg-fae1x1l0.uu-os8-apps2.eu-n-1.cloud.plus4u.net",
        "node-id": "57285a3d279289124ce23666",
        "node-image-id": "57285a3c279289de0ee23664",
        "node-image-name": "ucl_embpla-widget:0.0.28",
        "node-name": "dev0126_bt-ucl_embpla-widget-0_0_28-57285a3d279289124ce23666",
        "pool-access-group-uri": "ues:DEV0126-BT:DEV~DEPLOYERS",
        "pool-auditors-uri": nil,
        "resource-group-code": "fae1x1l0",
        "resource-group-id": "571fb9c52792890902e22804",
        "runtime-stack-code": "WIDGET_JRUBY_V1.0",
        "runtime-stack-id": "571fb9d02792890902e22860",
        "ports": "38280:8080,11383:9090,19018:9091",
        "uuEEs": nil,
        "serverCfg": nil,
      }
    },
    {
      "uri": "ues:OT-BT[99923616732452117]:5731b6d62792892a381479b1[5731b6d62792892a381479b1]",
      "status": "NOT_RUNNING",
      "runParams": {
        "action": "createUUNode",
        "dhost": "h-ygt2i0tk.rg-fae1x1l0.uu-os8-apps2.eu-n-1.cloud.plus4u.net",
        "name": "triangle_bt-uu_sdi-cmd-0_0_36-5731b6d62792892a381479b1",
        "image": "uu_sdi-cmd:0.0.36",
        "memory": 500,
        "cpu-shares": 1,
        "app-deployment-uri": "ues:TRIANGLE-BT[84723967990072194]:DEV[571fb9d92792891f35e228f7]:UU.SDI[5720b2e4279289de0ee22c6b]",
        "app-version": "0.0.36",
        "host-id": "571fb9c82792890902e2281c",
        "host-name": "h-ygt2i0tk.rg-fae1x1l0.uu-os8-apps2.eu-n-1.cloud.plus4u.net",
        "node-id": "5731b65b27928977e31479a3",
        "node-image-id": "5731b69227928971931479ab",
        "node-image-name": "uu_sdi-cmd:0.0.36",
        "node-name": "triangle_bt-uu_sdi-cmd-0_0_36-5731b6d62792892a381479b1",
        "pool-access-group-uri": "ues:TRIANGLE-BT:DEV~DEPLOYERS",
        "pool-auditors-uri": nil,
        "resource-group-code": "fae1x1l0",
        "resource-group-id": "571fb9c52792890902e22804",
        "runtime-stack-code": "CMD_JRUBY_V1.0",
        "runtime-stack-id": "571fb9d02792890902e22859",
        "ports": "50593:8080,55096:9090,22909:9091",
        "uuEEs": nil,
        "serverCfg": nil,
      }
    }
  ],
  "commonContainers": [
    {
      "id": "6310a34fc134d121c83d13e9c49a11524e25d61959f951f36471518ef434c8e3",
      "name": "/uu_logstore-collector",
      "state": "running",
      "creationTime": "2017-06-27T01:34:49.875221823Z",
      "image": {
        "id": "sha256:18c349ebbefe10ee6727fe52d2db2eb5045518fe98d8e31fdad1cbdd5e1f7370",
        "name": "uu_logstore-collector"
      }
    }
  ],
  "unknownContainers": [
    {
      "id": "fc134d121c83d13e9c49a11524e25d61959f951f36471518ef434c8e36310a34",
      "name": "/eager_booth",
      "state": "running",
      "creationTime": "2017-08-07T12:14:10.287521823Z",
      "image": {
        "id": "sha256:efe10ee6727fe52d2db2eb5045518fe98d8e31fdad1cbdd5e1f737018c349ebb",
        "name": "busybox"
      }
    }
  ]
}

Parameters:

  • host_uri (UU::OS::UESURI, String)

    Target host uri.

Returns:

  • (Hash)

    Structured hash.



150
151
152
# File 'lib/uu/cloud_runtime/host.rb', line 150

def self.get_status(host_uri)
  self.new(UU::OS::Security::Session.current_session).get_status(host_uri)
end

.reinit(host_uri, parameters = {}) ⇒ UU::OS::Lang::Future

Note:

reinit is only allowed for hosts with reinitStrategy set to “SUPPORTED”

Synchronize a target host with the metadata in the Operation Registry:

* Run containers that are supposed to be running (according do the Operation Registry)
* Restart running containers if requested - see parameter +restartRunningContainers+
* Delete containers that are not supposed to be running if requested - see parameter
  +stopUnknownContainers+

Examples:

require 'uu_c3'
UU::OS::Security::Session.('...')

future = UU::CloudRuntime::Host.reinit("ues:OT-BT:h-ygt2i0tk",
  restartRunningContainers: true,
  stopUnknownContainers: true
)

future.get # blocking opertation

future.get response


{
  added: [
    "triangle_bt-uu_sdi-cmd-0_0_36-5731b6d62792892a381479b1"
  ],
  restarted: [
    "dev0126_bt-ucl_embpla-widget-0_0_28-57285a3d279289124ce23666"
  ],
  deleted: [
    "/eager_booth"
  ],
  problems: [
  ]
}

Parameters:

  • host_uri (UU::OS::UESURI, String)

    Target host uri.

  • parameters (Hash) (defaults to: {})

    Reinit parameters.

Options Hash (parameters):

  • restartRunningContainers (TrueClass, FalseClass)

    Flag determining whether to restart (known) containers that are running on the host. Default vlaue is false. May be nil.

  • stopUnknownContainers (TrueClass, FalseClass)

    Flag determining whether the containers that are running on the host but are not registered in the Operation Registry should be deleted. Default value is false. May be nil.

Returns:

  • (UU::OS::Lang::Future)

    Instance of future to use to wait for the reinit operation to finish (Note that maximum timeout of future is set to 30 seconds, which might be insufficient time to finish a reinit. Therefore timeout error might be expected when Future.get is invoked immediately after the command invocation. It is however possible to wait repeatedly using the same instance of the returned Future object.) Future.get returns reinitStatus.



234
235
236
# File 'lib/uu/cloud_runtime/host.rb', line 234

def self.reinit(host_uri, parameters = {})
  self.new(UU::OS::Security::Session.current_session).reinit(host_uri, parameters)
end

Instance Method Details

#get_status(host_uri) ⇒ Hash

Note:

get_status is not allowed for SWARM hosts.

Returns general info about a target host and info about running containers on the host.

Parameters:

  • host_uri (UU::OS::UESURI, String)

    Target host uri.

Returns:

  • (Hash)

    Structured hash.

See Also:



28
29
30
# File 'lib/uu/cloud_runtime/host.rb', line 28

def get_status(host_uri)
  @client.invoke(:getStatus, host_uri)
end

#reinit(host_uri, parameters = {}) ⇒ UU::OS::Lang::Future

Note:

reinit is only allowed for hosts with reinitStrategy set to “SUPPORTED”

Synchronize a target host with the metadata in the Operation Registry:

* Run containers that are supposed to be running (according do the Operation Registry)
* Restart running containers (if requested - see parameter +restartRunningContainers+)
* Delete containers that are not supposed to be running (if requested - see parameter
  +stopUnknownContainers+)

Parameters:

  • host_uri (UU::OS::UESURI, String)

    Target host uri.

  • parameters (Hash) (defaults to: {})

    Reinit parameters.

Options Hash (parameters):

  • restartRunningContainers (TrueClass, FalseClass)

    Flag determining whether to restart (known) containers that are running on the host. Default vlaue is false. May be nil.

  • stopUnknownContainers (TrueClass, FalseClass)

    Flag determining whether the containers that are running on the host but are not registered in the Operation Registry should be deleted. Default value is false. May be nil.

Returns:

  • (UU::OS::Lang::Future)

    Instance of future to use to wait for the reinit operation to finish (Note that maximum timeout of future is set to 30 seconds, which might be insufficient time to finish a reinit. Therefore timeout error might be expected when Future.get is invoked immediately after the command invocation. It is however possible to wait repeatedly using the same instance of the returned Future object.) Future.get returns reinitStatus.

See Also:



179
180
181
# File 'lib/uu/cloud_runtime/host.rb', line 179

def reinit(host_uri, parameters = {})
  @client.invoke(:reinit, host_uri, parameters: parameters)
end