Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy config fixup for bad merge. #337

Merged
merged 1 commit into from
Jun 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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