def run(experiment, expiration, site_name, groups, hw_type, img, with_lan): site = sites.get(site_name, None) if not site: raise Exception('Unknown site name: {}'.format(site_name)) if len(sys.argv) != 2: raise Exception( "Expecting only 1 argument: apply, destroy, renew or inventory") cmd = sys.argv[1] out_dir = os.getcwd() if cmd == 'get-inventory': print('Creating Ansible inventory from GENI manifest.') geni_out_dir = out_dir + '/geni' ansible_out_dir = out_dir + '/ansible' if not os.path.isdir(geni_out_dir): os.makedirs(geni_out_dir) if not os.path.isdir(ansible_out_dir): os.makedirs(ansible_out_dir) manifest_path = geni_out_dir + '/manifest.xml' util.xmlManifestToAnsibleInventory(manifest_path, groups=groups, hostsfile=ansible_out_dir + '/hosts', format='yaml') sys.exit(0) # load context ctx = util.loadCtx() if cmd == 'destroy': util.deleteSliverExists(site, ctx, experiment) sys.exit(0) # create slice util.createSlice(ctx, experiment, expiration=expiration, renew_if_exists=True) if cmd == 'renew': sys.exit(0) if cmd != 'apply': print("Unknown command '{}'".format(cmd)) sys.exit(1) request = create_request(img, hw_type, groups, with_lan) # create sliver on selected site manifest = util.createSliver(ctx, site, experiment, request) # write manifest manifest.writeXML(out_dir + '/geni/manifest.xml')
import os from geni.aggregate import cloudlab from geni import util ctx = util.loadContext(key_passphrase=os.environ['GENI_KEY_PASSPHRASE']) print("Available slices: {}".format(ctx.cf.listSlices(ctx).keys())) if util.sliceExists(ctx, 'popperized'): print('Slice exists.') print('Removing all existing slivers (errors are ignored)') util.deleteSliverExists(cloudlab.Clemson, ctx, 'popperized') else: print("Slice does not exist.")
node.disk_image = ("urn:publicid:IDN+clemson.cloudlab.us+image+" "schedock-PG0:ubuntu18-docker") node.hardware_type = 'c6320' request = pg.Request() request.addResource(node) # } # create slice util.createSlice(ctx, experiment_name) # create sliver on clemson manifest = util.createSliver(ctx, cloudlab.Clemson, experiment_name, request) print(manifest.text) elif command == 'destroy': print("Available slices: {}".format(ctx.cf.listSlices(ctx).keys())) if util.sliceExists(ctx, experiment_name): print('Slice exists.') print('Removing all existing slivers (errors are ignored)') util.deleteSliverExists(cloudlab.Clemson, ctx, experiment_name) else: print("Slice does not exist.") else: raise Exception("Unknown command '{}'".format(command))
import os from geni.aggregate import cloudlab from geni import util slice_name = str(os.environ['NODE_SLICE']) ctx = util.loadContext("/geni-context.json", key_passphrase=os.environ['GENI_KEY_PASSPHRASE']) print("Available slices: {}".format(ctx.cf.listSlices(ctx).keys())) # identify the cluster cluster = str(os.environ['NODE_CLUSTER']) if cluster == 'utah': cluster = cloudlab.Utah elif cluster == 'wisconsin': cluster = cloudlab.Wisconsin elif cluster == 'clemson': cluster = cloudlab.Clemson if util.sliceExists(ctx, slice_name): print('Slice exists.') print('Removing all existing slivers (errors are ignored)') util.deleteSliverExists(cluster, ctx, slice_name) else: print("Slice does not exist.")
import os from geni.aggregate import cloudlab from geni import util ctx = util.loadContext(key_passphrase=os.environ['GENI_KEY_PASSPHRASE']) print("Available slices: {}".format(ctx.cf.listSlices(ctx).keys())) if util.sliceExists(ctx, 'popper-examples'): print('Slice exists.') print('Removing sliver (errors are ignored)') util.deleteSliverExists(cloudlab.Clemson, ctx, 'popper-examples') else: print("Slice does not exist.")