Skip to content

Commit

Permalink
Proxy config fixup for bad merge.
Browse files Browse the repository at this point in the history
The previous proxy config patch erroneously applied changes to the deleted
file package_managers.py, reviving it in the process. Delete it again, and
apply its changes to linux_virtual_machine.py.
  • Loading branch information
klausw committed Jun 23, 2015
1 parent 0391cc0 commit b8e2771
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 342 deletions.
48 changes: 48 additions & 0 deletions perfkitbenchmarker/linux_virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from perfkitbenchmarker import virtual_machine
from perfkitbenchmarker import vm_util

FLAGS = flags.FLAGS

EPEL6_RPM = ('http://dl.fedoraproject.org/pub/epel/'
'6/x86_64/epel-release-6-8.noarch.rpm')
Expand Down Expand Up @@ -153,7 +154,28 @@ def RobustRemoteCommand(self, command):
'--delete']
return self.RemoteCommand(' '.join(wait_command), should_log=False)

def SetupProxy(self):
"""Sets up proxy configuration variables for the cloud environment."""
env_file = "/etc/environment"
commands = []

if FLAGS.http_proxy:
commands.append("echo 'http_proxy=%s' | sudo tee -a %s" % (
FLAGS.http_proxy, env_file))

if FLAGS.https_proxy:
commands.append("echo 'https_proxy=%s' | sudo tee -a %s" % (
FLAGS.https_proxy, env_file))

if FLAGS.ftp_proxy:
commands.append("echo 'ftp_proxy=%s' | sudo tee -a %s" % (
FLAGS.ftp_proxy, env_file))

if commands:
self.RemoteCommand(";".join(commands))

def OnStartup(self):
self.SetupProxy()
if self.is_static and self.install_packages:
self.SnapshotPackages()
self.BurnCpu()
Expand Down Expand Up @@ -572,6 +594,15 @@ def GetServiceName(self, package_name):
package = packages.PACKAGES[package_name]
return package.YumGetServiceName(self)

def SetupProxy(self):
"""Sets up proxy configuration variables for the cloud environment."""
super(RhelMixin, self).SetupProxy()
yum_proxy_file = "/etc/yum.conf"

if FLAGS.http_proxy:
self.RemoteCommand("echo -e 'proxy= \"%s\";' | sudo tee -a %s" % (
FLAGS.http_proxy, yum_proxy_file))


class DebianMixin(BaseLinuxMixin):
"""Class holding Debian specific VM methods and attributes."""
Expand Down Expand Up @@ -660,3 +691,20 @@ def GetServiceName(self, package_name):
"""
package = packages.PACKAGES[package_name]
return package.AptGetServiceName(self)

def SetupProxy(self):
"""Sets up proxy configuration variables for the cloud environment."""
super(DebianMixin, self).SetupProxy()
apt_proxy_file = "/etc/apt/apt.conf"
commands = []

if FLAGS.http_proxy:
commands.append("echo -e 'Acquire::http::proxy \"%s\";' |"
'sudo tee -a %s' % (FLAGS.http_proxy, apt_proxy_file))

if FLAGS.https_proxy:
commands.append("echo -e 'Acquire::https::proxy \"%s\";' |"
'sudo tee -a %s' % (FLAGS.https_proxy, apt_proxy_file))

if commands:
self.RemoteCommand(";".join(commands))
Loading

0 comments on commit b8e2771

Please sign in to comment.