Skip to content

Commit

Permalink
Merge pull request #3 from xmigrate/jboss_cmigrate
Browse files Browse the repository at this point in the history
adding support to jboss
  • Loading branch information
iamvishnuks authored Nov 19, 2022
2 parents 4e925db + f576c21 commit 2087faf
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
# xmigrate_cli
VM to container migration tool

# Overview
Cmigrate is an open-source project for migrating your VM-based application deployments to container. Cmigrate is a CLI based tool wriitten in python which can discover the application runtime on the server and generate a docker file and the application artifacts to containerize.

## Current release
---

We have shipped cmigrate with the following features :

- Automatic Environment discovery
- Option to select from multiple environments
- Automatically collect the application-related environment variable and configurations
- Generates docker file for containerization of the application
- Support for tomcat and jboss based application


> 💡 *Currently cmigrate only support tomcat and Jboss. We will add support for more application in the forthcoming releases.

## Tech stack
Cmigrate is build on the below tech stack
- Click python framework
- Jinja web template engine


All the code for cmigrate is written in python. Jinja is a web template engine for the Python programming language and it is used to create the template for generating a docker file. Click is a Python package for creating command-line interfaces.

## Future Roadmap
- Support for more applications runtimes

## 🚀How to run?

Run the cmigrate.py file.

```
python3 cmigrate.py
```

if you have multiple application runtime running you can pass one in --runtime parameter.

Stay tuned for more updates 🎉

22 changes: 21 additions & 1 deletion cmigrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def find_runtime():
app_runtimes.append("tomcat")
elif "httpd" in proc.as_dict().values():
app_runtimes.append("httpd")
elif "jboss" in str(proc.as_dict().values()):
app_runtimes.append("jboss")

return list(set(app_runtimes))

Expand All @@ -34,6 +36,21 @@ def get_artefacts(app_runtime):
continue
else:
artefact['APP_PORT'] = conn.laddr.port
# jboss
if app_runtime=='jboss':
for proc in psutil.process_iter():
if "jboss" in str(proc.as_dict().values()):
break
artefact['APP_RUNTIME'] = app_runtime
war_files = glob(proc.environ()['JBOSS_HOME'] + 'standalone/deployments/*.war')
artefact['APP_DIR'] = war_files
artefact['APP_CONFIG'] = proc.environ()['JBOSS_HOME'] + '/bin/standalone/configuration/standalone.xml'
for conn in proc.connections():
if conn.laddr.port == 8080:
continue
else:
artefact['APP_PORT'] = conn.laddr.port

if app_runtime == 'httpd':
for proc in psutil.process_iter():
if "httpd" in proc.as_dict().values():
Expand All @@ -49,6 +66,10 @@ def generate_docker_file(artefacts):
templateEnv = jinja2.Environment(loader=templateLoader)
if artefacts['APP_RUNTIME'] == "tomcat":
TEMPLATE_FILE = "Dockerfile-tomcat.j2"
elif artefacts['APP_RUNTIME'] == "jboss":
TEMPLATE_FILE = "Dockerfile-jboss.j2"
# elif artefacts['APP_RUNTIME'] == "httpd":
# TEMPLATE_FILE = "Dockerfile-httpd.j2"
template = templateEnv.get_template(TEMPLATE_FILE)
output_dir = './artefact'
isExist = os.path.exists(output_dir)
Expand Down Expand Up @@ -90,4 +111,3 @@ def build_dockerfile(runtime):

if __name__ == '__main__':
build_dockerfile()

8 changes: 8 additions & 0 deletions templates/Dockerfile-jboss.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM registry.access.redhat.com/jboss-eap-7/eap71-openshift
LABEL maintainer="xmigrate.cloud"
{% for artefact in artefacts.APP_DIR %}
COPY {{ artefact }} standalone/deployments
{% endfor %}
COPY {{ artefacts.APP_CONFIG }} /bin/standalone/configuration/standalone.xml
EXPOSE {{ artefacts.APP_PORT }}
CMD ["standalone.sh", "run"]

0 comments on commit 2087faf

Please sign in to comment.