Beispiel #1
0
    def create_sliver (self, slice_urn, slice_hrn, creds, rspec_string, users, options):
   
        aggregate = OSAggregate(self)

        # assume first user is the caller and use their context
        # for the ec2/euca api connection. Also, use the first users
        # key as the project key.
        key_name = None
        if len(users) > 1:
            key_name = aggregate.create_instance_key(slice_hrn, users[0])

        # collect public keys
        pubkeys = []
        for user in users:
            pubkeys.extend(user['keys'])
           
        rspec = RSpec(rspec_string)
        instance_name = hrn_to_os_slicename(slice_hrn)
        tenant_name = OSXrn(xrn=slice_hrn, type='slice').get_tenant_name()
        instances = aggregate.run_instances(instance_name, tenant_name, rspec_string, key_name, pubkeys)
        rspec_nodes = []
        for instance in instances:
            rspec_nodes.append(aggregate.instance_to_rspec_node(slice_urn, instance))    
        version_manager = VersionManager()
        manifest_version = version_manager._get_version(rspec.version.type, rspec.version.version, 'manifest')
        manifest_rspec = RSpec(version=manifest_version, user_options=options)
        manifest_rspec.version.add_nodes(rspec_nodes) 
         
        return manifest_rspec.toxml()
Beispiel #2
0
    def allocate(self, urn, rspec_string, expiration, options={}):
        xrn = Xrn(urn)
        aggregate = OSAggregate(self)

        # assume first user is the caller and use their context
        # for the ec2/euca api connection. Also, use the first users
        # key as the project key.
        key_name = None
        if len(users) > 1:
            key_name = aggregate.create_instance_key(xrn.get_hrn(), users[0])

        # collect public keys
        users = options.get('geni_users', [])
        pubkeys = []
        for user in users:
            pubkeys.extend(user['keys'])

        rspec = RSpec(rspec_string)
        instance_name = hrn_to_os_slicename(slice_hrn)
        tenant_name = OSXrn(xrn=slice_hrn, type='slice').get_tenant_name()
        slivers = aggregate.run_instances(instance_name, tenant_name, \
                                          rspec_string, key_name, pubkeys)

        # update all sliver allocation states setting then to geni_allocated
        sliver_ids = [sliver.id for sliver in slivers]
        dbsession = self.api.dbsession()
        SliverAllocation.set_allocations(sliver_ids, 'geni_provisioned',
                                         dbsession)

        return aggregate.describe(urns=[urn], version=rspec.version)
Beispiel #3
0
    def allocate (self, urn, rspec_string, expiration, options=None):
        if options is None: options={}
        xrn = Xrn(urn) 
        aggregate = OSAggregate(self)

        # assume first user is the caller and use their context
        # for the ec2/euca api connection. Also, use the first users
        # key as the project key.
        key_name = None
        if len(users) > 1:
            key_name = aggregate.create_instance_key(xrn.get_hrn(), users[0])

        # collect public keys
        users = options.get('geni_users', [])
        pubkeys = []
        for user in users:
            pubkeys.extend(user['keys'])
           
        rspec = RSpec(rspec_string)
        instance_name = hrn_to_os_slicename(slice_hrn)
        tenant_name = OSXrn(xrn=slice_hrn, type='slice').get_tenant_name()
        slivers = aggregate.run_instances(instance_name, tenant_name, \
                                          rspec_string, key_name, pubkeys)
        
        # update all sliver allocation states setting then to geni_allocated    
        sliver_ids = [sliver.id for sliver in slivers]
        dbsession=self.api.dbsession()
        SliverAllocation.set_allocations(sliver_ids, 'geni_provisioned',dbsession)
   
        return aggregate.describe(urns=[urn], version=rspec.version)