def setUp(self): self.agent_conf_dir = mkdtemp(delete=True) state = State(os.path.join(self.agent_conf_dir, "state.json")) common.services.register(ServiceName.MODE, Mode(state)) common.services.register(ServiceName.DATASTORE_TAGS, DatastoreTags(state)) self.agent = AgentConfig(["--config-path", self.agent_conf_dir])
def __init__(self, id, networks, datastores, cpu, mem, disk, overcommit): self.id = id self.cpu = cpu self.mem = mem self.disk = disk self.parent = "" self.constraints = set() host_constraint = ResourceConstraint(ResourceConstraintType.HOST, ["host-" + str(id)]) self.constraints.add(host_constraint) [self.constraints.add(net) for net in networks] [self.constraints.add(ds) for ds in datastores] self.address = "" self.port = "" conf_dir = mkdtemp(delete=True) state = State(os.path.join(conf_dir, "state.json")) common.services.register(ServiceName.MODE, Mode(state)) self.hv = self._get_hypervisor_instance( id, cpu, mem, disk, [ds.values[0] for ds in datastores], [network.values[0] for network in networks], overcommit) # need agent_config for create/delete vm. agent_config = AgentConfig([ "--config-path", conf_dir, "--hostname", "localhost", "--port", "1234", "--host-id", id ]) common.services.register(ServiceName.AGENT_CONFIG, agent_config) super(Host, self).__init__(self.hv)
def _register_services(self): common.services.register(ServiceName.AGENT_CONFIG, self._config) common.services.register(ServiceName.LOCKED_VMS, ExclusiveSet()) threadpool = RequestIdExecutor( ThreadPoolExecutor(self._config.workers)) common.services.register(ThreadPoolExecutor, threadpool) self._registrant = ChairmanRegistrant(self._config.chairman_list) self._config.on_config_change(self._config.CHAIRMAN, self._registrant.update_chairman_list) common.services.register(ServiceName.REGISTRANT, self._registrant) state_json_file = os.path.join( self._config.options.config_path, self._config.DEFAULT_STATE_FILE) state = State(state_json_file) mode = Mode(state) mode.on_change(self._registrant.trigger_chairman_update) common.services.register(ServiceName.MODE, mode) ds_tags = DatastoreTags(state) ds_tags.on_change(self._registrant.trigger_chairman_update) common.services.register(ServiceName.DATASTORE_TAGS, ds_tags)
def __init__(self, config_handler: ConfigHandler) -> None: super().__init__() self._config_handler = config_handler self._time_since_last_throttle_steering_eval = time.time() self._request_handler = RequestHandler(config_handler) self._mode = Mode() self._thread = VehicleCtlThread() # This represents the last command we sent to the vehicle. It is needed to interpolate # between the current command and the target command. self._last_cmd_sent = Command() # The logical "Gear" we are working with. FIRST, REVERSE, or NEUTRAL # This is used when we are preparing the command to send to the vehicle self._gear = Gear.DRIVE # These represents the intended speed/direction of the vehicle # VehicleCtlThread uses the target_acceleration to compute a target throttle, # allowing us to roll onto the throttle, rather than FLOOR IT when the user presses 'forward'. # Steering, however, is NOT interpolated, and for good reason. If a user steers hard to the left, # we want the wheels to go to that position as quickly as possible. self._target_acceleration = 0 self._target_steering = self._last_cmd_sent.get_steering() # Defines the behavior for our thread loop self._thread.behave = lambda: self.throttle_steering_eval() self._stream_port = self._config_handler.get_config_value_or( 'stream_port', 4000)
def setup(self): self.state_file = tempfile.mktemp() self._host_handler = MagicMock() common.services.register(Host.Iface, self._host_handler) common.services.register(ServiceName.MODE, Mode(State(self.state_file))) common.services.register(ServiceName.AGENT_CONFIG, MagicMock())
def setUp(self): self.agent_conf_dir = mkdtemp(delete=True) state = State(os.path.join(self.agent_conf_dir, "state.json")) common.services.register(ServiceName.MODE, Mode(state)) common.services.register(ServiceName.DATASTORE_TAGS, DatastoreTags(state)) self.multi_agent = MultiAgent(2200, AgentConfig.DEFAULT_CONFIG_PATH, AgentConfig.DEFAULT_CONFIG_FILE) self.agent = AgentConfig(["--config-path", self.agent_conf_dir])
def _register_services(self): common.services.register(ServiceName.AGENT_CONFIG, self._config) common.services.register(ServiceName.LOCKED_VMS, ExclusiveSet()) state_json_file = os.path.join(self._config.options.config_path, self._config.DEFAULT_STATE_FILE) state = State(state_json_file) mode = Mode(state) common.services.register(ServiceName.MODE, mode)
def setup(self): self._threadpool = ThreadPoolExecutor(16) self.state_file = tempfile.mktemp() common.services.register(ThreadPoolExecutor, self._threadpool) self._host_handler = MagicMock() common.services.register(Host.Iface, self._host_handler) common.services.register(ServiceName.MODE, Mode(State(self.state_file))) common.services.register(ServiceName.AGENT_CONFIG, MagicMock()) common.services.register(ServiceName.DATASTORE_TAGS, DatastoreTags(State(self.state_file)))
def _register_services(self): common.services.register(ServiceName.AGENT_CONFIG, self._config) common.services.register(ServiceName.LOCKED_VMS, ExclusiveSet()) threadpool = RequestIdExecutor(ThreadPoolExecutor( self._config.workers)) common.services.register(ThreadPoolExecutor, threadpool) state_json_file = os.path.join(self._config.options.config_path, self._config.DEFAULT_STATE_FILE) state = State(state_json_file) mode = Mode(state) common.services.register(ServiceName.MODE, mode)
def __init__(self): self.config_handler = ConfigHandler.get_instance() # Populate our peripheral list from the config self.peripherals = {} peripheral_list = self.config_handler.get_config_value_or( 'peripheral_list', []) for peripheral in peripheral_list: if peripheral == 'distance_sensor': self.peripherals['distance_sensor'] = DistanceSensor() if peripheral == 'segmented_display': self.peripherals['segmented_display'] = SegmentedDisplay() if peripheral == 'cpu_fan': self.peripherals['cpu_fan'] = CpuFan() if peripheral == 'stereo_camera': self.peripherals['stereo_camera'] = StereoCamera() self.mode = Mode()
def setUp(self): self.hostname = "localhost" self.host_port = 1234 self.availability_zone_id = "test" self.host_addr = ServerAddress(self.hostname, self.host_port) self.chairman_list = [] self.agent_id = "foo" self.host_config = HostConfig(self.agent_id, self.availability_zone_id, [Datastore("bar")], self.host_addr, [Network("nw1")]) self.registrant = ChairmanRegistrant(self.chairman_list) host_handler = MagicMock() host_handler.get_host_config_no_logging.return_value = \ GetConfigResponse(hostConfig=self.host_config) common.services.register(Host.Iface, host_handler) self.request = RegisterHostRequest("foo", self.host_config) self.state_file = tempfile.mktemp() common.services.register(ServiceName.MODE, Mode(State(self.state_file)))
def setUp(self): self._threadpool = ThreadPoolExecutor(16) self.state_file = tempfile.mktemp() self.state = CommonState(self.state_file) common.services.register(ThreadPoolExecutor, self._threadpool) common.services.register(ServiceName.REQUEST_ID, threading.local()) common.services.register(ServiceName.LOCKED_VMS, ExclusiveSet()) common.services.register(ServiceName.MODE, Mode(self.state)) self.agent_conf_dir = mkdtemp(delete=True) self.hostname = "localhost" self._config = MagicMock() self._config.hypervisor = "fake" self._config.agent_id = stable_uuid("agent_id") self._config.hostname = "localhost" self._config.host_port = 1234 self._config.host_version = "X.X.X" self._config.reboot_required = False self._config.image_datastores = [] common.services.register(ServiceName.AGENT_CONFIG, self._config)
def setUp(self): self.file_location = tempfile.mkstemp()[1] self.state = State(self.file_location) self.mode = Mode(self.state)
def mode_changed(self, index): mode_int = self._cbo_mode.currentData() mode = Mode() mode.set_mode(mode_int) self._vehicle_ctl.set_mode(mode)
def setUp(self): self.agent_conf_dir = mkdtemp(delete=True) state = State(os.path.join(self.agent_conf_dir, "state.json")) common.services.register(ServiceName.MODE, Mode(state)) common.services.register(ServiceName.REGISTRANT, mock.MagicMock()) self.agent = AgentConfig(["--config-path", self.agent_conf_dir])