Module: Unix::File
Instance Attribute Summary
Attributes included from Beaker::CommandFactory
Instance Method Summary collapse
- #file_exist?(path) ⇒ Boolean
-
#noask_file_text ⇒ String
Returns the noask file text for Solaris hosts.
-
#package_config_dir ⇒ String
Gets the config dir location for package information.
- #path_split(paths) ⇒ Object
-
#repo_filename(package_name, build_version) ⇒ String
Returns the repo filename for a given package & version for a platform.
-
#repo_type ⇒ String
Gets the repo type for the given platform.
-
#scp_path(path) ⇒ String
Handles any changes needed in a path for SCP.
- #system_temp_path ⇒ Object
- #tmpdir(name) ⇒ Object
- #tmpfile(name) ⇒ Object
Methods included from Beaker::CommandFactory
Instance Method Details
#file_exist?(path) ⇒ Boolean
30 31 32 33 |
# File 'lib/beaker/host/unix/file.rb', line 30 def file_exist?(path) result = exec(Beaker::Command.new("test -e #{path}"), :acceptable_exit_codes => [0, 1]) result.exit_code == 0 end |
#noask_file_text ⇒ String
Returns the noask file text for Solaris hosts
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/beaker/host/unix/file.rb', line 121 def noask_file_text variant, version, arch, codename = self['platform'].to_array if variant == 'solaris' && version == '10' noask = <<NOASK # Write the noask file to a temporary directory # please see man -s 4 admin for details about this file: # http://www.opensolarisforum.org/man/man4/admin.html # # The key thing we don't want to prompt for are conflicting files. # The other nocheck settings are mostly defensive to prevent prompts # We _do_ want to check for available free space and abort if there is # not enough mail= # Overwrite already installed instances instance=overwrite # Do not bother checking for partially installed packages partial=nocheck # Do not bother checking the runlevel runlevel=nocheck # Do not bother checking package dependencies (We take care of this) idepend=nocheck rdepend=nocheck # DO check for available free space and abort if there isn't enough space=quit # Do not check for setuid files. setuid=nocheck # Do not check if files conflict with other packages conflict=nocheck # We have no action scripts. Do not check for them. action=nocheck # Install to the default base directory. basedir=default NOASK else msg = "noask file text unknown for platform '#{self['platform']}'" raise ArgumentError, msg end noask end |
#package_config_dir ⇒ String
Gets the config dir location for package information
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/beaker/host/unix/file.rb', line 40 def package_config_dir case self['platform'] when /fedora|el-|centos/ '/etc/yum.repos.d/' when /sles/ '/etc/zypp/repos.d/' when /debian|ubuntu|cumulus|huaweios/ '/etc/apt/sources.list.d' else msg = "package config dir unknown for platform '#{self['platform']}'" raise ArgumentError, msg end end |
#path_split(paths) ⇒ Object
26 27 28 |
# File 'lib/beaker/host/unix/file.rb', line 26 def path_split(paths) paths.split(':') end |
#repo_filename(package_name, build_version) ⇒ String
Returns the repo filename for a given package & version for a platform
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/beaker/host/unix/file.rb', line 62 def repo_filename(package_name, build_version) variant, version, arch, codename = self['platform'].to_array repo_filename = "pl-%s-%s-" % [ package_name, build_version ] case variant when /fedora|el|centos|cisco_nexus|cisco_ios_xr|sles/ variant = 'el' if variant == 'centos' if variant == 'cisco_nexus' variant = 'cisco-wrlinux' version = '5' end if variant == 'cisco_ios_xr' variant = 'cisco-wrlinux' version = '7' end fedora_prefix = ((variant == 'fedora') ? 'f' : '') pattern = "%s-%s%s-%s.repo" pattern = "repos-pe-#{pattern}" if self.is_pe? repo_filename << pattern % [ variant, fedora_prefix, version, arch ] when /debian|ubuntu|cumulus|huaweios/ codename = variant if variant == 'cumulus' || variant == 'huaweios' repo_filename << "%s.list" % [ codename ] else msg = "#repo_filename: repo filename pattern not known for platform '#{self['platform']}'" raise ArgumentError, msg end repo_filename end |
#repo_type ⇒ String
Gets the repo type for the given platform
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/beaker/host/unix/file.rb', line 104 def repo_type case self['platform'] when /fedora|el-|centos|sles/ 'rpm' when /debian|ubuntu|cumulus|huaweios/ 'deb' else msg = "#repo_type: repo type not known for platform '#{self['platform']}'" raise ArgumentError, msg end end |
#scp_path(path) ⇒ String
Handles any changes needed in a path for SCP
22 23 24 |
# File 'lib/beaker/host/unix/file.rb', line 22 def scp_path(path) path end |
#system_temp_path ⇒ Object
12 13 14 |
# File 'lib/beaker/host/unix/file.rb', line 12 def system_temp_path '/tmp' end |
#tmpdir(name) ⇒ Object
8 9 10 |
# File 'lib/beaker/host/unix/file.rb', line 8 def tmpdir(name) execute("mktemp -dt #{name}.XXXXXX") end |
#tmpfile(name) ⇒ Object
4 5 6 |
# File 'lib/beaker/host/unix/file.rb', line 4 def tmpfile(name) execute("mktemp -t #{name}.XXXXXX") end |