David Howells [Tue, 20 May 2014 23:04:29 +0000 (00:04 +0100)]
Provide bash completion
Provide bash completion that uses the argument lists in the individual
subcommand files to work out how to complete. The completion algorithm will
interpolate required flags first and will fully expand flag names. Flag
parameters will be switched to hostname expansion or cellname expansion as
appropriate.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Wed, 14 May 2014 11:14:52 +0000 (12:14 +0100)]
Provide a protection DB Name<->ID cache
Provide a protection DB Name<->ID cache to eliminate redundant lookups and to
reduce the number of NameToID and IDToName RPC calls made by consolidating
multiple requests into single calls.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Tue, 13 May 2014 20:27:56 +0000 (21:27 +0100)]
Better iterate over list of ptservers upon failure
Separate out the iteration over a list of ptservers when one fails. We don't
want to have to intermingle it with a loop over a list of calls to make (eg. a
list of IDs to be deleted).
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Tue, 13 May 2014 20:24:30 +0000 (21:24 +0100)]
rxgen: Always check type of objects in a bulk list when encoding arguments
We should always check the type of the objects in a bulk list when we're
encoding them as part of an argument (or result) list. Previously we only did
this when we needed to fold things like arrays of ints into an object.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Tue, 13 May 2014 20:20:08 +0000 (21:20 +0100)]
rxgen: Integer INOUT args should take an int in PyArg_ParseTuple()
Integer INOUT args should take an int in PyArg_ParseTuple() rather than an
arbitrary object as the code now doesn't pass results back through the argument
list.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Tue, 13 May 2014 16:28:11 +0000 (17:28 +0100)]
Handle exit codes better
Returning the intended exit code from the main try block that invokes the
subcommand handler rather than trying to exit within the exception handling
seems to work better and actually return the error code.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Tue, 13 May 2014 16:23:37 +0000 (17:23 +0100)]
rxgen: Handle bulk arguments correctly
Need to check for a bulk-class argument of an integer-type before testing for
the integer-type otherwise the integer-type is selected. This causes the wrong
argument spec to be emitted for PyArg_ParseTuple() when decoding the arguments
for an RPC call to be issued.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Thu, 1 May 2014 14:53:03 +0000 (15:53 +0100)]
Implement "bos getlog" and reengineer the decode path somewhat
Implement the "bos getlog" subcommand - which requires making the receive side
of split RPC function work. To this end, the following reengineering has been
done to the decode side:
(1) Lift the requirement that the Rx buffer cursor be 4-byte aligned as
BOZO.GetLog() doesn't align the log data it returns.
(2) Permit a request for an unknown - and possibly zero - amount of data to be
set in call->need_size. BOZO.GetLog() doesn't tell you in advance how
much data it will return: the data stops when the Rx receive phase ends
with LAST_PACKET being flagged.
(3) Separate blob decoding (strings & opaques) from bulk decoding in the
member variables of the rx_call struct, where a bulk decode is now a
sequence of blobs, structs or ints.
(4) Handle blob decoding asynchronously, where the buffer into which a blob is
being written may not represent contiguous memory. This is done by
setting up with an init function, called once, and a decode-into function,
called repeatedly whilst it returns 1. The function is only called when
there is sufficient data in the receive buffers.
(5) Decode padding asynchronously by working out up front for a blob how much
padding it requires and then decoding it as its own blob at the end using
a special source buffer as a marker to switch processing.
(6) Perform split reception by adding additional states within the decode
state machine to call out to the handler functions.
The receive() method of the split_handler class provided to a split RPC
function then implements its own state machine on top of the decoder state
machine.
Further:
(*) rxrpc_recv_data() now reports ENODATA rather than EMSGSIZE if the receive
phase ends with short data.
(*) MSG_MORE handling has separate rx_call struct members for the send and
receive phase now to avoid confusion.
(*) rxrpc_enc/dec_slow() now use rxrpc_enc/dec_blob() to avoid duplicating a
lot of code.
(*) rxrpc_enc/dec() now also go to the slow path if the cursor is misaligned,
which may mean the data to be read is split across buffers.
(*) The rx_call struct now has a pointer to a cleanup function to clean up the
decoder state at the end to deal with aborted calls.
(*) rxrpc_post_dec() reduces call->need_size as well as call->data_count as we
don't want to be waiting for N bytes to turn up for a size-N blob if we
have already received N-1 bytes of it and only need one more byte.
This does mean that call->need_size may need resetting more often.
(*) Added an output_raw() python output method to permit bytearray objects to
be printed. Conversion to a string means that control characters and
quotes get escaped (eg. a newline char gets converted to \n).
(*) Catching the SystemExit exception should not produce an error due to ret
not existing as a variable.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Tue, 15 Apr 2014 08:34:42 +0000 (09:34 +0100)]
rxgen: Implement the transmission side of split-mode RPC calls
Implement the transmission side of RPC calls that are marked with a 'split'
flag - ie. functions in which the caller is allowed to interpolate an
arbitrary transmission blob after the arguments and to receive an arbitrary
blob before the response is received.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Wed, 16 Apr 2014 07:18:07 +0000 (08:18 +0100)]
rxgen: Use PyErr_NoMemory() rather than PyExc_MemoryError
Use PyErr_NoMemory() rather than PyExc_MemoryError as the former actually
raises an exception. The latter is just a class and is then just an object
with no special meaning when returned.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Tue, 15 Apr 2014 09:42:23 +0000 (10:42 +0100)]
rxgen: Fix rxrpc_send_data()
Make three Fixes to rxrpc_send_data():
(1) Advance to the next buffer when filling the iovec array rather than
endlessly cycling over the first one.
(2) Only clear MSG_MORE if we have sent all the buffered data at the end of
the transmission phase of a call.
(3) Don't turn the return value of sendmsg() into just -1 or 0 as we need the
number of bytes actually sent to allow us to correctly advance the buffer
cursor.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Mon, 14 Apr 2014 12:42:41 +0000 (13:42 +0100)]
Fix up output and error displaying in commands
Fix up output and error displaying in commands so far implemented. Replace
usage of print() with output() and outputf() for normal operation and error()
for error display. debug() is replaced with verbose() which is contingent on
the -verbose switch.
Also add error handling to a number of commands.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Mon, 14 Apr 2014 07:09:58 +0000 (08:09 +0100)]
rxgen: The abort table comparator needs to handle big numbers
The abort table comparator needs to handle big numbers (larger than
0x7fffffff). Subtracting a small number from such a big number and then
casting to a signed int results in a negative number, which bsearch()
interprets as indicating that the bigger number is smaller than the smaller
number.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Sat, 12 Apr 2014 14:51:03 +0000 (15:51 +0100)]
Provide separate arg interpretation functions for multivalued arguments
Provide separate arg interpretation functions for multivalued arguments so
that the single-valued versions return a non-list and the multivalued returns
a list.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Sat, 12 Apr 2014 13:33:46 +0000 (14:33 +0100)]
Use gethostbyname_ex() and gethostbyaddr() rather than the DNS resolver
Use gethostbyname_ex() and gethostbyaddr() for A and PTR record retrieval
rather than using the DNS resolver directly so that /etc/hosts and suchlike
are also used.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Fri, 11 Apr 2014 22:57:53 +0000 (23:57 +0100)]
rxgen: The string and bytes decode functions must advance the cursor
The string and bytes decode functions (py_dec_string() and rxrpc_dec_bytes())
need to advance the extraction cursor after extracting so the data doesn't get
reused.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Thu, 10 Apr 2014 13:04:52 +0000 (14:04 +0100)]
Implement "vos examine"
Implement the "vos examine" command. There is a lot of common display code
between this and several of the other commands, so the common bits are drawn
out into a library module for all to share.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Thu, 10 Apr 2014 10:19:56 +0000 (11:19 +0100)]
Save raw argument list for each switch
Several of the switch parameters have their argument lists cooked by the
argument parser. This means we cannot get at the original string(s) when
producing error messages.
Save the raw argument list for each switch in the parameters dictionary as a
list of strings attached to a key of "raw.<switchname>".
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Thu, 10 Apr 2014 10:17:25 +0000 (11:17 +0100)]
Add a convenience module for partition ID handling
Add a convenience module for partition ID handling. One function translates
"/vicepX[Y]", "vicepX[Y]", "X[Y]" and "N" into a numeric ID and range checks
it. Another function translates a numeric ID back into "/vicepX[Y]".
Make the argument parser use it.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Wed, 9 Apr 2014 22:38:32 +0000 (23:38 +0100)]
rxgen: Emit individual exception classes for defined abort codes and raise them
Emit an exception class for each defined abort code and raise the appropriate
exception when an abort is received. Each set of classes is subclassed from a
package-specific class (eg. AbortVL_NOENT -> VLAbort) and each
package-specific class is subclassed from a generic class (eg. VLAbort ->
RemoteAbort) so that all package codes can be trapped in one statement and all
remote aborts can be trapped together.
If an unknown code is received, then this is raised as RemoteAbort only.
RxRPC/rxgen codes are supplied now also in the rxgen.xg file under the RXGEN
package name.
KAA/KAM/KAT codes are under the KA package.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Wed, 9 Apr 2014 20:27:58 +0000 (21:27 +0100)]
rxgen: Set struct members correctly in struct types
When setting a member of a struct (eg. VL.ListAddrByAttributes) where that
member is itself a struct type (eg. afsUUID), we need to check that the type
of the value to assign is the member type, not the container type.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Wed, 9 Apr 2014 14:40:36 +0000 (15:40 +0100)]
Move VL connection security determination into cell.py
Move the Volume Location DB connection security handling into
cell.open_vl_server() as it's common to all vos commands. It can be
configured directly by passing in a dictionary holding the appropriate
parameters.
Signed-off-by: David Howells <dhowells@redhat.com>
David Howells [Wed, 9 Apr 2014 14:43:22 +0000 (15:43 +0100)]
Provide generic check for non-combinable parameters
Provide generic check for non-combinable parameters in command py files. A
list of tuples of pairs of argument names that don't interact is provided by
the name cant_combine_arguments as a global var.
Signed-off-by: David Howells <dhowells@redhat.com>