def rebuild_container_pool(): hosts = Host.query.all() for host in hosts: key = 'eru:agent:%s:containers:meta' % host.name rds.delete(key) for c in host.containers.all(): add_container_for_agent(c)
def remove_ip_pool(self, cidr): try: cidr = IPNetwork(cidr) except (AddrFormatError, ValueError): return name = rds.get(_POOL_NAME_KEY % cidr) rds.delete(_POOL_NAME_KEY % cidr) rds.delete(_POOL_CIDR_KEY % name) _ipam.remove_ip_pool(4, cidr) _ipam.remove_profile(name)
def remove_ip_pool(self, cidr): try: cidr = IPNetwork(cidr) except (AddrFormatError, ValueError): return name = rds.get(_POOL_NAME_KEY % cidr) rds.delete(_POOL_NAME_KEY % cidr) rds.delete(_POOL_CIDR_KEY % name) _ipam.remove_ip_pool(4, cidr) _ipam.remove_profile(name)
def kill_container(id_or_cid): c = _get_container(id_or_cid) c.kill() key = ERU_AGENT_DIE_REASON % c.container_id r = rds.get(key) rds.delete(key) if r is not None: c.set_props({'oom': 1}) c.callback_report(status='die') migrate_container.apply_async(args=(c.container_id, True)) _log.info('Kill container (container_id=%s)', c.container_id) return DEFAULT_RETURN_VALUE
def kill_container(id_or_cid): c = _get_container(id_or_cid) c.kill() key = ERU_AGENT_DIE_REASON % c.container_id r = rds.get(key) rds.delete(key) if r is not None: c.set_props({'oom': 1}) c.callback_report(status='die') migrate_container.apply_async(args=(c.container_id, True)) _log.info('Kill container (container_id=%s)', c.container_id) return DEFAULT_RETURN_VALUE
def fix_core(host): containers = Container.get_multi_by_host(host) # 没有的话, 直接销毁重建 if not containers: _create_cores_on_host(host, host.ncore) return data = {str(i): host.core_share for i in xrange(host.ncore)} for c in containers: cores = c.cores nshare = int(cores.get('nshare', '0')) for e in cores.get('full', []): e.remain = host.core_share data.pop(e.label) for s in cores.get('part', []): s.remain = host.core_share - nshare data[s.label] -= nshare c.cores = cores rds.delete(host._cores_key) if data: rds.zadd(host._cores_key, **data) print 'done', host
def fix_core(host): containers = Container.get_multi_by_host(host) # 没有的话, 直接销毁重建 if not containers: _create_cores_on_host(host, host.ncore) return data = {str(i): host.core_share for i in xrange(host.ncore)} for c in containers: cores = c.cores nshare = int(cores.get('nshare', '0')) for e in cores.get('full', []): e.remain = host.core_share data.pop(e.label) for s in cores.get('part', []): s.remain = host.core_share - nshare data[s.label] -= nshare c.cores = cores rds.delete(host._cores_key) if data: rds.zadd(host._cores_key, **data) print 'done', host
def destroy_props(self): rds.delete(self._property_key)
def _create_cores_on_host(host, count): rds.delete(host._cores_key) data = {str(i): host.core_share for i in xrange(count)} rds.zadd(host._cores_key, **data)
def delete(self): IP.delete_by_network(self.id) rds.delete(self.storekey, self.gatekey) db.session.delete(self) db.session.commit()
def destroy_props(self): rds.delete(self._property_key)
def clean_eip_bound(eip): rds.delete(_EIP_BOUND_KEY % eip)
def _create_cores_on_host(host, count): rds.delete(host._cores_key) data = {str(i): host.core_share for i in xrange(count)} rds.zadd(host._cores_key, **data)
def _del_cores(self): rds.delete(self._cores_key)
def remove_flag_for_agent(container_ids): flags = [_NO_REPORT_KEY % cid for cid in container_ids] rds.delete(*flags)
def remove_flag_for_agent(container_ids): flags = [_NO_REPORT_KEY % cid for cid in container_ids] rds.delete(*flags)
def clean_eip_bound(eip): rds.delete(_EIP_BOUND_KEY % eip)
def _del_cores(self): rds.delete(self._cores_key)
def delete(self): IP.delete_by_network(self.id) rds.delete(self.storekey, self.gatekey) db.session.delete(self) db.session.commit()