def delete(self, namespace): if not namespace: return error(400, 'no namespace specified') if namespace == 'system': return error(403, 'you cannot delete the system namespace') # The namespace must be empty instances = [] deleted_instances = [] for i in db.get_instances(all=True, namespace=namespace): if i['state'] in ['deleted', 'error']: deleted_instances.append(i['uuid']) else: instances.append(i['uuid']) if len(instances) > 0: return error(400, 'you cannot delete a namespace with instances') networks = [] deleted_networks = [] for n in db.get_networks(all=True, namespace=namespace): if n['state'] in ['deleted', 'error']: deleted_networks.append(n['uuid']) else: networks.append(n['uuid']) if len(networks) > 0: return error(400, 'you cannot delete a namespace with networks') db.delete_namespace(namespace) db.delete_metadata('namespace', namespace)
def delete(self, namespace): if not namespace: return api_base.error(400, 'no namespace specified') if namespace == 'system': return api_base.error(403, 'you cannot delete the system namespace') # The namespace must be empty instances = [] deleted_instances = [] for i in instance.instances_in_namespace(namespace): if i.state.value in [dbo.STATE_DELETED, dbo.STATE_ERROR]: deleted_instances.append(i.uuid) else: LOG.withFields({ 'instance': i.uuid, 'state': i.state }).info('Blocks namespace delete') instances.append(i.uuid) if len(instances) > 0: return api_base.error( 400, 'you cannot delete a namespace with instances') networks = [] for n in net.networks_in_namespace(namespace): if not n.is_dead(): LOG.withFields({ 'network': n.uuid, 'state': n.state }).info('Blocks namespace delete') networks.append(n.uuid) if len(networks) > 0: return api_base.error( 400, 'you cannot delete a namespace with networks') db.delete_namespace(namespace) db.delete_metadata('namespace', namespace)
def hard_delete(self): etcd.delete('macaddress', None, self.macaddr) etcd.delete('networkinterface', None, self.uuid) etcd.delete_all('attribute/networkinterface', self.uuid) etcd.delete_all('event/networkinterface', self.uuid) db.delete_metadata('networkinterface', self.uuid)
def hard_delete(self): etcd.delete('instance', None, self.uuid) db.delete_metadata('instance', self.uuid) etcd.delete_all('attribute/instance', self.uuid) etcd.delete_all('event/instance', self.uuid)
def hard_delete(self): etcd.delete('network', None, self.uuid) etcd.delete('vxid', None, self.vxid) etcd.delete_all('attribute/network', self.uuid) etcd.delete_all('event/network', self.uuid) db.delete_metadata('network', self.uuid)