A surety may maintain an action against his principal, to obtain indemnity against the debt or liability for which he is bound, before it is due, whenever any of the grounds exist, upon which, by the provisions of this code, an order may be made for arrest and bail, or for an attachment.
R.L. 1910, § 5308.