def server_host_delete(server_id, host_id): svr = server.get_server(id=server_id) hst = host.get_host(id=host_id) svr.remove_host(hst) svr.commit(svr.changed) event.Event(type=SERVER_HOSTS_UPDATED, resource_id=svr.id) return utils.jsonify({})
def server_host_delete(server_id, host_id): svr = server.get_server(id=server_id) hst = host.get_host(id=host_id) svr.remove_host(hst) svr.commit(svr.changed) event.Event(type=SERVER_HOSTS_UPDATED, resource_id=svr.id) return utils.jsonify({})
def host_delete(host_id): hst = host.get_host(id=host_id) hst.remove() logger.LogEntry(message='Deleted host "%s".' % hst.name) event.Event(type=HOSTS_UPDATED) return utils.jsonify({})
def link_instance(self, host_id): if self.interrupt: return instance_link = ServerInstanceLink( server=self.server, linked_server=self.server, linked_host=host.get_host(id=host_id), ) self.replica_links[host_id] = instance_link instance_link.start()
def host_get(host_id=None): if host_id: return utils.jsonify(host.get_host(id=host_id).dict()) hosts = [] for hst in host.iter_hosts(): hosts.append(hst.dict()) return utils.jsonify(hosts)
def server_host_put(server_id, host_id): svr = server.get_server(id=server_id) hst = host.get_host(id=host_id) svr.add_host(hst) svr.commit(svr.changed) event.Event(type=SERVER_HOSTS_UPDATED, resource_id=svr.id) return utils.jsonify({ 'id': hst.id, 'server': svr.id, 'status': ONLINE if svr_hst_id == hst.id else OFFLINE, 'name': hst.name, 'public_address': hst.public_addr, })
def server_host_put(server_id, host_id): svr = server.get_server(id=server_id) hst = host.get_host(id=host_id) svr.add_host(hst) svr.commit(svr.changed) event.Event(type=SERVER_HOSTS_UPDATED, resource_id=svr.id) return utils.jsonify({ 'id': hst.id, 'server': svr.id, 'status': ONLINE if svr_hst_id == hst.id else OFFLINE, 'name': hst.name, 'public_address': hst.public_addr, })
def iter_hosts(self): for host_id in self.hosts: hst = host.get_host(id=host_id) if hst: yield hst else: logger.error('Removing non-existent host ' + 'from server. %r' % { 'server_id': self.id, 'host_id': host_id, }) self.remove_host(host_id) self.commit('hosts') event.Event(type=SERVER_HOSTS_UPDATED, resource_id=self.id)
def iter_hosts(self): for host_id in self.hosts: hst = host.get_host(id=host_id) if hst: yield hst else: logger.error('Removing non-existent host ' + 'from server. %r' % { 'server_id': self.id, 'host_id': host_id, }) self.remove_host(host_id) self.commit('hosts') event.Event(type=SERVER_HOSTS_UPDATED, resource_id=self.id)
def host_put(host_id=None): hst = host.get_host(id=host_id) if 'name' in flask.request.json: hst.name = utils.filter_str( flask.request.json['name']) or utils.random_name() if 'public_address' in flask.request.json: hst.public_address = utils.filter_str( flask.request.json['public_address']) hst.commit(hst.changed) event.Event(type=HOSTS_UPDATED) return utils.jsonify(host.dict())
def get_host(self, host_id): if host_id in self.hosts: return host.get_host(id=host_id)
def get_host(self, host_id): if host_id in self.hosts: return host.get_host(id=host_id)
def host_usage_get(host_id, period): hst = host.get_host(id=host_id) return utils.jsonify(hst.usage.get_period(period))