The code changes are primarily required when the runtime environment is Windows.
JIRA: SNAPS-75
Change-Id: Ia2134861dd96e1d2c4b597f42fb348929e787a51
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
::
- sudo yum install -7 git gcc python-pip python-devel openssl-devel
+ sudo yum -y update
+ sudo yum install -y epel-release
+ sudo yum install -y git gcc python-pip python-devel openssl-devel
+ sudo pip install --upgrade pip
-Ubuntu
-------
+Ubuntu 14.04
+------------
::
- sudo apt-get install git python2.7-dev libssl-dev
+ sudo apt-get install git python2.7-dev libssl-dev python-pip
+ sudo apt-get install corkscrew (optional for SSH over an HTTP proxy)
+
+Ubuntu 16.04
+------------
+::
+
+ sudo apt install python git python2.7-dev libssl-dev python-pip
+ sudo apt install corkscrew (optional for SSH over an HTTP proxy)
+
+Windows Server 2012
+-------------------
+::
+
+ Install Python 2.7.x
+ Install Git
+ Install Microsoft Visual C++ Compiler for Python 2.7
+
+ Cannot SSH from behind a proxy in the 'cmd' shell as corkscrew is only available for Cygwin
+ Ansible functionality is not working on windows as an exception is being thrown while importing the packages
Optional: Setup a Python virtual environment
--------------------------------------------
::
+ git clone https://gerrit.opnfv.org/gerrit/snaps
sudo pip install -e <path to repo>/snaps/
+ (note: on CentOS 7 and Ubuntu 14.04 you may have to try the previous command several times)
The install should now be complete and you can start using the SNAPS-OO libraries.
dest = dest_path + '/' + name
logger.debug('Downloading file from - ' + url)
# Override proxy settings to use localhost to download file
- with open(dest, 'wb') as f:
- logger.debug('Saving file to - ' + dest)
- response = __get_url_response(url)
- f.write(response.read())
- return f
+ f = None
+ try:
+ with open(dest, 'wb') as f:
+ logger.debug('Saving file to - ' + dest)
+ response = __get_url_response(url)
+ f.write(response.read())
+ return f
+ finally:
+ if f:
+ f.close()
def get_content_length(url):
pass
self.__keypair = None
+ if self.keypair_settings.public_filepath:
+ os.chmod(self.keypair_settings.public_filepath, 0o777)
+ os.remove(self.keypair_settings.public_filepath)
+ if self.keypair_settings.private_filepath:
+ os.chmod(self.keypair_settings.private_filepath, 0o777)
+ os.remove(self.keypair_settings.private_filepath)
+
def get_keypair(self):
"""
Returns the OpenStack keypair object
:raise Exception if using a file and it cannot be found
"""
cleanup_temp_file = False
+ image_file = None
if image_settings.image_file:
image_filename = image_settings.image_file
elif image_settings.url:
- image_file = file_utils.download(image_settings.url, '/tmp', str(uuid.uuid4()))
- image_filename = image_file.name
+ file_name = str(uuid.uuid4())
+ try:
+ image_file = file_utils.download(image_settings.url, './tmp', file_name)
+ image_filename = image_file.name
+ except:
+ os.remove('./tmp/' + file_name)
+ raise
+
cleanup_temp_file = True
else:
raise Exception('Filename or URL of image not configured')
delete_image(glance, created_image)
raise
finally:
+ if image_file:
+ image_file.close()
if cleanup_temp_file:
os.remove(image_filename)
pass
try:
+ os.chmod(self.priv_key_file_path, 0o777)
os.remove(self.priv_key_file_path)
except:
pass
try:
+ os.chmod(self.pub_key_file_path, 0o777)
os.remove(self.pub_key_file_path)
except:
pass
"""
nova_utils.save_keys_to_files(self.keys, self.pub_key_file_path, self.priv_key_file_path)
self.keypair = nova_utils.upload_keypair_file(self.nova, self.keypair_name, self.pub_key_file_path)
- pub_key = open(os.path.expanduser(self.pub_key_file_path)).read()
+ pub_key_file = open(os.path.expanduser(self.pub_key_file_path))
+ pub_key = pub_key_file.read()
+ pub_key_file.close()
self.assertEqual(self.keypair.public_key, pub_key)
def test_floating_ips(self):
import os
import paramiko
-from ansible.parsing.dataloader import DataLoader
-from ansible.vars import VariableManager
-from ansible.inventory import Inventory
-from ansible.executor.playbook_executor import PlaybookExecutor
+try:
+ from ansible.parsing.dataloader import DataLoader
+ from ansible.vars import VariableManager
+ from ansible.inventory import Inventory
+ from ansible.executor.playbook_executor import PlaybookExecutor
+except:
+ pass
__author__ = 'spisarski'