Commit def62a71 authored by David Johnson's avatar David Johnson

Optionally transform values before printing.

Only for ist_authinit auth_network field for now;
FreeNAS seems to add \n "separators" in the list of
authorized networks.  So, when we print, change those
to spaces, which is what we give FreeNAS as input ;)
parent c13f0eee
......@@ -204,6 +204,11 @@ class CommandSet(object):
tk = cdict['translateKeys']
else:
tk = {}
if cdict.has_key('translateValues'):
tv = cdict['translateValues']
else:
tv = {}
pretty = False
if command == 'plist':
pretty = True
......@@ -246,6 +251,9 @@ class CommandSet(object):
nv = {}
for (k,v2) in v.iteritems():
nvi = "%s" % (str(v2),)
if tv.has_key(k):
nvi = tv[k](k,v2)
pass
nl = len(nvi)
if not fieldwidths.has_key(k):
fieldwidths[k] = nl
......@@ -1072,8 +1080,14 @@ class IscsiTargetAuthorizedInitiator(CommandSet):
'kwDefaults' : {},
'instanceFilterArgs' : [ 'tag' ],
'type' : 'del' })
self.commands['list'] = self.commands['plist'] = {}
self.commands['list'] = \
dict({ 'translateValues' : { 'iscsi_target_initiator_auth_network' : self.nlToSpace } })
self.commands['plist'] = self.commands['list']
pass
def nlToSpace(self,k,v):
return v.replace("\n"," ")
pass
class IscsiTargetToExtent(CommandSet):
......
......@@ -217,6 +217,11 @@ class CommandSet(object):
tk = cdict['translateKeys']
else:
tk = {}
if cdict.has_key('translateValues'):
tv = cdict['translateValues']
else:
tv = {}
pretty = False
if command == 'plist':
pretty = True
......@@ -259,6 +264,9 @@ class CommandSet(object):
nv = {}
for (k,v2) in v.iteritems():
nvi = "%s" % (str(v2),)
if tv.has_key(k):
nvi = tv[k](k,v2)
pass
nl = len(nvi)
if not fieldwidths.has_key(k):
fieldwidths[k] = nl
......@@ -1102,8 +1110,14 @@ class IscsiTargetAuthorizedInitiator(CommandSet):
'kwDefaults' : {},
'instanceFilterArgs' : [ 'tag' ],
'type' : 'del' })
self.commands['list'] = self.commands['plist'] = {}
self.commands['list'] = \
dict({ 'translateValues' : { 'iscsi_target_initiator_auth_network' : self.nlToSpace } })
self.commands['plist'] = self.commands['list']
pass
def nlToSpace(self,k,v):
return v.replace("\n"," ")
pass
class IscsiTargetToExtent(CommandSet):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment