def install_agent(self, agent_wheel, vip_identity=None, publickey=None, secretkey=None, add_auth=True): while True: agent_uuid = str(uuid.uuid4()) if agent_uuid in self.agents: continue agent_path = os.path.join(self.install_dir, agent_uuid) try: os.mkdir(agent_path) break except OSError as exc: if exc.errno != errno.EEXIST: raise try: if auth is not None and self.env.verify_agents: unpacker = auth.VolttronPackageWheelFile(agent_wheel, certsobj=certs.Certs()) unpacker.unpack(dest=agent_path) else: unpack(agent_wheel, dest=agent_path) final_identity = self._setup_agent_vip_id(agent_uuid, vip_identity=vip_identity) if publickey is not None and secretkey is not None: keystore = self.get_agent_keystore(agent_uuid) keystore.public = publickey keystore.secret = secretkey if add_auth: self._authorize_agent_keys(agent_uuid, final_identity) except Exception: shutil.rmtree(agent_path) raise return agent_uuid
def install_agent(self, agent_wheel, vip_identity=None, publickey=None, secretkey=None): if self.secure_agent_user: _log.info("Installing secure Volttron agent...") while True: agent_uuid = str(uuid.uuid4()) if agent_uuid in self.agents: continue agent_path = os.path.join(self.install_dir, agent_uuid) try: os.mkdir(agent_path) break except OSError as exc: if exc.errno != errno.EEXIST: raise try: if auth is not None and self.env.verify_agents: unpacker = auth.VolttronPackageWheelFile(agent_wheel, certsobj=certs.Certs()) unpacker.unpack(dest=agent_path) else: unpack(agent_wheel, dest=agent_path) # Is it ok to remove the wheel file after unpacking? os.remove(agent_wheel) final_identity = self._setup_agent_vip_id( agent_uuid, vip_identity=vip_identity) keystore = self.get_agent_keystore(agent_uuid, publickey, secretkey) self._authorize_agent_keys(agent_uuid, final_identity, keystore.public) if self.message_bus == 'rmq': rmq_user = get_fq_identity(final_identity, self.instance_name) certs.Certs().create_signed_cert_files(rmq_user, overwrite=False) if self.secure_agent_user: # When installing, we always create a new user, as anything # that already exists is untrustworthy created_user = self.add_agent_user(self.agent_name(agent_uuid), agent_path) self.set_agent_user_permissions(created_user, agent_uuid, agent_path) except Exception: shutil.rmtree(agent_path) raise return agent_uuid
def install_agent(self, agent_wheel): while True: agent_uuid = str(uuid.uuid4()) if agent_uuid in self.agents: continue agent_path = os.path.join(self.install_dir, agent_uuid) try: os.mkdir(agent_path) break except OSError as exc: if exc.errno != errno.EEXIST: raise try: if auth is not None and self.env.verify_agents: unpacker = auth.VolttronPackageWheelFile(agent_wheel, certsobj=certs.Certs()) unpacker.unpack(dest=agent_path) else: unpack(agent_wheel, dest=agent_path) except Exception: shutil.rmtree(agent_path) raise return agent_uuid