summaryrefslogtreecommitdiffstats
path: root/apex/common/utils.py
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2018-08-02 23:49:00 -0400
committerTim Rozet <trozet@redhat.com>2018-08-23 18:01:16 -0400
commit4301e4cb3bd6f62caec575d30e8588b72ac626c7 (patch)
tree31f6ca88598c12d45f578a6a25b5c3b86c7d5dad /apex/common/utils.py
parentdc83fb1667a1a65ad333a3aab1c2843601180b23 (diff)
Adds deployment via snapshot
New arguments are added to allow snapshot deployment: --snapshot, --snap-cache The previous tripleo-quickstart code has been removed/replaced with the snapshot option. Snapshot deployments are supported on CentOS and Fedora, and snapshot artifacts use a similar caching system as the standard deployment. Snapshots are produced daily by Apex, and include latest as well as n-1 OpenStack versions. The os-odl-nofeature scenario is used for the snapshots. Additionally multiple topology verions of Snapshots are available. The Snapshot pulled at deploy time depends on the deploy-settings and number of virtual-computes used at deploy time. Since there is only one network used with snapshot deployments (admin), there is no reason to pass in network settings for snapshot deployments. That argument is now optional. Previously we required even in Standard virtual deployments that the network settings be provided. However that is also unnecessary, as we can default to the virtual network settings. Includes minor fix to the tox.ini to allow specifying test cases to run (useful for developers writing tests). Default behavior of tox is unchanged. JIRA: APEX-548 Change-Id: I1e08c4e54eac5aae99921f61ab7f69693ed12b47 Signed-off-by: Tim Rozet <trozet@redhat.com>
Diffstat (limited to 'apex/common/utils.py')
-rw-r--r--apex/common/utils.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/apex/common/utils.py b/apex/common/utils.py
index 464aaf28..aae821ef 100644
--- a/apex/common/utils.py
+++ b/apex/common/utils.py
@@ -218,7 +218,7 @@ def fetch_upstream_and_unpack(dest, url, targets, fetch=True):
if download_target:
urllib.request.urlretrieve(target_url, filename=target_dest)
logging.info("Target downloaded: {}".format(target))
- if target.endswith('.tar'):
+ if target.endswith(('.tar', 'tar.gz', 'tgz')):
logging.info('Unpacking tar file')
tar = tarfile.open(target_dest)
tar.extractall(path=dest)
@@ -255,9 +255,9 @@ def open_webpage(url, timeout=5):
try:
response = urllib.request.urlopen(url, timeout=timeout)
return response.read()
- except (urllib.request.URLError, socket.timeout):
+ except (urllib.request.URLError, socket.timeout) as e:
logging.error("Unable to open URL: {}".format(url))
- raise
+ raise exc.FetchException('Unable to open URL') from e
def edit_tht_env(env_file, section, settings):
@@ -281,3 +281,32 @@ def unique(tmp_list):
if x not in uniq_list:
uniq_list.append(x)
return uniq_list
+
+
+def bash_settings_to_dict(data):
+ """
+ Parses bash settings x=y and returns dict of key, values
+ :param data: bash settings data in x=y format
+ :return: dict of keys and values
+ """
+ return dict(item.split('=') for item in data.splitlines())
+
+
+def fetch_properties(url):
+ """
+ Downloads OPNFV properties and returns a dictionary of the key, values
+ :param url: URL of properties file
+ :return: dict of k,v for each properties
+ """
+ if bool(urllib.parse.urlparse(url).scheme):
+ logging.debug('Fetching properties from internet: {}'.format(url))
+ return bash_settings_to_dict(open_webpage(url).decode('utf-8'))
+ elif os.path.isfile(url):
+ logging.debug('Fetching properties from file: {}'.format(url))
+ with open(url, 'r') as fh:
+ data = fh.read()
+ return bash_settings_to_dict(data)
+ else:
+ logging.warning('Unable to fetch properties for: {}'.format(url))
+ raise exc.FetchException('Unable determine properties location: '
+ '{}'.format(url))