"""
fields = {
- 'id': Parameter(str, "User identifier"),
+ 'person_id': Parameter(str, "User identifier"),
'name': Parameter(str, "Given name", max = 128),
'email': Parameter(str, "Primary e-mail address", max = 254),
'enabled': Parameter(bool, "Has been enabled"),
'tenant_ids': Parameter(str, "Site identifier"),
#'last_updated': Parameter(int, "Date and time of last update"),
#'date_created': Parameter(int, "Date and time when account was created"),
- 'roles': Parameter([str], "List of roles", ro=True),
- 'key_ids': Parameter([str], "List of key identifiers", ro=True),
- 'slice_ids': Parameter([int], "List of slice identifiers", ro=True),
+ 'roles': Parameter([str], "List of roles", joined=True),
+ 'key_ids': Parameter([str], "List of key identifiers", joined=True),
+ 'slice_ids': Parameter([int], "List of slice identifiers", joined=True),
}
def validate_email(self, email):
assert isinstance(person, Person)
- if self.id == person.id:
+ if self.person_id == person.person_id:
return True
if 'admin' in self['roles']:
def sync(self, insert=False, validate=True):
NovaObject.sync(self, insert, validate)
- if insert == True or id not in self:
+ if insert == True or 'person_id' not in self:
self.object = self.api.client_shell.keystone.users.create(**self)
def delete(self):
# delete relationships
- SlicePerson().delete.filter({'person_id': self['id']})
+ SlicePerson().delete.filter({'person_id': self['person_id']})
# delete nova object
user = self.api.client_shell.keystone.users.find(**self)
fields = {
'enabled': Parameter(bool, "Has been enabled"),
- 'id': Parameter(str, "Site identifier"),
+ 'site_id': Parameter(str, "Site identifier"),
'tenant_id': Parameter(str, "Tenant identifier"),
'abbreviated_name': Parameter(str, "Abbreviated site name", max = 50),
'login_base': Parameter(str, "Site slice prefix", max = 20),
'last_updated': Parameter(int, "Date and time when site entry was last updated, in seconds since UNIX epoch", ro = True),
'max_slices': Parameter(int, "Maximum number of slices that the site is able to create"),
'max_slivers': Parameter(int, "Maximum number of slivers that the site is able to create"),
- 'person_ids': Parameter([int], "List of account identifiers", ro=True),
- 'slice_ids': Parameter([int], "List of slice identifiers", ro=True),
- 'address_ids': Parameter([int], "List of address identifiers"),
- 'pcu_ids': Parameter([int], "List of PCU identifiers", ro=True),
- 'node_ids': Parameter([int], "List of site node identifiers", ro=True),
- 'site_tag_ids' : Parameter ([int], "List of tags attached to this site", ro=True),
+ 'person_ids': Parameter([int], "List of account identifiers", joined=True),
+ 'slice_ids': Parameter([int], "List of slice identifiers", joined=True),
+ 'address_ids': Parameter([int], "List of address identifiers", joined=True),
+ 'pcu_ids': Parameter([int], "List of PCU identifiers", joined=True),
+ 'node_ids': Parameter([int], "List of site node identifiers", joined=True),
+ 'site_tag_ids' : Parameter ([int], "List of tags attached to this site", joined=True),
'peer_id': Parameter(int, "Peer to which this site belongs", nullok = True),
'peer_site_id': Parameter(int, "Foreign site identifier at peer", nullok = True),
'ext_consortium_id': Parameter(int, "external consortium id", nullok = True)
nova_can_update = lambda (field, value): field in nova_fields
nova_site = dict(filter(nova_can_update, self.items()))
AlchemyObj.sync(self, insert, validate)
- if insert == True or 'id' not in self:
+ if insert == True or 'site_id' not in self:
self.object = self.api.client_shell.keystone.tenants.create(**nova_site)
self['tenant_id'] = self.object.id
AlchemyObj.insert(self, dict(self))
self.object = self.api.client_shell.keystone.tenants.update(self['tenant_id'], **nova_site)
AlchemyObj.update(self, dict(self))
- def delete(self):
+ def delete(self, commit=True):
# delete nova object
tenant = self.api.client_shell.keystone.tenants.find(id=self['tenant_id'])
self.api.client_shell.keystone.tenants.delete(tenant)
# delete relationships
- SitePerson().delete(filter={'site_id': self['id']})
- Slice().delete(filter={'site_id': self['id']})
- PCU().delete(filter={'site_id': self['id']})
- Node().delete(filter={'site_id': self['id']})
- Address().delete(filter={'site_id': self['id']})
- SiteTag().delete(filter={'site_id': self['id']})
+ SitePerson().delete(filter={'site_id': self['site_id']})
+ Slice().delete(filter={'site_id': self['site_id']})
+ PCU().delete(filter={'site_id': self['site_id']})
+ Node().delete(filter={'site_id': self['site_id']})
+ Address().delete(filter={'site_id': self['site_id']})
+ SiteTag().delete(filter={'site_id': self['site_id']})
# delete site
AlchemyObj.delete(self, dict(self))
-class Sites(NovaTable):
+class Sites(list):
"""
Representation of row(s) from the sites table in the
database.
if not site_filter:
sites = Site().select()
elif isinstance(site_filter, int):
- sites = Site().select(filter={'id': site_filter})
+ sites = Site().select(filter={'site_id': site_filter})
elif isinstance(site_filter, StringTypes):
sites = Site().select(filter={'login_base': site_filter})
elif isinstance(site_filter, dict):
tablename = 'slices'
fields = {
- 'id': Parameter(int, "Slice identifier", primary_key=True),
+ 'slice_id': Parameter(int, "Slice identifier", primary_key=True),
'site_id': Parameter(int, "Identifier of the site to which this slice belongs"),
'name': Parameter(str, "Slice name", max = 32),
'instantiation': Parameter(str, "Slice instantiation state", nullok=True),
'creator_person_id': Parameter(str, "Identifier of the account that created this slice"),
'created': Parameter(datetime, "Date and time when slice was created, in seconds since UNIX epoch", ro = True),
'expires': Parameter(datetime, "Date and time when slice expires, in seconds since UNIX epoch"),
- 'node_ids': Parameter([str], "List of nodes in this slice", ro = True),
- 'person_ids': Parameter([str], "List of accounts that can use this slice", ro = True),
- 'slice_tag_ids': Parameter([int], "List of slice attributes", ro = True),
+ 'node_ids': Parameter([str], "List of nodes in this slice", joined = True),
+ 'person_ids': Parameter([str], "List of accounts that can use this slice", joined = True),
+ 'slice_tag_ids': Parameter([int], "List of slice attributes", joined = True),
'peer_id': Parameter(int, "Peer to which this slice belongs", nullok = True),
'peer_slice_id': Parameter(int, "Foreign slice identifier at peer", nullok = True),
}
conflicts = Slices(self.api, [name])
for slice in conflicts:
- if 'id' not in self or self['id'] != slice.id:
+ if 'slice_id' not in self or self['slice_id'] != slice.slice_id:
raise PLCInvalidArgument, "Slice name already in use, %s"%name
return name
Add or update a slice.
"""
AlchemyObj.sync(self, commit, validate)
- if 'id' not in self:
+ if 'slice_id' not in self:
# Before a new slice is added, delete expired slices
#expired = Slices(self.api, expires = -int(time.time()))
#for slice in expired:
# slice.delete(commit)
AlchemyObj.insert(self, dict(self))
else:
- AlchemyObj.update(self, self['id'], dict(self))
+ AlchemyObj.update(self, self['slice_id'], dict(self))
def delete(self, commit = True):
"""
Delete existing slice.
"""
- assert 'id' in self
+ assert 'slice_id' in self
# delete relationships
- SlicePerson().delete(self, filter={'slice_id': self['id']})
- SliceNode().delete(self, filter={'slice_id': self['id']})
- SliceTag().delete(self, filter={'slice_id': self['id']})
+ SlicePerson().delete(self, filter={'slice_id': self['slice_id']})
+ SliceNode().delete(self, filter={'slice_id': self['slice_id']})
+ SliceTag().delete(self, filter={'slice_id': self['slice_id']})
AlchemyObj.delete(self, dict(self))