Skip to content

Commit

Permalink
Change Directory Structure
Browse files Browse the repository at this point in the history
  • Loading branch information
hn826 committed Jun 9, 2016
1 parent 6b0ff59 commit f425ec6
Show file tree
Hide file tree
Showing 15 changed files with 664 additions and 0 deletions.
23 changes: 23 additions & 0 deletions host_vars/admin.nsdom.local
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"
2 changes: 2 additions & 0 deletions hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[vnxmgmt]
admin.nsdom.local
65 changes: 65 additions & 0 deletions library/cachechk.py
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()
54 changes: 54 additions & 0 deletions library/diskchk.py
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()
54 changes: 54 additions & 0 deletions library/faultschk.py
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()
54 changes: 54 additions & 0 deletions library/hwchk.py
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()
64 changes: 64 additions & 0 deletions library/sg.py
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()
Loading

0 comments on commit f425ec6

Please sign in to comment.