mirror of
https://github.com/xcat2/confluent.git
synced 2026-08-28 09:36:41 +00:00
4ca6ec365d
A stray trailing comma made the update detail a one element tuple, so a firmware error printed as a python tuple. A missing status printed the whole response dict. A failure that named no node was dropped entirely, which is how a service data request that the server refused came out as silence and a success exit code, and nodestorage, nodelicense and nodesupport exited zero even when they had reported an error. nodeconsole crashed decoding an absent screenshot, and again on the terminal calls behind a pipe, where a log replay crashed too; refuse the terminal only modes cleanly and dump the log when there is no terminal to replay into. nodedefine raised a ValueError on an argument without an equals sign, and firmware for a category the target does not describe printed usage as though the question had been malformed. On the server side the readability check was applied to the path a download is saved to, so asking for service data or saved licences at a path that does not exist yet failed claiming the destination was not readable.
69 lines
2.0 KiB
Python
Executable File
69 lines
2.0 KiB
Python
Executable File
#!/usr/bin/python3
|
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
# Copyright 2017 Lenovo
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import asyncio
|
|
import optparse
|
|
import os
|
|
import signal
|
|
import sys
|
|
|
|
try:
|
|
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
|
except AttributeError:
|
|
pass
|
|
|
|
path = os.path.dirname(os.path.realpath(__file__))
|
|
path = os.path.realpath(os.path.join(path, '..', 'lib', 'python'))
|
|
if path.startswith('/opt'):
|
|
sys.path.append(path)
|
|
|
|
import confluent.asynclient as client
|
|
|
|
async def main():
|
|
argparser = optparse.OptionParser(
|
|
usage='''\n %prog noderange attribute1=value1 attribute2=value,...
|
|
\n ''')
|
|
(options, args) = argparser.parse_args()
|
|
requestargs = None
|
|
try:
|
|
noderange = args[0]
|
|
except IndexError:
|
|
argparser.print_help()
|
|
sys.exit(1)
|
|
client.check_globbing(noderange)
|
|
session = client.Command()
|
|
exitcode = 0
|
|
attribs = {'name': noderange}
|
|
for arg in args[1:]:
|
|
if '=' not in arg:
|
|
sys.stderr.write(
|
|
'Attributes must be given as attribute=value, got "{0}"\n'.format(
|
|
arg))
|
|
sys.exit(1)
|
|
key, val = arg.split('=', 1)
|
|
attribs[key] = val
|
|
async for r in session.create('/noderange/', attribs):
|
|
if 'error' in r:
|
|
sys.stderr.write(r['error'] + '\n')
|
|
exitcode |= 1
|
|
if 'created' in r:
|
|
print('{0}: created'.format(r['created']))
|
|
sys.exit(exitcode)
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main())
|