def see_slice(): c = loadContext("/tmp/context.json", key_passphrase='TeFxy^FVv8Z5') print(c.cf.listProjects(c)) cl.do_release(c, 'testing138', ['cl-utah']) #cl.release(experiment_name='testing136', # cloudlab_user='******', # cloudlab_password='******', # cloudlab_project='Consensus', ## cloudlab_cert_path='cloudlab.pem', # cloudlab_key_path='~/.ssh/id_ed25519.pub') print("Available slices: {}".format(c.cf.listSlices(c).keys()))
def get_slice(cloudlab_user, cloudlab_password, cloudlab_project, cloudlab_cert_path, cloudlab_key_path, experiment_name, expiration=120, create_if_not_exists=False, renew_slice=False): cloudlab_user = check_var(cloudlab_user, 'CLOUDLAB_USER') cloudlab_password = check_var(cloudlab_password, 'CLOUDLAB_PASSWORD') cloudlab_project = check_var(cloudlab_project, 'CLOUDLAB_PROJECT') cloudlab_cert_path = check_var(cloudlab_cert_path, 'CLOUDLAB_CERT_PATH') cloudlab_key_path = check_var(cloudlab_key_path, 'CLOUDLAB_PUBKEY_PATH') with open('/tmp/context.json', 'w') as f: data = { "framework": "emulab-ch2", "cert-path": cloudlab_cert_path, "key-path": cloudlab_cert_path, "user-name": cloudlab_user, "user-urn": "urn:publicid:IDN+emulab.net+user+" + cloudlab_user, "user-pubkeypath": cloudlab_key_path, "project": cloudlab_project } json.dump(data, f) print("Loading GENI context") print(cloudlab_password) c = loadContext("/tmp/context.json", key_passphrase=cloudlab_password) slice_id = ("urn:publicid:IDN+emulab.net:{}+slice+{}").format( cloudlab_project, experiment_name) exp = datetime.datetime.now() + datetime.timedelta(minutes=expiration) print("Available slices: {}".format(c.cf.listSlices(c).keys())) if slice_id in c.cf.listSlices(c): print("Using existing slice {}".format(slice_id)) if renew_slice: print("Renewing slice for {} more minutes".format(expiration)) c.cf.renewSlice(c, experiment_name, exp=exp) else: if create_if_not_exists: print("Creating slice {} ({} minutes)".format( slice_id, expiration)) c.cf.createSlice(c, experiment_name, exp=exp) else: print("We couldn't find a slice for {}.".format(experiment_name)) return None return c
def main(sname, site, of_vlan=False, of_controller=None): # Load GENI credentials context = util.loadContext(key_passphrase=True) # Make a basic request with two VMs r = PG.Request() vms = [] for idx in range(0, 2): vm = r.XenVM("vm%d" % (idx)) vm.addInterface("if0") vms.append(vm) lnk = r.Link() lnk.addInterface(vms[0].interfaces[0]) lnk.addInterface(vms[1].interfaces[0]) # Openflow-enable this link if requested if of_vlan: lnk.addChild(IGX.OFController(of_controller[0], of_controller[1])) # Find nodes that support VMs at the requested site ad = site.listresources(context) vmnodes = [] for node in ad.nodes: if IGU.shared_xen(node): vmnodes.append(node) # Bind request VMs to different nodes by component_id for (vm, node) in zip(vms, vmnodes): vm.component_id = node.component_id # Save the request r.writeXML("%s-%s-request.xml" % (sname, site.name)) # Make the reservation m = site.createsliver(context, sname, r) # Save the manifest m.writeXML("%s-%s-manifest.xml" % (sname, site.name)) # Output login info to stdout util.printlogininfo(manifest=m)
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_list = list() node_count = int(os.environ['NODE_COUNT']) slice_name = str(os.environ['NODE_SLICE']) # Create the raw "PC" nodes for _idx in range(0, node_count): node = request.RawPC('node_{}'.format(_idx)) node.hardware_type = str(os.environ['NODE_HARDWARE']) node_list.append(node) # Create a link between them link1 = request.Link(members=node_list) # load context ctx = util.loadContext(path="/geni-context.json", key_passphrase=os.environ['GENI_KEY_PASSPHRASE']) # create slice util.createSlice(ctx, slice_name, 300, True) # 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
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.")
def create_cluster(slice_name, nodes=constants.DEFAULT_CLUSTER_SIZE, site=constants.DEFAULT_SITE): # Creating the context. context = geniutil.loadContext(key_passphrase=constants.PASS_PHRASE) # Creating the slice. result = create_slice(slice_name, context) if result == 1: print "cloudlab_setup.py :: create_cluster :: Could not create the slice :: ", slice_name exit(-1) # Creating the (standard) RSpec. rspec = cloudlab_profile.create_std_RSpec(nodes) # Obtaining the site details. if site == constants.SITE_UTAH: aggregate = cloudlab.Utah elif site == constants.SITE_WISCONSIN: aggregate = cloudlab.Wisconsin elif site == constants.SITE_CLEMSON: aggregate = cloudlab.Clemson elif site == constants.SITE_APT: aggregate = cloudlab.Apt else: print "cloudlab_setup.py :: create_cluster :: Invalid site details entered. Should be one of utah|wisc|clemson|apt" # Creating the experiment. try: result = aggregate.createsliver(context, slice_name, rspec) except Exception as excep: print excep exit(-1) print "cloudlab_setup.py :: create_cluster :: Created silver", result.__dict__ # Extracting the nodes from the status. output = subprocess.check_output(shlex.split( "java -cp xml_processor/build/XMLProcessor.jar edu.missouri.core.XPathProcessor '" + aggregate.listresources( context, slice_name).__dict__.get("_xml") + "' '//login/@hostname'")).rstrip() node_lst = [x.strip() for x in output[1:-1].split(",")] print "cloudlab_setup.py :: create_cluster :: node_lst:: ", node_lst # Extracting the ports from the status. output = subprocess.check_output(shlex.split( "java -cp xml_processor/build/XMLProcessor.jar edu.missouri.core.XPathProcessor '" + aggregate.listresources( context, slice_name).__dict__.get("_xml") + "' '//login/@port'")).rstrip() port_lst = [x.strip() for x in output[1:-1].split(",")] print "cloudlab_setup.py :: create_cluster :: port_lst:: ", port_lst # Setting up ssh client. ssh = paramiko.SSHClient() sshkey = paramiko.RSAKey.from_private_key_file(constants.PRIVATE_KEY_PATH) ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # Waiting for the experiment to finish setting up. print "cloudlab_setup.py :: create_cluster :: Awaiting completion of provisioning." time.sleep(500) # Creating a status dictionary for auditing the node status. status_dict = {} # Verifying the nodes provisioned. for node, port in zip(node_lst, port_lst): # Skipping dataset login validation. if port != "22": continue tries = 0 while constants.MAX_RETRIES > tries: try: ssh.connect(hostname=node, port=22, username=constants.USER_NAME, pkey=sshkey) status_dict[node] = True break except Exception as e: time.sleep(60) tries += 1 status_dict[node] = False print e, "\n cloudlab_setup.py :: create_cluster :: Retrying ", node, " ..." if not all(value for value in status_dict.values()): print "cloudlab_setup.py :: create_cluster :: Not all nodes were provisioned. Details :: ", status_dict exit(-1) else: print "cloudlab_setup.py :: create_cluster :: Successfully provisioned all nodes." return node_lst