Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
jijisa
/
porch
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e6d091da
authored
Mar 30, 2017
by
Heechul Kim
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Added git tag creation
parent
7a670a30
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
216 additions
and
7 deletions
porch/api/app/bizlogic.py
porch/api/app/endpoints/route.py
porch/api/app/serializers.py
porch/templates/bind_main.j2
porch/templates/bind_site.j2
quasar/src/components/app/List.vue
quasar/src/components/os/List.vue
porch/api/app/bizlogic.py
View file @
e6d091da
...
...
@@ -26,6 +26,7 @@ from porch.config import FILE_LOG
from
porch.config
import
APP_ROOT
from
porch.config
import
PORCH_USER
from
porch.config
import
PORCHSHELL
from
porch.config
import
PROXY_URL
,
PROXY_PORT
logging
.
config
.
fileConfig
(
'logging.conf'
)
log
=
logging
.
getLogger
(
'porch'
)
...
...
@@ -353,7 +354,7 @@ def _bg_file_distribute(data, s_logfile):
return
True
def
create_tag
(
data
):
def
tag_app
(
data
):
"""Create tag
```
{
...
...
@@ -363,4 +364,58 @@ def create_tag(data):
```
"""
t_ret
=
(
False
,
''
)
# Get app info.
s_rsc
=
'{}/app/{}'
.
format
(
etcdc
.
prefix
,
data
[
'name'
])
try
:
r
=
etcdc
.
read
(
s_rsc
)
except
etcd
.
EtcdKeyNotFound
as
e
:
log
.
error
(
e
)
return
(
False
,
e
)
d
=
ast
.
literal_eval
(
r
.
value
)
# Get repo.
s_play_dir
=
PLAY_DIR
+
'/'
+
d
[
'name'
]
+
datetime
.
now
()
.
isoformat
()
o_repo
=
Repo
.
clone_from
(
'file://'
+
GIT_DIR
+
'/'
+
d
[
'repo'
],
s_play_dir
,
depth
=
1
)
# render site.yml
data
[
'proxy_url'
]
=
PROXY_URL
data
[
'proxy_port'
]
=
PROXY_PORT
s_out
=
render_template
(
'{}_site.j2'
.
format
(
d
[
'name'
]),
d
=
data
)
try
:
with
open
(
s_play_dir
+
'/site.yml'
,
'w'
)
as
f
:
f
.
write
(
s_out
)
except
:
s_msg
=
'Fail to create ansible site.yml file.'
return
(
False
,
s_msg
)
# render role's main.yml
s_out
=
render_template
(
'{}_main.j2'
.
format
(
d
[
'name'
]),
d
=
data
)
try
:
s_main
=
s_play_dir
+
'/roles/{}/tasks/main.yml'
.
format
(
d
[
'name'
])
with
open
(
s_main
,
'w'
)
as
f
:
f
.
write
(
s_out
)
except
:
s_msg
=
'Fail to create ansible main.yml file.'
return
(
False
,
s_msg
)
try
:
# git add modified files.
o_repo
.
git
.
add
(
update
=
True
)
# git commit files
o_repo
.
index
.
commit
(
'commit for the new tag {}'
.
format
(
data
[
'tag'
]))
# git tag
newtag
=
o_repo
.
create_tag
(
data
[
'tag'
])
# git push tag
o_repo
.
remotes
.
origin
.
push
(
newtag
)
except
Exception
as
e
:
s_msg
=
'Fail to push git tag {}: {}'
.
format
(
data
[
'tag'
],
e
)
log
.
error
(
s_msg
)
return
(
False
,
s_msg
)
return
(
True
,
'Succeed to create a tag {}'
.
format
(
data
[
'tag'
]))
porch/api/app/endpoints/route.py
View file @
e6d091da
...
...
@@ -15,6 +15,7 @@ from porch.api.app.serializers import appPostSerializer
from
porch.api.app.serializers
import
appPatchSerializer
from
porch.api.app.serializers
import
appPlaySerializer
from
porch.api.app.serializers
import
appFileDistributeSerializer
from
porch.api.app.serializers
import
appTagSerializer
from
porch.config
import
MY_IP
...
...
@@ -27,6 +28,7 @@ from porch.api.app.bizlogic import get_app_log
from
porch.api.app.bizlogic
import
file_container_app
from
porch.api.app.bizlogic
import
close_file_container
from
porch.api.app.bizlogic
import
file_distribute_app
from
porch.api.app.bizlogic
import
tag_app
log
=
logging
.
getLogger
(
'porch'
)
...
...
@@ -180,3 +182,19 @@ class AppFileDistribute(Resource):
return
s_msg
,
200
@ns.route
(
'/<string:name>/tag'
)
@ns.response
(
404
,
'App not found.'
)
class
AppTag
(
Resource
):
@ns.expect
(
appTagSerializer
)
@jwt_required
def
post
(
self
,
name
):
"""the catalog file distributer."""
data
=
request
.
json
data
[
'name'
]
=
name
(
b_ret
,
s_msg
)
=
tag_app
(
data
)
if
not
b_ret
:
d_msg
=
{
'error'
:
s_msg
}
return
d_msg
,
400
return
s_msg
,
200
porch/api/app/serializers.py
View file @
e6d091da
...
...
@@ -31,4 +31,7 @@ appFileDistributeSerializer = api.model('FileDistributeApp', {
'name'
:
fields
.
String
(
required
=
True
,
description
=
'app name'
),
'machines'
:
fields
.
List
(
fields
.
String
),
})
appTagSerializer
=
api
.
model
(
'TagApp'
,
{
'tag'
:
fields
.
String
(
required
=
True
,
description
=
'app tag'
),
})
porch/templates/bind_main.j2
0 → 100644
View file @
e6d091da
---
# This playbook deploys BIND
- name: Ensure the 'Developemnt tools' package group installed.
yum:
name: "@Development tools"
state: present
- name: Ensure the openssl-devel package installed
yum:
name: openssl-devel
state: present
- name: Get bind source tarball from ftp://ftp.isc.org.
get_url:
url: ftp://ftp.isc.org/isc/bind9/{{ d['tag'] }}/bind-{{ d['tag'] }}.tar.gz
dest: /tmp/bind-{{ d['tag'] }}.tar.gz
- name: untar the source tarball to managed node's /tmp.
unarchive:
src: /tmp/bind-{{ d['tag'] }}.tar.gz
dest: /tmp
remote_src: True
- name: configure bind.
shell: ./configure --prefix=/usr/local/bind-{{ d['tag'] }} --sysconfdir=/etc --enable-querytrace --with-tuning=large --enable-threads --enable-full-report
args:
chdir: /tmp/bind-{{ d['tag'] }}
- name: make bind.
shell: make -j {{ ansible_processor_vcpus }}
args:
chdir: /tmp/bind-{{ d['tag'] }}
- name: make install bind.
shell: make install
args:
chdir: /tmp/bind-{{ d['tag'] }}
- name: Clean untarred source
file:
path: /tmp/bind-{{ d['tag'] }}
state: absent
- name: Create named user.
user:
name: named
shell: /sbin/nologin
createhome: no
- name: Check if named is running.
command: pidof named
register: is_named_running
ignore_errors: True
- name: kill named process
shell: kill -9 $(pidof named)
when: is_named_running.rc == 0
- name: Delete /usr/sbin/named.
file:
path: /usr/sbin/named
state: absent
ignore_errors: True
- name: Delete /usr/sbin/rndc.
file:
path: /usr/sbin/rndc
state: absent
ignore_errors: True
- name: Symlink named.
file:
src: /usr/local/bind-{{ d['tag'] }}/sbin/named
dest: /usr/sbin/named
state: link
- name: Symlink rndc.
file:
src: /usr/local/bind-{{ d['tag'] }}/sbin/rndc
dest: /usr/sbin/rndc
state: link
- name: Check to see if /etc/named.conf exists.
stat:
path: /etc/named.conf
register: st
- name: Touch /etc/named.conf if not exist.
file:
path: /etc/named.conf
state: touch
when: st.stat.exists == False
- name: Make directory /data/nis
file:
path: /data/nis
state: directory
mode: 0755
- name: Make directory /data/named/log
file:
path: /data/named/log
state: directory
mode: 0755
- name: Change ownership of /data to named:named
command: chown -R named:named /data
- name: Copy named.service systemd file.
copy:
src: named.service
dest: /etc/systemd/system/named.service
- name: Reload systemd.
command: systemctl daemon-reload
- name: Enable named service
command: systemctl enable named.service
- name: Run named service
command: systemctl start named.service
...
porch/templates/bind_site.j2
0 → 100644
View file @
e6d091da
---
# This playbook deploys BIND
- name: Install bind
hosts: all
roles:
- bind
environment:
http_proxy: http://{{ d['proxy_url'] }}:{{ d['proxy_port'] }}
...
quasar/src/components/app/List.vue
View file @
e6d091da
...
...
@@ -152,17 +152,17 @@ export default {
'Authorization'
:
`Bearer
${
token
}
`
}
}
self
.
$http
.
p
atch
(
url
,
data
,
headers
).
then
(
response
=>
{
self
.
$http
.
p
ost
(
url
,
data
,
headers
).
then
(
response
=>
{
// close dialog
close
(()
=>
{
Toast
.
create
.
positive
({
html
:
`애플리케이션
${
name
}
태그 생성 완료`
,
timeout
:
5
000
timeout
:
3
000
})
})
self
.
loadData
()
},
response
=>
{
let
err
=
`애플리케이션
${
name
}
태그 실패
`
let
err
=
`애플리케이션
${
name
}
태그 실패
: `
+
response
.
body
Toast
.
create
.
negative
({
html
:
err
,
timeout
:
3000
...
...
quasar/src/components/os/List.vue
View file @
e6d091da
...
...
@@ -136,11 +136,11 @@ export default {
const
url
=
API_URL
+
'/machine/os'
this
.
$http
.
post
(
url
,
this
.
form
,
headers
).
then
(
response
=>
{
console
.
log
(
response
.
body
)
this
.
$router
.
push
(
'/log'
)
},
response
=>
{
Toast
.
create
.
negative
(
'서버 OS 배포 실패'
)
return
console
.
log
(
response
.
statusText
)
// Toast.create.negative('서버 OS 배포 실패')
})
this
.
$router
.
push
(
'/log'
)
},
toggle
:
function
()
{
let
selected
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment