Merge pull request #48 from markberger/740-cli-accept-multiple-aliases
740 cli accept multiple aliases
This commit is contained in:
commit
e493dcec4a
|
@ -451,8 +451,8 @@ class CheckOptions(FilesystemOptions):
|
||||||
("repair", None, "Automatically repair any problems found."),
|
("repair", None, "Automatically repair any problems found."),
|
||||||
("add-lease", None, "Add/renew lease on all shares."),
|
("add-lease", None, "Add/renew lease on all shares."),
|
||||||
]
|
]
|
||||||
def parseArgs(self, where=''):
|
def parseArgs(self, *locations):
|
||||||
self.where = argv_to_unicode(where)
|
self.locations = map(argv_to_unicode, locations)
|
||||||
|
|
||||||
def getSynopsis(self):
|
def getSynopsis(self):
|
||||||
return "Usage: %s [global-opts] check [options] [ALIAS:PATH]" % (self.command_name,)
|
return "Usage: %s [global-opts] check [options] [ALIAS:PATH]" % (self.command_name,)
|
||||||
|
@ -470,8 +470,8 @@ class DeepCheckOptions(FilesystemOptions):
|
||||||
("add-lease", None, "Add/renew lease on all shares."),
|
("add-lease", None, "Add/renew lease on all shares."),
|
||||||
("verbose", "v", "Be noisy about what is happening."),
|
("verbose", "v", "Be noisy about what is happening."),
|
||||||
]
|
]
|
||||||
def parseArgs(self, where=''):
|
def parseArgs(self, *locations):
|
||||||
self.where = argv_to_unicode(where)
|
self.locations = map(argv_to_unicode, locations)
|
||||||
|
|
||||||
def getSynopsis(self):
|
def getSynopsis(self):
|
||||||
return "Usage: %s [global-opts] deep-check [options] [ALIAS:PATH]" % (self.command_name,)
|
return "Usage: %s [global-opts] deep-check [options] [ALIAS:PATH]" % (self.command_name,)
|
||||||
|
|
|
@ -15,13 +15,12 @@ def _quote_serverid_index_share(serverid, storage_index, sharenum):
|
||||||
quote_output(storage_index, quotemarks=False),
|
quote_output(storage_index, quotemarks=False),
|
||||||
sharenum)
|
sharenum)
|
||||||
|
|
||||||
def check(options):
|
def check_location(options, where):
|
||||||
stdout = options.stdout
|
stdout = options.stdout
|
||||||
stderr = options.stderr
|
stderr = options.stderr
|
||||||
nodeurl = options['node-url']
|
nodeurl = options['node-url']
|
||||||
if not nodeurl.endswith("/"):
|
if not nodeurl.endswith("/"):
|
||||||
nodeurl += "/"
|
nodeurl += "/"
|
||||||
where = options.where
|
|
||||||
try:
|
try:
|
||||||
rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
|
rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
|
||||||
except UnknownAliasError, e:
|
except UnknownAliasError, e:
|
||||||
|
@ -97,8 +96,19 @@ def check(options):
|
||||||
for (serverid, storage_index, sharenum) in corrupt:
|
for (serverid, storage_index, sharenum) in corrupt:
|
||||||
stdout.write(" %s\n" % _quote_serverid_index_share(serverid, storage_index, sharenum))
|
stdout.write(" %s\n" % _quote_serverid_index_share(serverid, storage_index, sharenum))
|
||||||
|
|
||||||
return 0
|
return 0;
|
||||||
|
|
||||||
|
def check(options):
|
||||||
|
if len(options.locations) == 0:
|
||||||
|
errno = check_location(options, unicode())
|
||||||
|
if errno != 0:
|
||||||
|
return errno
|
||||||
|
return 0
|
||||||
|
for location in options.locations:
|
||||||
|
errno = check_location(options, location)
|
||||||
|
if errno != 0:
|
||||||
|
return errno
|
||||||
|
return 0
|
||||||
|
|
||||||
class FakeTransport:
|
class FakeTransport:
|
||||||
disconnecting = False
|
disconnecting = False
|
||||||
|
@ -262,7 +272,7 @@ class DeepCheckAndRepairOutput(LineOnlyReceiver):
|
||||||
|
|
||||||
class DeepCheckStreamer(LineOnlyReceiver):
|
class DeepCheckStreamer(LineOnlyReceiver):
|
||||||
|
|
||||||
def run(self, options):
|
def deepcheck_location(self, options, where):
|
||||||
stdout = options.stdout
|
stdout = options.stdout
|
||||||
stderr = options.stderr
|
stderr = options.stderr
|
||||||
self.rc = 0
|
self.rc = 0
|
||||||
|
@ -271,7 +281,7 @@ class DeepCheckStreamer(LineOnlyReceiver):
|
||||||
if not nodeurl.endswith("/"):
|
if not nodeurl.endswith("/"):
|
||||||
nodeurl += "/"
|
nodeurl += "/"
|
||||||
self.nodeurl = nodeurl
|
self.nodeurl = nodeurl
|
||||||
where = options.where
|
|
||||||
try:
|
try:
|
||||||
rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
|
rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
|
||||||
except UnknownAliasError, e:
|
except UnknownAliasError, e:
|
||||||
|
@ -309,6 +319,19 @@ class DeepCheckStreamer(LineOnlyReceiver):
|
||||||
output.dataReceived(chunk)
|
output.dataReceived(chunk)
|
||||||
if not self.options["raw"]:
|
if not self.options["raw"]:
|
||||||
output.done()
|
output.done()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def run(self, options):
|
||||||
|
if len(options.locations) == 0:
|
||||||
|
errno = self.deepcheck_location(options, unicode())
|
||||||
|
if errno != 0:
|
||||||
|
return errno
|
||||||
|
return 0
|
||||||
|
for location in options.locations:
|
||||||
|
errno = self.deepcheck_location(options, location)
|
||||||
|
if errno != 0:
|
||||||
|
return errno
|
||||||
return self.rc
|
return self.rc
|
||||||
|
|
||||||
def deepcheck(options):
|
def deepcheck(options):
|
||||||
|
|
|
@ -3298,6 +3298,37 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||||
d.addCallback(_check)
|
d.addCallback(_check)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def test_check_with_multiple_aliases(self):
|
||||||
|
self.basedir = "cli/Check/check_with_multiple_aliases"
|
||||||
|
self.set_up_grid()
|
||||||
|
self.uriList = []
|
||||||
|
c0 = self.g.clients[0]
|
||||||
|
d = c0.create_dirnode()
|
||||||
|
def _stash_uri(n):
|
||||||
|
self.uriList.append(n.get_uri())
|
||||||
|
d.addCallback(_stash_uri)
|
||||||
|
d = c0.create_dirnode()
|
||||||
|
d.addCallback(_stash_uri)
|
||||||
|
|
||||||
|
d.addCallback(lambda ign: self.do_cli("check", self.uriList[0], self.uriList[1]))
|
||||||
|
def _check((rc, out, err)):
|
||||||
|
self.failUnlessReallyEqual(rc, 0)
|
||||||
|
self.failUnlessReallyEqual(err, "")
|
||||||
|
#Ensure healthy appears for each uri
|
||||||
|
self.failUnlessIn("Healthy", out[:len(out)/2])
|
||||||
|
self.failUnlessIn("Healthy", out[len(out)/2:])
|
||||||
|
d.addCallback(_check)
|
||||||
|
|
||||||
|
d.addCallback(lambda ign: self.do_cli("check", self.uriList[0], "nonexistent:"))
|
||||||
|
def _check2((rc, out, err)):
|
||||||
|
self.failUnlessReallyEqual(rc, 1)
|
||||||
|
self.failUnlessIn("Healthy", out)
|
||||||
|
self.failUnlessIn("error:", err)
|
||||||
|
self.failUnlessIn("nonexistent", err)
|
||||||
|
d.addCallback(_check2)
|
||||||
|
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
||||||
class Errors(GridTestMixin, CLITestMixin, unittest.TestCase):
|
class Errors(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
|
|
Loading…
Reference in New Issue