This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Complete Guide: Creating a Custom Foreman Plugin with REST API | |
| ======================================================= | |
| Table of Contents: | |
| ----------------- | |
| 1. Directory Structure | |
| 2. Plugin Files | |
| 3. API Implementation | |
| 4. Database | |
| 5. Installation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Foreman Custom API for MCO Tasks | |
| ================================ | |
| 1. Enhanced Controller Logic (app/controllers/foreman_mco_tasks/tasks_controller.rb): | |
| module ForemanMcoTasks | |
| class TasksController < ApplicationController | |
| # Skip CSRF token verification for API calls | |
| skip_before_action :verify_authenticity_token, only: [:execute] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ## Assigned Variable | |
| DOMAIN_HOME= | |
| ADMIN_SERVER_LOG=/tmp/admin.log | |
| NODEMANAGER_LOG=/tmp/nodemgr.log | |
| WL_HOME= | |
| SERVER_LOG= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Set WebLogic environment variables | |
| export DOMAIN_HOME=/weblogic/Oracle/Middleware/Oracle_Home/user_projects/domains/dlpuatapp_domain/ # Change this to your domain path | |
| export WL_HOME=/weblogic/Oracle/Middleware/Oracle_Home/oracle_common/common/ # Change this to your WebLogic installation path | |
| # Paths to logs | |
| ADMIN_SERVER_LOG=$DOMAIN_HOME/servers/AdminServer/logs/AdminServer.log | |
| NODEMANAGER_LOG=$DOMAIN_HOME/servers/logs/NodeManager.log | |
| MANAGED_SERVER1_LOG=$DOMAIN_HOME/logs/ManagedServer1.log | |
| MANAGED_SERVER2_LOG=$DOMAIN_HOME/logs/ManagedServer2.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # nodemgr Oracle Weblogic NodeManager service | |
| # | |
| # chkconfig: 345 85 15 | |
| # description: Oracle Weblogic NodeManager service | |
| # The script needs to be saved as /etc/init.d/nodemgr and then issue chkconfig –add nodemgr as root | |
| ### BEGIN INIT INFO | |
| # Provides: nodemgr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| import shlex | |
| def fetch_processes(command): | |
| proc = {} | |
| """Fetches process information using the specified command. | |
| Args: | |
| command: The command to execute (e.g., "ps aux"). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GLOBAL] | |
| [DEV] | |
| CONSOLE_USER_NAME=weblogic | |
| CONSOLE_PASSWORD=weblogic11 | |
| NODE_MANAGER_IP=192.168.1.40 | |
| NODE_MANAGER_PORT=5301 | |
| DOMAIN_NAME=domainName | |
| DOMAIN_PATH=/dir0/dir1/dir2/domainName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| from pprint import pprint as pp | |
| # from running_process import running_process | |
| # import get_running_process | |
| from get_running_process import get_running_process | |
| ### Argumnets where we passing the values as part of script ) | |
| arg_parser = argparse.ArgumentParser( description='This script helps to perform the given action on Weblogic node') | |
| arg_parser.add_argument('--action',choices = ['running-proc','start','stop','restart','check'], required = True, help='Mention what action need to perform using this script') | |
| arg_parser.add_argument('--env',choices = ['PROD','DEV'], required = True, help='Mention the environment name ') | |
| args = arg_parser.parse_args() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import psutil | |
| from pprint import pprint as pp | |
| def get_running_process(proc_name,cmd_line): | |
| import psutil | |
| # """ | |
| # Gets a list of all running processes on the server. | |
| # | |
| # Returns: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 0 is too far from ` ;) | |
| set -g base-index 1 | |
| # Automatically set window title | |
| set-window-option -g automatic-rename on | |
| set-option -g set-titles on | |
| #set -g default-terminal screen-256color | |
| set -g status-keys vi | |
| set -g history-limit 10000 |
NewerOlder