-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
664 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
# file: host_vars/admin.nsdom.local | ||
vnx: | ||
- serial: "CKM00111000126" | ||
user: "sysadmin" | ||
password: "sysadmin" | ||
spa: "10.32.2.144" | ||
spb: "10.32.2.145" | ||
storagegroup: | ||
- gname: "TestMaskingSG" | ||
# hlualu: "0,5202:1,5032" | ||
hlualu: "" | ||
# hosts: "nakagy:nsesx02.nsdom.local" | ||
hosts: "" | ||
- gname: "TestMaskingSG2" | ||
# - serial: "CKM00111000127" | ||
# user: "sysadmin" | ||
# password: "sysadmin" | ||
# spa: "10.32.2.146" | ||
# spb: "10.32.2.147" | ||
# storagegroup: | ||
# - gname: "TestMaskingSG3" | ||
# - gname: "TestMaskingSG4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[vnxmgmt] | ||
admin.nsdom.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/python | ||
|
||
import commands | ||
import re | ||
|
||
from string import * | ||
from ansible.module_utils.basic import * | ||
|
||
def checkSp(user,password,spa,spb): | ||
naviseccli_path = "/opt/Navisphere/bin/naviseccli" | ||
(rc, out, err) = module.run_command('%s -user %s -password %s -address %s -scope 0 getarrayuid' % (naviseccli_path, user, password, spa)) | ||
if rc == 0: | ||
return spa | ||
else: | ||
return spb | ||
|
||
def getRev(): | ||
(rc, out, err) = module.run_command('%s getagent' % (naviseccli), check_rc=True) | ||
return re.search(r'[0-9]+' , re.search(r'\.[0-9]+\.', re.search(r'Revision:.*', out, re.M).group()).group()).group() | ||
|
||
def checkCache(rev): | ||
if rev == "31" or rev == "32": | ||
(rc, out, err) = module.run_command('%s getcache' % (naviseccli), check_rc=True) | ||
else: | ||
(rc, out, err) = module.run_command('%s cache -sp -info' % (naviseccli), check_rc=True) | ||
|
||
for l in re.split(r'\n', out): | ||
if re.search(r'^.*Cache State.*', l): | ||
x=re.search(r'^.*Cache State.*', l).group().split(" ") | ||
if x[-1] != "Enabled": | ||
module.fail_json(msg='Cache Check Failed') | ||
|
||
def main(): | ||
### Parse Arguments | ||
global module | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
user = dict(required=True), | ||
password = dict(required=True), | ||
spa = dict(required=True), | ||
spb = dict(required=True), | ||
), | ||
) | ||
user = module.params['user'] | ||
password = module.params['password'] | ||
spa = module.params['spa'] | ||
spb = module.params['spb'] | ||
|
||
### Check SP | ||
address = checkSp(user,password,spa,spb) | ||
|
||
### Set Global Variable naviseccli | ||
global naviseccli | ||
naviseccli = "/opt/Navisphere/bin/naviseccli -user " + user + " -password " + password + " -address " + address + " -scope 0" | ||
|
||
### Check Faults List | ||
checkCache(getRev()) | ||
|
||
res_args = dict( | ||
changed = False | ||
) | ||
module.exit_json(**res_args) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/python | ||
|
||
import commands | ||
import re | ||
|
||
from string import * | ||
from ansible.module_utils.basic import * | ||
|
||
def checkSp(user,password,spa,spb): | ||
naviseccli_path = "/opt/Navisphere/bin/naviseccli" | ||
(rc, out, err) = module.run_command('%s -user %s -password %s -address %s -scope 0 getarrayuid' % (naviseccli_path, user, password, spa)) | ||
if rc == 0: | ||
return spa | ||
else: | ||
return spb | ||
|
||
def checkDisk(): | ||
(rc, out, err) = module.run_command('%s getdisk -state' % (naviseccli), check_rc=True) | ||
if re.search('Fault', out): | ||
module.fail_json(msg='Disk Check Failed') | ||
|
||
def main(): | ||
### Parse Arguments | ||
global module | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
user = dict(required=True), | ||
password = dict(required=True), | ||
spa = dict(required=True), | ||
spb = dict(required=True), | ||
), | ||
) | ||
user = module.params['user'] | ||
password = module.params['password'] | ||
spa = module.params['spa'] | ||
spb = module.params['spb'] | ||
|
||
### Check SP | ||
address = checkSp(user,password,spa,spb) | ||
|
||
### Set Global Variable naviseccli | ||
global naviseccli | ||
naviseccli = "/opt/Navisphere/bin/naviseccli -user " + user + " -password " + password + " -address " + address + " -scope 0" | ||
|
||
### Check Disk | ||
checkDisk() | ||
|
||
res_args = dict( | ||
changed = False | ||
) | ||
module.exit_json(**res_args) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/python | ||
|
||
import commands | ||
import re | ||
|
||
from string import * | ||
from ansible.module_utils.basic import * | ||
|
||
def checkSp(user,password,spa,spb): | ||
naviseccli_path = "/opt/Navisphere/bin/naviseccli" | ||
(rc, out, err) = module.run_command('%s -user %s -password %s -address %s -scope 0 getarrayuid' % (naviseccli_path, user, password, spa)) | ||
if rc == 0: | ||
return spa | ||
else: | ||
return spb | ||
|
||
def checkFaultslist(): | ||
(rc, out, err) = module.run_command('%s faults -list' % (naviseccli), check_rc=True) | ||
if not re.search('The array is operating normally.', out): | ||
module.fail_json(msg='Faults List Check Failed') | ||
|
||
def main(): | ||
### Parse Arguments | ||
global module | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
user = dict(required=True), | ||
password = dict(required=True), | ||
spa = dict(required=True), | ||
spb = dict(required=True), | ||
), | ||
) | ||
user = module.params['user'] | ||
password = module.params['password'] | ||
spa = module.params['spa'] | ||
spb = module.params['spb'] | ||
|
||
### Check SP | ||
address = checkSp(user,password,spa,spb) | ||
|
||
### Set Global Variable naviseccli | ||
global naviseccli | ||
naviseccli = "/opt/Navisphere/bin/naviseccli -user " + user + " -password " + password + " -address " + address + " -scope 0" | ||
|
||
### Check Faults List | ||
checkFaultslist() | ||
|
||
res_args = dict( | ||
changed = False | ||
) | ||
module.exit_json(**res_args) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/python | ||
|
||
import commands | ||
import re | ||
|
||
from string import * | ||
from ansible.module_utils.basic import * | ||
|
||
def checkSp(user,password,spa,spb): | ||
naviseccli_path = "/opt/Navisphere/bin/naviseccli" | ||
(rc, out, err) = module.run_command('%s -user %s -password %s -address %s -scope 0 getarrayuid' % (naviseccli_path, user, password, spa)) | ||
if rc == 0: | ||
return spa | ||
else: | ||
return spb | ||
|
||
def checkHw(): | ||
(rc, out, err) = module.run_command('%s getcrus' % (naviseccli), check_rc=True) | ||
if re.search('Fault', out): | ||
module.fail_json(msg='Hardware Check Failed') | ||
|
||
def main(): | ||
### Parse Arguments | ||
global module | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
user = dict(required=True), | ||
password = dict(required=True), | ||
spa = dict(required=True), | ||
spb = dict(required=True), | ||
), | ||
) | ||
user = module.params['user'] | ||
password = module.params['password'] | ||
spa = module.params['spa'] | ||
spb = module.params['spb'] | ||
|
||
### Check SP | ||
address = checkSp(user,password,spa,spb) | ||
|
||
### Set Global Variable naviseccli | ||
global naviseccli | ||
naviseccli = "/opt/Navisphere/bin/naviseccli -user " + user + " -password " + password + " -address " + address + " -scope 0" | ||
|
||
### Check Hardware | ||
checkHw() | ||
|
||
res_args = dict( | ||
changed = False | ||
) | ||
module.exit_json(**res_args) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/python | ||
|
||
import commands | ||
import re | ||
|
||
from string import * | ||
from ansible.module_utils.basic import * | ||
|
||
def checkSp(user,password,spa,spb): | ||
naviseccli_path = "/opt/Navisphere/bin/naviseccli" | ||
(rc, out, err) = module.run_command('%s -user %s -password %s -address %s -scope 0 getarrayuid' % (naviseccli_path, user, password, spa)) | ||
if rc == 0: | ||
return spa | ||
else: | ||
return spb | ||
|
||
def createSg(gname): | ||
(rc, out, err) = module.run_command('%s storagegroup -list -gname %s' % (naviseccli, gname)) | ||
if rc != 0: | ||
(rc, out, err) = module.run_command('%s storagegroup -create -gname %s' % (naviseccli, gname), check_rc=True) | ||
return 1 | ||
else: | ||
return 0 | ||
|
||
def main(): | ||
### Parse Arguments | ||
global module | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
user = dict(required=True), | ||
password = dict(required=True), | ||
spa = dict(required=True), | ||
spb = dict(required=True), | ||
gname = dict(required=True), | ||
), | ||
) | ||
user = module.params['user'] | ||
password = module.params['password'] | ||
spa = module.params['spa'] | ||
spb = module.params['spb'] | ||
gname = module.params['gname'] | ||
|
||
### Check SP | ||
address = checkSp(user,password,spa,spb) | ||
|
||
### Set Global Variable naviseccli | ||
global naviseccli | ||
naviseccli = "/opt/Navisphere/bin/naviseccli -user " + user + " -password " + password + " -address " + address + " -scope 0" | ||
|
||
### Create Storage Group | ||
rc = createSg(gname) | ||
if rc: | ||
res_args = dict( | ||
changed = True | ||
) | ||
module.exit_json(**res_args) | ||
else: | ||
res_args = dict( | ||
changed = False | ||
) | ||
module.exit_json(**res_args) | ||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.