Пример #1
0
 def delete(self,request, site_id):
     if not request.user.is_superuser:
         raise PermissionDenied
     site = self._get_instance_by_id(Site, site_id) 
     node = self._get_instance_by_id(Node, site_id) 
     composites = getReferredComRepoForSite(site)
     if(len(composites) != 0): 
         restr = ''
         for x in composites:
             restr = restr+','
             restr = restr + x.name+'in site'+x.site.name
         raise ErrorResponse(status.HTTP_412_PRECONDITION_FAILED,
                             'Repository is referenced by composite ' + restr)
         
    
     if site.name in conf.CONF.get('REPOSITORY_SITES'):
         del conf.CONF.get('REPOSITORY_SITES')[site.name]
         conf.CONF.save()
     if os.path.isdir(site.get_location()):
         oldName=site.get_location()
         newName = site.get_location()+time.strftime('%Y%m%d%H%I%S',time.localtime(time.time()))
         os.rename(oldName, newName)
     #cascading delete site, site's node, repo and repo'nodes, composites and composites' nodes
     dbhandler.delete_site(site.id)   
     return site       
Пример #2
0
def remove_site_from_db(site):
    print('Remove site {} from db'.format(site.name))
    dbhandler.delete_site(site.id);  #all node, repo and repo's node, composite and composite nodes will be deleted
Пример #3
0
def remove_site_from_db(site):
    print('Remove site {} from db'.format(site.name))
    dbhandler.delete_site(site.id)