1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Unbreak beadm module (#1105)

* Unbreak beadm module

* Add a changelog fragment

* Module beadm.py: remove regex, use split() everywhere, fix array indexes.

* Fix typos

* Change array indexes for BE name - according to Oracle documents, the name of BE is in the first column of beadm output on Solaris.

* Add 'None' checks in beadm.py
This commit is contained in:
Пётр 2020-10-31 13:51:10 +01:00 committed by GitHub
parent 282c1d546c
commit 20ca01e486
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 13 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- beadm - fixed issue "list object has no attribute split" (https://github.com/ansible-collections/community.general/issues/791).

View file

@ -165,20 +165,29 @@ class BE(object):
if '@' in self.name: if '@' in self.name:
for line in out.splitlines(): for line in out.splitlines():
if self.is_freebsd: if self.is_freebsd:
check = re.match(r'.+/({0})\s+\-'.format(self.name), line) check = line.split()
if check: if(check == []):
continue
full_name = check[0].split('/')
if(full_name == []):
continue
check[0] = full_name[len(full_name) - 1]
if check[0] == self.name:
return check return check
else: else:
check = line.split(';') check = line.split(';')
if check[1] == self.name: if check[0] == self.name:
return check return check
else: else:
splitter = '\t' if self.is_freebsd else ';'
for line in out.splitlines(): for line in out.splitlines():
check = line.split(splitter) if self.is_freebsd:
if check[0] == self.name: check = line.split()
return check if check[0] == self.name:
return check
else:
check = line.split(';')
if check[0] == self.name:
return check
return None return None
def exists(self): def exists(self):
@ -197,11 +206,13 @@ class BE(object):
if rc == 0: if rc == 0:
line = self._find_be_by_name(out) line = self._find_be_by_name(out)
if line is None:
return False
if self.is_freebsd: if self.is_freebsd:
if line is not None and 'R' in line.split('\t')[1]: if 'R' in line[1]:
return True return True
else: else:
if 'R' in line.split(';')[2]: if 'R' in line[2]:
return True return True
return False return False
@ -250,15 +261,16 @@ class BE(object):
if rc == 0: if rc == 0:
line = self._find_be_by_name(out) line = self._find_be_by_name(out)
if line is None:
return False
if self.is_freebsd: if self.is_freebsd:
# On FreeBSD, we exclude currently mounted BE on /, as it is # On FreeBSD, we exclude currently mounted BE on /, as it is
# special and can be activated even if it is mounted. That is not # special and can be activated even if it is mounted. That is not
# possible with non-root BEs. # possible with non-root BEs.
if line.split('\t')[2] != '-' and \ if line[2] != '-' and line[2] != '/':
line.split('\t')[2] != '/':
return True return True
else: else:
if line.split(';')[3]: if line[3]:
return True return True
return False return False