Method: ContainerManager#create_container

Defined in:
lib/wf_node_api/container_manager.rb

#create_container(name, ip_address, disk_size_gb, memory_limit_mb, cpu_core_count) ⇒ String

Creates a container with the given parameters

Parameters:

  • name (String)

    The container name

  • ip_address (String)

    A valid IPv4 address

  • disk_size_gb (Integer)

    The disk size in GB

  • memory_limit_mb (Integer)

    The memory limit in MB

  • cpu_core_count (Integer)

    Amount of Vcores to assign

Returns:

  • (String)

    CLI output

Raises:



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/wf_node_api/container_manager.rb', line 267

def create_container(name, ip_address, disk_size_gb, memory_limit_mb, cpu_core_count)
  disk_size_gb = disk_size_gb.to_i
  memory_limit_mb = memory_limit_mb.to_i
  cpu_core_count = cpu_core_count.to_i

  if name.nil? || name.empty? || (/^([A-Za-z0-9_]+)$/ =~ name).nil?
    raise ArgumentError, 'container name is invalid'
  end

  if ip_address.nil? || ip_address.empty? || (/^#{Resolv::IPv4::Regex}$/ =~ ip_address).nil?
    raise ArgumentError, 'the submitted ip address is not a valid ipv4 address'
  end

  if @adapter.exist?(name)
    raise ::NotFoundError
  end

  @adapter.create_container(name, ip_address, disk_size_gb, memory_limit_mb, cpu_core_count)
end