Esempio n. 1
0
    def _handle_default_db_config(server):
        server.db.create_all()
        admin_user = get_admin_user()

        fd, temp_auth_file = tempfile.mkstemp()
        os.close(fd)
        with open(temp_auth_file, 'w') as f:
            yaml.dump(auth_dict, f)

        try:
            # We're mocking the AMQPManager, we aren't really using Rabbit here
            default_tenant = create_default_user_tenant_and_roles(
                admin_username=admin_user['username'],
                admin_password=admin_user['password'],
                amqp_manager=MagicMock(),
                authorization_file_path=temp_auth_file)
            default_tenant.rabbitmq_password = encrypt(
                AMQPManager._generate_user_password())
        finally:
            os.remove(temp_auth_file)

        utils.set_current_tenant(default_tenant)
Esempio n. 2
0
 def put_agent(self,
               agent_name='agent_1',
               instance_id='node_instance_1',
               deployment_id='deployment_1'):
     node_instance = self._get_or_create_node_instance(
         instance_id, deployment_id)
     agent = Agent(id=agent_name,
                   name=agent_name,
                   ip='127.0.0.1',
                   install_method='remote',
                   system='centos core',
                   version='4.5.5',
                   visibility='tenant',
                   state=AgentState.CREATING,
                   rabbitmq_username='******'.format(agent_name),
                   rabbitmq_password=encrypt(
                       AMQPManager._generate_user_password()),
                   rabbitmq_exchange=agent_name,
                   created_at=get_formatted_timestamp(),
                   updated_at=get_formatted_timestamp())
     agent.node_instance = node_instance
     return self.sm.put(agent)