def backups_list(args): l = args.endpoint.list_backups(args.vmuuid) l = sorted(l, key=lambda e: d(e, ['timestamp'], 0)) if args.H: header(args) fmt = mk_fmt_str(args) for e in l: if not e: print('error!') exit(1) l = mk_fmt_line(args, e) if args.p: print(':'.join(l)) else: print(fmt%tuple(l))
def backups_list(args): l = args.endpoint.list_backups(args.vmuuid) l = sorted(l, key=lambda e: d(e, ['timestamp'], 0)) if args.H: header(args) fmt = mk_fmt_str(args) for e in l: if not e: print('error!') exit(1) l = mk_fmt_line(args, e) if args.p: print(':'.join(l)) else: print(fmt % tuple(l))
def name_of(self, obj): return d(obj, ['config', 'alias'])
return(vm['info']) def vm_metadata_map_fn(vm): return(vm['metadata']) # Returns the ip of a vm (first ip in the networks) def vm_ip(e): n = d(e, ['config', 'networks'], []) if len(n) > 0: return n[0]['ip'] else: return '-' vm_fmt = { 'uuid': {'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid'])}, 'alias': {'title': 'alias', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['config', 'alias'])}, 'ip': {'title': 'IP', 'len': 15, 'fmt': '%15s', 'get': vm_ip}, 'state': {'title': 'state', 'len': 15, 'fmt': '%-15s', 'get': lambda e: d(e, ['state'])}, 'hypervisor': {'title': 'hypervisor', 'len': 20, 'fmt': '%-20s', 'get': lambda e: d(e, ['hypervisor'])}, 'package': {'title': 'package', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['package'])}, 'dataset': {'title': 'dataset', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['config', 'dataset'])}, } snapshot_fmt = {
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete network_fmt = { 'uuid': {'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid'])}, 'name': {'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['name'])}, 'ipranges': {'title': 'ipranges', 'len': 36, 'fmt': '%36s', 'get': lambda e: ','.join(d(e, ['ipranges']))}, } def create(args): res = args.endpoint.create(args.name) if res: print 'Network successfully created: %s' % res['uuid'] else: print 'Network creation failed: %r' % res exit(1) def add_range(args): res = args.endpoint.add_range(args.uuid, args.iprange_uuid) if res: print 'Successfully added IP range %s to %s' % (args.iprange_uuid, args.uuid) else: print 'Adding IP range failed: %r' % res exit(1) class Network(Entity):
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 import json from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete iprange_fmt = { 'uuid': { 'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid']) }, 'name': { 'title': 'Name', 'len': 20, 'fmt': '%-20s', 'get': lambda e: d(e, ['name']) }, 'tag': { 'title': 'Tag', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['tag']) }, 'iprange': { 'title': 'Iprange', 'len': 15, 'fmt': '%15s', 'get': lambda e: d(e, ['iprange']) },
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete import re import argparse pkg_fmt = { 'uuid': { 'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid']) }, 'name': { 'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['name']) }, 'cpu_cap': { 'title': 'CPU cap', 'len': 10, 'fmt': '%-10s', 'get': lambda e: str(d(e, ['cpu_cap'])) + '%' }, 'quota': { 'title': 'Quota', 'len': 10, 'fmt': '%-10s', 'get': lambda e: str(d(e, ['quota'])) + ' GB'
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete role_fmt = { 'uuid': {'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid'])}, 'name': {'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['name'])}, } def create(args): res = args.endpoint.create(args.name) if args.p: if res: print res['uuid'] else: exit(1) else: if res: print 'Role successfully created: %s' % res['uuid'] else: print 'Role creation failed: %r' % res exit(1) def grant(args): res = args.endpoint.grant(args.uuid, args.permission) if args.p: if res: exit(0)
# Returns the ip of a vm (first ip in the networks) def vm_ip(e): n = d(e, ['config', 'networks'], []) if len(n) > 0: return n[0]['ip'] else: return '-' vm_fmt = { 'uuid': { 'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid']) }, 'alias': { 'title': 'alias', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['config', 'alias']) }, 'ip': { 'title': 'IP', 'len': 15, 'fmt': '%15s', 'get': vm_ip }, 'state': { 'title': 'state',
def vm_ip(e): n = d(e, ['config', 'networks'], []) if len(n) > 0: return n[0]['ip'] else: return '-'
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 import sys from .wiggle import Entity from fifo.helper import d, vprint, ListAction, show_list, show_get, show_delete import httplib import json import argparse dataset_fmt = { 'uuid': { 'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid']) }, 'name': { 'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['name']) }, 'version': { 'title': 'Version', 'len': 7, 'fmt': '%-7s', 'get': lambda e: d(e, ['version']) }, 'type': { 'title': 'Type', 'len': 5,
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 import sys from .wiggle import Entity from fifo.helper import d, vprint, ListAction, show_list, show_get, show_delete import httplib import json import argparse dataset_fmt = { 'uuid': {'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid'])}, 'name': {'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['name'])}, 'version': {'title': 'Version', 'len': 7, 'fmt': '%-7s', 'get': lambda e: d(e, ['version'])}, 'type': {'title': 'Type', 'len': 5, 'fmt': '%-5s', 'get': lambda e: d(e, ['type'])}, 'description': {'title': 'Description', 'len': 10, 'fmt': '%-30s', 'get': lambda e: d(e, ['description'])}, } def _write_bindata(response, f): amt = 4096 try: data = response.read(amt) except httplib.IncompleteRead, e: data = e.partial f.write(data) f.flush() return
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete grouping_fmt = { "uuid": {"title": "UUID", "len": 36, "fmt": "%36s", "get": lambda e: d(e, ["uuid"])}, "name": {"title": "Name", "len": 10, "fmt": "%-10s", "get": lambda e: d(e, ["name"])}, "type": {"title": "Name", "len": 10, "fmt": "%-10s", "get": lambda e: d(e, ["type"])}, "elements": {"title": "elements", "len": 36, "fmt": "%36s", "get": lambda e: ",".join(d(e, ["elements"]))}, "groupings": {"title": "groupings", "len": 36, "fmt": "%36s", "get": lambda e: ",".join(d(e, ["groupings"]))}, } def create_grouping(args): res = args.endpoint.create(args.name, args.type) if res: print "New " + args.type + " created: " + res["uuid"] else: print "Failed to create " + args.type exit(1) def grouping_add(args): main = args.endpoint.get(args.uuid) if main["type"] != "stack": print "Only clusters can be added to stacks." exit(1) res = args.endpoint.get(args.target) if not res:
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete import sys user_fmt = { 'uuid': { 'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid']) }, 'name': { 'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['name']) }, 'roles': { 'title': 'Roles', 'len': 10, 'fmt': '%-10s', 'get': lambda e: str(d(e, ['roles'])) }, 'orgs': { 'title': 'Orgs', 'len': 10, 'fmt': '%-10s', 'get': lambda e: str(d(e, ['orgs'])) },
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete import sys user_fmt = { 'uuid': {'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid'])}, 'name': {'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['name'])}, 'roles': {'title': 'Roles', 'len': 10, 'fmt': '%-10s', 'get': lambda e: str(d(e, ['roles']))}, 'orgs': {'title': 'Orgs', 'len': 10, 'fmt': '%-10s', 'get': lambda e: str(d(e, ['orgs']))}, } def user_create(args): if not args.userpassword: print 'You have to specify a userpassword' exit(1) wiggle = args.endpoint._wiggle reply = args.endpoint.create(args.name, args.userpassword) if reply: if args.organization: args.endpoint.join_org(reply['uuid'], args.organization) if args.p:
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete org_fmt = { 'uuid': {'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid'])}, 'name': {'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['name'])}, } org_acct_fmt = { 'resource': {'title': 'Resource UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['resource'])}, 'action': {'title': 'Action', 'len': 8, 'fmt': '%-8s', 'get': lambda e: d(e, ['action'])}, 'timestamp': {'title': 'Timestamp', 'len': 16, 'fmt': '%-16s', 'get': lambda e: d(e, ['timestamp'])}, 'date': {'title': 'Date & Time', 'len': 19, 'fmt': '%-19s', 'get': lambda e: t(d(e, ['timestamp']))}, } def create(args): res = args.endpoint.create(args.name) if args.p: if res: print res['uuid'] else: exit(1) else:
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete grouping_fmt = { 'uuid': { 'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid']) }, 'name': { 'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['name']) }, 'type': { 'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['type']) }, 'elements': { 'title': 'elements', 'len': 36, 'fmt': '%36s', 'get': lambda e: ','.join(d(e, ['elements'])) }, 'groupings': {
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete import re import argparse pkg_fmt = { 'uuid': {'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid'])}, 'name': {'title': 'Name', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['name'])}, 'cpu_cap': {'title': 'CPU cap', 'len': 10, 'fmt': '%-10s', 'get': lambda e: str(d(e, ['cpu_cap'])) + '%'}, 'quota': {'title': 'Quota', 'len': 10, 'fmt': '%-10s', 'get': lambda e: str(d(e, ['quota'])) + ' GB'}, 'ram': {'title': 'RAM', 'len': 10, 'fmt': '%-10s', 'get': lambda e: str(d(e, ['ram'])) + ' MB'}, } def create(args): mb = 1024*1024 gb = mb * 1024 reqs = [] if args.requirement: reqs = map(package_rule, args.requirement) if args.random: reqs += map(package_random, args.random) if args.scale: reqs += map(package_scale, args.scale)
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete iprange_fmt = { 'uuid': {'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid'])}, 'name': {'title': 'Name', 'len': 20, 'fmt': '%-20s', 'get': lambda e: d(e, ['name'])}, 'tag': {'title': 'Tag', 'len': 10, 'fmt': '%-10s', 'get': lambda e: d(e, ['tag'])}, 'iprange': {'title': 'Iprange', 'len': 15, 'fmt': '%15s', 'get': lambda e: d(e, ['iprange'])}, 'first': {'title': 'First', 'len': 15, 'fmt': '%15s', 'get': lambda e: d(e, ['first'])}, 'next': {'title': 'Next', 'len': 15, 'fmt': '%15s', 'get': lambda e: d(e, ['current'])}, 'last': {'title': 'Last', 'len': 15, 'fmt': '%15s', 'get': lambda e: d(e, ['last'])}, 'returned': {'title': 'Returned', 'len': 15, 'fmt': '%15s', 'get': lambda e: len(d(e, ['free'], []))}, 'gateway': {'title': 'Gateway', 'len': 15, 'fmt': '%15s', 'get': lambda e: d(e, ['gateway'])}, 'netmask': {'title': 'Netmask', 'len': 15, 'fmt': '%15s', 'get': lambda e: d(e, ['netmask'])}, 'vlan': {'title': 'vlan', 'len': 5, 'fmt': '%5s', 'get': lambda e: d(e, ['vlan'])}, } def create(args):
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from .wiggle import Entity from fifo.helper import d, ListAction, show_list, show_get, show_delete hypervisor_fmt = { 'uuid': { 'title': 'UUID', 'len': 36, 'fmt': '%36s', 'get': lambda e: d(e, ['uuid']) }, 'name': { 'title': 'Name', 'len': 30, 'fmt': '%30s', 'get': lambda e: d(e, ['alias']) }, 'free': { 'title': 'Free RAM', 'len': 10, 'fmt': '%10s', 'get': lambda e: str(d(e, ['resources', 'free-memory'])) + 'MB' }, 'used': { 'title': 'Used RAM', 'len': 10, 'fmt': '%10s', 'get': lambda e: str(d(e, ['resources', 'provisioned-memory'])) + 'MB' }, 'reserved': {