Skip to content

Commit

Permalink
Add function of sp failover
Browse files Browse the repository at this point in the history
  • Loading branch information
hn826 committed Jun 1, 2016
1 parent f0806c4 commit ad96e4f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
17 changes: 15 additions & 2 deletions sglun-module/library/sglun.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
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 getPairs(gname):
(rc, out, err) = module.run_command('%s storagegroup -list -gname %s' % (naviseccli, gname), check_rc=True)
retlist = []
Expand Down Expand Up @@ -38,19 +46,24 @@ def main():
argument_spec = dict(
user = dict(required=True),
password = dict(required=True),
address = dict(required=True),
spa = dict(required=True),
spb = dict(required=True),
query = dict(required=True),
gname = dict(required=True),
noremove = dict(default=False, required=False, type='bool')
),
)
user = module.params['user']
password = module.params['password']
address = module.params['address']
spa = module.params['spa']
spb = module.params['spb']
query = module.params['query']
gname = module.params['gname']
noremove = module.params['noremove']

### 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"
Expand Down
1 change: 1 addition & 0 deletions sglun-module/site.retry
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhosts
7 changes: 4 additions & 3 deletions sglun-module/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
vars:
user: "sysadmin"
password: "sysadmin"
sp: "10.32.2.144"
spa: "10.32.2.146"
spb: "10.32.2.145"
gname: "TestMaskingSG"
tasks:
- name: Check LUN A
sglun: user={{ user }} password={{ password }} address={{ sp }} gname={{ gname }} query="0,5202:1,5032" noremove=True
sglun: user={{ user }} password={{ password }} spa={{ spa }} spb={{ spb }} gname={{ gname }} query="0,5202:1,5032"
- name: Check LUN B
sglun: user={{ user }} password={{ password }} address={{ sp }} gname={{ gname }} query="1,5202:0,5032"
sglun: user={{ user }} password={{ password }} spa={{ spa }} spb={{ spb }} gname={{ gname }} query="1,5202:0,5032" noremove=True

0 comments on commit ad96e4f

Please sign in to comment.