Add pre-flight check for device pristinity

Add `non-pristine` key to `list-disks` action.

No longer attempt to do initializtion of `osd-journal` devices.

Make py27 test noop

Flip pep8 test to py3

Partial-Bug: #1698154
Change-Id: I0ca574fa7f0683b4e8a693b9f62fbf6b39689789
Depends-On: I90a866aa138d18e4242783c42d4c7c587f696d7d
This commit is contained in:
Frode Nordahl
2018-06-01 12:15:01 +02:00
parent bebf8601c9
commit 352d699387
9 changed files with 252 additions and 115 deletions

View File

@@ -12,8 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import socket
import re
import os
import socket
from charmhelpers.core.hookenv import (
unit_get,
cached,
@@ -22,6 +24,8 @@ from charmhelpers.core.hookenv import (
log,
DEBUG,
status_set,
storage_get,
storage_list,
)
from charmhelpers.core import unitdata
from charmhelpers.fetch import (
@@ -39,6 +43,7 @@ from charmhelpers.contrib.network.ip import (
get_ipv6_addr
)
TEMPLATES_DIR = 'templates'
try:
@@ -213,3 +218,17 @@ def get_blacklist():
"""Get blacklist stored in the local kv() store"""
db = unitdata.kv()
return db.get('osd-blacklist', [])
def get_journal_devices():
if config('osd-journal'):
devices = [l.strip() for l in config('osd-journal').split(' ')]
else:
devices = []
storage_ids = storage_list('osd-journals')
devices.extend((storage_get('location', s) for s in storage_ids))
# Filter out any devices in the action managed unit-local device blacklist
_blacklist = get_blacklist()
return set(device for device in devices
if device not in _blacklist and os.path.exists(device))