def POST(self): consul_host, error = self.get_post_parameter('host') if error: return self.status_error(error) armada_size = _get_armada_size() if armada_size > 1: return self.status_error('Currently only single ship armadas can join the others. ' 'Your armada has size: {0}.'.format(armada_size)) try: agent_self_dict = consul_query('agent/self', consul_address='{0}:8500'.format(consul_host)) datacenter = agent_self_dict['Config']['Datacenter'] except: return self.status_error('Could not read remote host datacenter address.') current_consul_mode = _get_current_consul_mode() if current_consul_mode == consul_config.ConsulMode.BOOTSTRAP: override_runtime_settings(consul_mode=consul_config.ConsulMode.CLIENT, ship_ips=[consul_host], datacenter=datacenter) else: override_runtime_settings(ship_ips=[consul_host] + get_other_ship_ips(), datacenter=datacenter) if _restart_consul(): supervisor_server = xmlrpclib.Server('http://localhost:9001/RPC2') hermes_init_output = supervisor_server.supervisor.startProcessGroup('hermes_init') get_logger().info('hermes_init start: {}'.format(hermes_init_output)) return self.status_ok() return self.status_error('Waiting for armada restart timed out.')
def POST(self): consul_host, error = self.get_post_parameter('host') if error: return self.status_error(error) armada_size = _get_armada_size() if armada_size > 1: return self.status_error( 'Currently only single ship armadas can join the others. ' 'Your armada has size: {armada_size}.'.format( armada_size=armada_size)) try: agent_self_dict = consul_query( 'agent/self', consul_address='{consul_host}:8500'.format(**locals())) datacenter = agent_self_dict['Config']['Datacenter'] except: return self.status_error( 'Could not read remote host datacenter address.') current_consul_mode = _get_current_consul_mode() if current_consul_mode == consul_config.ConsulMode.BOOTSTRAP: override_runtime_settings( consul_mode=consul_config.ConsulMode.CLIENT, ship_ips=[consul_host], datacenter=datacenter) else: override_runtime_settings(ship_ips=[consul_host] + get_other_ship_ips(), datacenter=datacenter) if _restart_consul(): return self.status_ok() return self.status_error('Waiting for armada restart timed out.')
def POST(self): consul_host, error = self.get_post_parameter('host') if error: return self.status_error(error) armada_size = _get_armada_size() if armada_size > 1: return self.status_error('Currently only single ship armadas can join the others. ' 'Your armada has size: {armada_size}.'.format(armada_size=armada_size)) try: agent_self_dict = consul_query('agent/self', consul_address='{consul_host}:8500'.format(**locals())) datacenter = agent_self_dict['Config']['Datacenter'] except: return self.status_error('Could not read remote host datacenter address.') current_consul_mode = _get_current_consul_mode() if current_consul_mode == consul_config.ConsulMode.BOOTSTRAP: override_runtime_settings(consul_mode=consul_config.ConsulMode.CLIENT, ship_ips=[consul_host], datacenter=datacenter) else: override_runtime_settings(ship_ips=[consul_host] + get_other_ship_ips(), datacenter=datacenter) if _restart_consul(): return self.status_ok() return self.status_error('Waiting for armada restart timed out.')
def POST(self): ship_name, error = self.get_post_parameter('name') if error: return self.status_error(error) other_ship_names = [get_ship_name(ip) for ip in get_other_ship_ips()] name_taken = ship_name in other_ship_names if not ship_name or ship_name == 'None' or name_taken: return self.status_error('Incorrect ship name: {}'.format(ship_name)) set_ship_name(ship_name) return self.status_ok()
def POST(self): ship_name, error = self.get_post_parameter('name') if error: return self.status_error(error) other_ship_names = [get_ship_name(ip) for ip in get_other_ship_ips()] name_taken = ship_name in other_ship_names if not ship_name or ship_name == 'None' or name_taken: return self.status_error( 'Incorrect ship name: {}'.format(ship_name)) set_ship_name(ship_name) return self.status_ok()
def POST(self): consul_host, error = self.get_post_parameter('host') if error: return self.status_error(error) ship = get_ship_name() local_services = kv.kv_list('ships/{}/service/'.format(ship)) or [] local_services_data = {key: kv.kv_get(key) for key in local_services} armada_size = _get_armada_size() if armada_size > 1: return self.status_error( 'Currently only single ship armadas can join the others. ' 'Your armada has size: {0}.'.format(armada_size)) try: agent_self_dict = consul_query( 'agent/self', consul_address='{0}:8500'.format(consul_host)) datacenter = agent_self_dict['Config']['Datacenter'] except: return self.status_error( 'Could not read remote host datacenter address.') current_consul_mode = _get_current_consul_mode() if current_consul_mode == consul_config.ConsulMode.BOOTSTRAP: override_runtime_settings( consul_mode=consul_config.ConsulMode.CLIENT, ship_ips=[consul_host], datacenter=datacenter) else: override_runtime_settings(ship_ips=[consul_host] + get_other_ship_ips(), datacenter=datacenter) if _restart_consul(): supervisor_server = xmlrpclib.Server('http://localhost:9001/RPC2') hermes_init_output = supervisor_server.supervisor.startProcessGroup( 'hermes_init') get_logger().info( 'hermes_init start: {}'.format(hermes_init_output)) set_ship_name(ship) for key, data in local_services_data.items(): kv.kv_set(key, data) return self.status_ok() return self.status_error('Waiting for armada restart timed out.')