'tags': []})
rspec_node['sliver_id'] = rspec_sliver['sliver_id']
rspec_node['client_id'] = sliver_allocations[sliver['urn']].client_id
+ if sliver_allocations[sliver['urn']].component_id:
+ rspec_node['component_id'] = sliver_allocations[sliver['urn']].component_id
rspec_node['slivers'] = [rspec_sliver]
# slivers always provide the ssh service
site=sites_dict[site_id]
rspec_lease['lease_id'] = lease['lease_id']
- rspec_lease['component_id'] = hostname_to_urn(self.driver.hrn, site['login_base'], lease['hostname'])
+ rspec_lease['component_id'] = PlXrn(self.driver.hrn, hostname=lease['hostname']).urn
slice_hrn = slicename_to_hrn(self.driver.hrn, lease['name'])
slice_urn = hrn_to_urn(slice_hrn, 'slice')
rspec_lease['slice_id'] = slice_urn
slivers = {}
for node in rspec_nodes:
- hostname = None
- client_id = node.get('client_id')
- if node.get('component_name'):
- hostname = node.get('component_name').strip()
- elif node.get('component_id'):
- hostname = xrn_to_hostname(node.get('component_id').strip())
+ hostname = node.get('component_name')
+ client_id = node.get('client_id')
+ component_id = node.get('component_id').strip()
if hostname:
- slivers[hostname] = client_id
+ hostname = hostname.strip()
+ elif component_id:
+ hostname = xrn_to_hostname(component_id)
+ if hostname:
+ slivers[hostname] = {'client_id': client_id, 'component_id': component_id}
nodes = self.driver.shell.GetNodes(slice['node_ids'], ['node_id', 'hostname', 'interface_ids'])
current_slivers = [node['hostname'] for node in nodes]
# update sliver allocations
for node in resulting_nodes:
- client_id = slivers[node['hostname']]
+ client_id = slivers[node['hostname']]['client_id']
+ component_id = slivers[node['hostname']]['component_id']
sliver_hrn = '%s.%s-%s' % (self.driver.hrn, slice['slice_id'], node['node_id'])
sliver_id = Xrn(sliver_hrn, type='sliver').urn
- record = SliverAllocation(sliver_id=sliver_id, client_id=client_id, allocation_state='geni_allocated')
+ record = SliverAllocation(sliver_id=sliver_id, client_id=client_id,
+ component_id=component_id,
+ allocation_state='geni_allocated')
record.sync()
return resulting_nodes
__tablename__ = 'sliver_allocation'
sliver_id = Column(String, primary_key=True)
client_id = Column(String)
+ component_id = Column(String)
allocation_state = Column(String)
def __init__(self, **kwds):
if 'sliver_id' in kwds:
self.sliver_id = kwds['sliver_id']
- if 'sliver_id' in kwds:
+ if 'client_id' in kwds:
self.client_id = kwds['client_id']
+ if 'component_id' in kwds:
+ self.component_id = kwds['component_id']
if 'allocation_state' in kwds:
self.allocation_state = kwds['allocation_state']
def sync(self):
from sfa.storage.alchemy import dbsession
- constraints = [SliverAllocation.sliver_id==self.sliver_id,
- SliverAllocation.client_id==self.client_id,
- SliverAllocation.allocation_state==self.allocation_state]
+ constraints = [SliverAllocation.sliver_id==self.sliver_id]
results = dbsession.query(SliverAllocation).filter(and_(*constraints))
records = []
for result in results:
record = records[0]
record.sliver_id = self.sliver_id
record.client_id = self.client_id
+ record.component_id = self.component_id
record.allocation_state = self.allocation_state
dbsession.commit()