class Vanagon::Platform::DSL
Public Class Methods
Public Instance Methods
Accessor for the platform.
@return [Vanagon::Platform] the platform the DSL
methods will be acting against
# File lib/vanagon/platform/dsl.rb, line 68 def _platform @platform end
Set
the name of this platform as always-be-scheduling (ABS) expects it
@param name [String] name of the platform to request from always-be-scheduling
# File lib/vanagon/platform/dsl.rb, line 311 def abs_resource_name(resource_name) @platform.abs_resource_name = resource_name end
Generic adder for build repositories
@param *args [Array<String>] List of arguments to pass on to the platform specific method @raise [Vanagon::Error] an arror is raised if the current platform does not define add_repository
# File lib/vanagon/platform/dsl.rb, line 465 def add_build_repository(*args) @platform.add_build_repository(*args) end
Helper to setup a apt repository on a target system
@param definition [String] the repo setup file, must be a valid uri, fetched with curl @param gpg_key [String] optional gpg key to be fetched via curl and installed @deprecated Please use the add_build_repository
DSL
method instead. apt_repo
will be removed in a future vanagon release.
# File lib/vanagon/platform/dsl.rb, line 438 def apt_repo(definition, gpg_key = nil) VanagonLogger.info "Please use the add_build_repository DSL method instead. apt_repo will be removed in a future vanagon release." self.add_build_repository(definition, gpg_key) end
Set
the ami for the platform to use
@param ami [String] the ami id used.
# File lib/vanagon/platform/dsl.rb, line 343 def aws_ami(ami_name) @platform.aws_ami = ami_name end
Set
the instaince type. This defaults to t1.micro which is the free instance
@param instance_type [String] a string to define the instaince type
# File lib/vanagon/platform/dsl.rb, line 378 def aws_instance_type(instance_type = 't1.micro') @platform.aws_instance_type = instance_type end
Set
the key_name used. This should already exist on AWS.
@param key_name [String] this defaults to the keyname vanagon. Can be set to any
# File lib/vanagon/platform/dsl.rb, line 371 def aws_key_name(key_name = 'vanagon') @platform.aws_key_name = key_name end
Set
the region, this defaults to us-east-1
@param region [String] a string used to setup the region
# File lib/vanagon/platform/dsl.rb, line 357 def aws_region(region = 'us-east-1') @platform.aws_region = region end
Set
the shutdown behavior for aws. This will default to terminate the instance on shutdown
@param shutdown_behavior [String] a string used to set the shutdown behavior
# File lib/vanagon/platform/dsl.rb, line 364 def aws_shutdown_behavior(shutdown_behavior = 'terminate') @platform.aws_shutdown_behavior = shutdown_behavior end
Set
the user data used in AWS to do setup. Like cloud-config
@param userdata [String] a string used to send to the node to do the intial setup
# File lib/vanagon/platform/dsl.rb, line 350 def aws_user_data(userdata) @platform.aws_user_data = userdata end
Set
the path to Homebrew for the platform
@param brew_cmd [String] Absolute path to Homebrew for the platform
# File lib/vanagon/platform/dsl.rb, line 171 def brew(brew_cmd) @platform.brew = brew_cmd end
Set
the list of possible host to perform a build on (when not using pooler or CLI
flags)
@param type [Array] the names of the hosts (must be resolvable) @rase ArgumentError if builds_hosts has no arguments
# File lib/vanagon/platform/dsl.rb, line 284 def build_hosts(*args) raise ArgumentError, "build_hosts requires at least one host to be a build target." if args.empty? @platform.build_hosts = Array(args).flatten end
Clears the provisioning commands array
# File lib/vanagon/platform/dsl.rb, line 231 def clear_provisioning @platform.provisioning.clear end
Set
any codename this platform may have (debian for example)
@param codename [String] codename for this platform (squeeze for example)
# File lib/vanagon/platform/dsl.rb, line 421 def codename(codename) @platform.codename = codename end
Set
the path to copy for the platform
@param copy_cmd [String] Full path to the copy command for the platform
# File lib/vanagon/platform/dsl.rb, line 164 def copy(copy_cmd) @platform.copy = copy_cmd end
Set
the cross_compiled
flag for the platform
@param xcc [Boolean] True if this is a cross-compiled platform
# File lib/vanagon/platform/dsl.rb, line 178 def cross_compiled(xcc_flag) @platform.cross_compiled = !!xcc_flag end
Set
the directory where default or sysconfig files live for the platform
@param dir [String] Directory where default or sysconfig files live on the platform
# File lib/vanagon/platform/dsl.rb, line 258 def defaultdir(dir) @platform.defaultdir = dir end
define an explicit Dist for the platform (most likely used for RPM
platforms)
@param dist_string [String] the value to use for .dist when building RPMs
# File lib/vanagon/platform/dsl.rb, line 185 def dist(dist_string) @platform.dist = dist_string end
Set
the name of the docker image to use
@param name [String] name of the docker image to use
# File lib/vanagon/platform/dsl.rb, line 318 def docker_image(image_name) @platform.docker_image = image_name end
Set
the path to find for the platform
@param find_cmd [String] Full path to the find command for the platform
# File lib/vanagon/platform/dsl.rb, line 143 def find(find_cmd) @platform.find = find_cmd end
# File lib/vanagon/platform/dsl.rb, line 94 def inherit_from_default(name = @name) default_file = File.join(__dir__, 'defaults', "#{name}.rb") default_object = Vanagon::Platform::DSL.new(name) @platform = default_object.instance_eval(File.read(default_file), default_file, 1) end
Set
the path to the install command @param install_cmd [String] Full path to install with arguments to be used by default
# File lib/vanagon/platform/dsl.rb, line 198 def install(install_cmd) @platform.install = install_cmd end
Set
the command to install any needed build dependencies for the target machine
@param command [String] Command to install build dependencies for the target machine @param suffix [String] shell to be run after the main command
# File lib/vanagon/platform/dsl.rb, line 239 def install_build_dependencies_with(command, suffix = nil) @platform.build_dependencies = OpenStruct.new({ :command => command, :suffix => suffix }) end
Set
the path to make for the platform
@param make_cmd [String] Full path to the make command for the platform
# File lib/vanagon/platform/dsl.rb, line 111 def make(make_cmd) @platform.make = make_cmd end
All purpose getter. This object, which is passed to the platform block, won’t have easy access to the attributes of the @platform, so we make a getter for each attribute.
We only magically handle get_ methods, any other methods just get the standard method_missing
treatment.
# File lib/vanagon/platform/dsl.rb, line 79 def method_missing(method_name, *args) attribute_match = method_name.to_s.match(/get_(.*)/) if attribute_match attribute = attribute_match.captures.first else super end @platform.send(attribute) end
Set
the path and options for the mktemp command @param command [String] Full path (if needed) for the mktemp command with arguments to be used by default
# File lib/vanagon/platform/dsl.rb, line 205 def mktemp(command) @platform.mktemp = command end
Sets the command to retrieve the number of cores available on a platform.
@param num_cores_cmd [String] the command to retrieve the number of available cores on a platform.
# File lib/vanagon/platform/dsl.rb, line 219 def num_cores(num_cores_cmd) @platform.num_cores = num_cores_cmd end
# File lib/vanagon/platform/dsl.rb, line 425 def output_dir(directory) @platform.output_dir = directory end
Set
the type of package we are going to build for this platform
@param pkg_type [String] The type of package we are going to build for this platform
# File lib/vanagon/platform/dsl.rb, line 136 def package_type(pkg_type) @platform.package_type = pkg_type end
Set
the path to patch for the platform
@param patch_cmd [String] Full path to the patch command for the platform
# File lib/vanagon/platform/dsl.rb, line 212 def patch(patch_cmd) @platform.patch = patch_cmd end
Primary way of interacting with the DSL
. Also a simple factory to get the right platform object.
@param platform_name [String] name of the platform @param override_name [Boolean] whether the specified ‘platform_name` should override the basename @param block [Proc] DSL
definition of the platform to call
# File lib/vanagon/platform/dsl.rb, line 32 def platform(platform_name, override_name: false, &block) # By default, the Vanagon::Platform's name/version/arch will be based on # the filename of the platform definition. But if override_name is true, # then use the `platform_name` passed into this method instead. @name = platform_name if override_name @platform = case platform_name when /^aix-/ Vanagon::Platform::RPM::AIX.new(@name) when /^(amazon|cisco-wrlinux|el|fedora|redhat|redhatfips)-/ Vanagon::Platform::RPM.new(@name) when /^sles-/ Vanagon::Platform::RPM::SLES.new(@name) when /^(cumulus|debian|huaweios|ubuntu)-/ Vanagon::Platform::DEB.new(@name) when /^eos-/ Vanagon::Platform::RPM::EOS.new(@name) when /^osx-/ Vanagon::Platform::OSX.new(@name) when /^solaris-10/ Vanagon::Platform::Solaris10.new(@name) when /^solaris-11/ Vanagon::Platform::Solaris11.new(@name) when /^windows/ Vanagon::Platform::Windows.new(@name) else fail "Platform not implemented for '#{@name}' yet. Please go do so..." end yield(self) @platform end
Set
the platform_triple
for the platform
@param triple platform_triple
for use in building out compiled tools and cross-compilation
# File lib/vanagon/platform/dsl.rb, line 414 def platform_triple(triple) @platform.platform_triple = triple end
Set
the command to turn the target machine into a builder for vanagon
@param command [String] Command to enable the target machine to build packages for the platform
# File lib/vanagon/platform/dsl.rb, line 226 def provision_with(command) @platform.provision_with(command) end
# File lib/vanagon/platform/dsl.rb, line 90 def respond_to_missing?(method_name, include_private = false) method_name.to_s.start_with?('get_') || super end
Set
the path to rpmbuild for the platform
@param rpmbuild_cmd [String] Full path to rpmbuild with arguments to be used by default
# File lib/vanagon/platform/dsl.rb, line 192 def rpmbuild(rpmbuild_cmd) @platform.rpmbuild = rpmbuild_cmd end
Set
the path to sed for the platform
@param command [String] full path to the sed command for the platform
# File lib/vanagon/platform/dsl.rb, line 150 def sed(command) @platform.sed = command end
Set
the directory where service files or init scripts live for the platform
@param dir [String] Directory where service files live on the platform
# File lib/vanagon/platform/dsl.rb, line 246 def servicedir(dir) @platform.servicedir = dir # Add to the servicetypes array if we haven't already if @platform.servicetype && @platform.servicedir && @platform.servicetypes.select { |s| s.servicetype == @platform.servicetype }.empty? @platform.servicetypes << OpenStruct.new(:servicetype => @platform.servicetype, :servicedir => @platform.servicedir) end end
Set
the servicetype for the platform so that services can be installed correctly.
@param type [String] service type for the platform (‘sysv’ for example) @param servicedir [String] service dir for this platform and service type (‘/etc/init.d’ for example). Optional.
# File lib/vanagon/platform/dsl.rb, line 266 def servicetype(type, servicedir: nil) # rubocop:disable Metrics/AbcSize if servicedir @platform.servicetypes << OpenStruct.new(:servicetype => type, :servicedir => servicedir) else @platform.servicetype = type end # Add to the servicetypes array if we haven't already if @platform.servicetype && @platform.servicedir && @platform.servicetypes.select { |s| s.servicetype == @platform.servicetype }.empty? @platform.servicetypes << OpenStruct.new(:servicetype => @platform.servicetype, :servicedir => @platform.servicedir) end end
# File lib/vanagon/platform/dsl.rb, line 469 def setting(name, value) @platform.settings[name] = value end
# File lib/vanagon/platform/dsl.rb, line 473 def settings @platform.settings end
# File lib/vanagon/platform/dsl.rb, line 129 def shasum(sha1sum_command) @platform.shasum = sha1sum_command end
Set
the path for Make’s SHELL for the platform
@param shell_path [String] Full path to the shell Make should use
# File lib/vanagon/platform/dsl.rb, line 118 def shell(shell_path) @platform.shell = shell_path end
Set
the path to sort for the platform
@param sort_cmd [String] Full path to the sort command for the platform
# File lib/vanagon/platform/dsl.rb, line 157 def sort(sort_cmd) @platform.sort = sort_cmd end
# File lib/vanagon/platform/dsl.rb, line 429 def source_output_dir(directory) @platform.source_output_dir = directory end
Set
the port for ssh to use if it’s not 22
@param port [Integer] port number for ssh
# File lib/vanagon/platform/dsl.rb, line 392 def ssh_port(port = 22) @platform.ssh_port = port end
Set
the path to tar for the platform
@param tar [String] Full path to the tar command for the platform
# File lib/vanagon/platform/dsl.rb, line 125 def tar(tar_cmd) @platform.tar = tar_cmd end
Set
the target ip address or hostname to start build
@param target_host a host string to login with.
# File lib/vanagon/platform/dsl.rb, line 406 def target_host(target_host) @platform.target_host = target_host end
Specify whether to use Docker exec instead of SSH to run commands
This also causes Vanagon
to use ‘docker cp` instead of `rsync` when copying files.
@param bool [Boolean] a boolean value indicating whether to use
`docker exec` and `docker cp` over `ssh` and `rsync`.
# File lib/vanagon/platform/dsl.rb, line 336 def use_docker_exec(bool) @platform.use_docker_exec = bool end
Set
the name of this platform as the vm pooler expects it
@param name [String] name that the pooler uses for this platform @deprecated Please use vmpooler_template
instead, this will be removed in a future vanagon release.
# File lib/vanagon/platform/dsl.rb, line 303 def vcloud_name(cloud_name) VanagonLogger.info "vcloud_name is a deprecated platform DSL method, and will be removed in a future vanagon release. Please use vmpooler_template instead." self.vmpooler_template(cloud_name) end
Set
the name of this platform as the vm pooler expects it
@param name [String] name of the target template to use from the vmpooler
# File lib/vanagon/platform/dsl.rb, line 295 def vmpooler_template(template_name) @platform.vmpooler_template = template_name end
Helper to setup a yum repository on a target system
@param definition [String] the repo setup URI or RPM
file @deprecated Please use the add_build_repository
DSL
method instead. yum_repo
will be removed in a future vanagon release.
# File lib/vanagon/platform/dsl.rb, line 447 def yum_repo(definition) VanagonLogger.info "Please use the add_build_repository DSL method instead. yum_repo will be removed in a future vanagon release." self.add_build_repository(definition) end
Helper to setup a zypper repository on a target system
@param definition [String] the repo setup URI or RPM
file @deprecated Please use the add_build_repository
DSL
method instead. zypper_repo
will be removed in a future vanagon release.
# File lib/vanagon/platform/dsl.rb, line 456 def zypper_repo(definition) VanagonLogger.info "Please use the add_build_repository DSL method instead. zypper_repo will be removed in a future vanagon release." self.add_build_repository(definition) end