try: opts, args = getopt.getopt(sys.argv[1:], options) except getopt.GetoptError, err: sys.stderr.write("%s\n" % str(err)) sys.exit(1) for o, a in opts: if o == "-f": format = a if o == "-p": profile = a if o == "-l": location = a try: conn = get_lc(profile, resource=resource) list_kwargs = kwargs if supports_location and location is not None: nodelocation = filter(lambda loc: str(loc.id) == location, conn.list_locations())[0] list_kwargs["location"] = nodelocation for node in getattr(conn, list_method)(**list_kwargs): Printer.do(node, format) except Exception, err: sys.stderr.write("Error: %s\n" % str(err)) def save_image_main(): """Shortcut for main() routine for provider
try: opts, args = getopt.getopt(sys.argv[1:], options) except getopt.GetoptError, err: sys.stderr.write("%s\n" % str(err)) sys.exit(1) for o, a in opts: if o == "-f": format = a if o == "-p": profile = a if o == "-l": location = a try: conn = get_lc(profile, resource=resource) list_kwargs = kwargs if supports_location and location is not None: nodelocation = filter(lambda loc: str(loc.id) == location, conn.list_locations())[0] list_kwargs["location"] = nodelocation for node in getattr(conn, list_method)(**list_kwargs): Printer.do(node, format) except Exception, err: sys.stderr.write("Error: %s\n" % str(err)) def save_image_main():
import getopt import sys from libcloud.types import NodeState from lc import get_lc from printer import Printer def lister_main(what): list_method = "list_%s" % what profile = "default" format = None try: opts, args = getopt.getopt(sys.argv[1:], "f:p:") except getopt.GetoptError, err: sys.stderr.write("%s\n" % str(err)) sys.exit(1) for o, a in opts: if o == "-f": format = a if o == "-p": profile = a conn = get_lc(profile) for node in getattr(conn, list_method)(): Printer.do(node, format)