summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Giuliani <giuliani.v@gmail.com>2014-05-30 23:46:42 +0200
committerVito Giuliani <giuliani.v@gmail.com>2014-05-30 23:46:42 +0200
commitd585ebc96c291d29ba9dc01e458398c288ac1bdb (patch)
tree2a0a85c976d52ed5a275107d6c0b1c2ea8180212
parent6c216502a996fc51f04002dc1c09544c22862ea9 (diff)
downloadgoogle-compute-image-packages-d585ebc96c291d29ba9dc01e458398c288ac1bdb.tar.gz
Pass the result of the function call as an argument in place of a callable
-rw-r--r--gcimagebundle/gcimagebundlelib/fs_copy.py4
-rwxr-xr-xgcimagebundle/gcimagebundlelib/manifest.py6
-rwxr-xr-xgcimagebundle/gcimagebundlelib/tests/block_disk_test.py2
-rwxr-xr-xgcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py2
4 files changed, 8 insertions, 6 deletions
diff --git a/gcimagebundle/gcimagebundlelib/fs_copy.py b/gcimagebundle/gcimagebundlelib/fs_copy.py
index 8989539..9924414 100644
--- a/gcimagebundle/gcimagebundlelib/fs_copy.py
+++ b/gcimagebundle/gcimagebundlelib/fs_copy.py
@@ -22,6 +22,7 @@ import os
import re
from gcimagebundlelib import manifest
+from gcimagebundlelib import utils
class FsCopyError(Exception):
@@ -48,7 +49,8 @@ class FsCopy(object):
self._overwrite_list = []
self._scratch_dir = '/tmp'
self._disk = None
- self._manifest = manifest.ImageManifest()
+ is_running_on_gce = utils.IsRunningOnGCE()
+ self._manifest = manifest.ImageManifest(is_running_on_gce)
def SetTarfile(self, tar_file):
"""Sets tar file which will contain file system copy.
diff --git a/gcimagebundle/gcimagebundlelib/manifest.py b/gcimagebundle/gcimagebundlelib/manifest.py
index cc7dc2c..df16741 100755
--- a/gcimagebundle/gcimagebundlelib/manifest.py
+++ b/gcimagebundle/gcimagebundlelib/manifest.py
@@ -29,10 +29,10 @@ class ImageManifest(object):
- Licenses
"""
- def __init__(self, http=utils.Http(), isProviderGCE=utils.IsRunningOnGCE):
+ def __init__(self, isGceInstance, http=utils.Http()):
self._http = http
self._licenses = []
- self._isProviderGCE = isProviderGCE
+ self._is_gce_instance = isGceInstance
def CreateIfNeeded(self, file_path):
"""Creates the manifest file to the specified path if it's needed.
@@ -44,7 +44,7 @@ class ImageManifest(object):
True Manifest was written to file_path.
False Manifest was not created.
"""
- if self._isProviderGCE():
+ if self._is_gce_instance:
self._LoadLicenses()
if self._IsManifestNeeded():
with open(file_path, 'w') as manifest_file:
diff --git a/gcimagebundle/gcimagebundlelib/tests/block_disk_test.py b/gcimagebundle/gcimagebundlelib/tests/block_disk_test.py
index 692e915..1f7f994 100755
--- a/gcimagebundle/gcimagebundlelib/tests/block_disk_test.py
+++ b/gcimagebundle/gcimagebundlelib/tests/block_disk_test.py
@@ -285,7 +285,7 @@ class FsRawDiskTest(image_bundle_test_base.ImageBundleTest):
self._http = MockHttp()
self._manifest._http = self._http
- self._manifest._isProviderGCE = lambda: False
+ self._manifest._is_gce_instance = False
self._bundle.AddSource(self.tmp_path)
self._bundle.Verify()
diff --git a/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py b/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py
index bbc6eb0..272a760 100755
--- a/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py
+++ b/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py
@@ -87,7 +87,7 @@ class ImageBundleTest(unittest.TestCase):
self.tmp_root = tempfile.mkdtemp(dir='/tmp')
self.tmp_path = tempfile.mkdtemp(dir=self.tmp_root)
self._http = MockHttp()
- self._manifest = manifest.ImageManifest(http=self._http, isProviderGCE=lambda: True)
+ self._manifest = manifest.ImageManifest(True, http=self._http)
self._SetupFilesystemToTar()
def tearDown(self):