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
ce3bd422
authored
Apr 03, 2017
by
Heechul Kim
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
updated
parent
7452abfb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
20 deletions
porch/api/machine/bizlogic.py
porch/templates/bind_main.j2
porch/templates/pxelinuxcfg.j2
porch/api/machine/bizlogic.py
View file @
ce3bd422
...
...
@@ -9,6 +9,7 @@ import stat
import
shutil
import
signal
import
tarfile
import
tempfile
import
logging
import
logging.config
...
...
@@ -387,7 +388,11 @@ def install_machine(data):
s_cmd
=
"{} -I lanplus -H {} -U {} -f {} chassis bootdev pxe"
\
.
format
(
IPMITOOL
,
d
[
'ipmi_ip'
],
IPMIUSER
,
s_tmp
)
log
.
debug
(
s_cmd
)
Popen
(
s_cmd
,
shell
=
True
)
(
b_ret
,
l_out
)
=
cmd
(
s_cmd
)
if
not
b_ret
:
log
.
error
(
'IPMI bootdev pxe is failed: {}'
.
format
(
l_out
))
else
:
log
.
info
(
'IPMI bootdev pxe is succeeded: {}'
.
format
(
l_out
))
# update machine state to 'Installing'
d
[
'state'
]
=
'Installing'
...
...
@@ -424,14 +429,14 @@ def install_machine(data):
# power on the physical machines if any.
if
len
(
l_ipmi
):
for
ipmi_ip
in
l_ipmi
:
s_cmd
=
"{} -I lanplus -H {} -U {} -f {} chassis power
reset
"
\
s_cmd
=
"{} -I lanplus -H {} -U {} -f {} chassis power
cycle
"
\
.
format
(
IPMITOOL
,
ipmi_ip
,
IPMIUSER
,
s_tmp
)
(
b_ret
,
l_out
)
=
cmd
(
s_cmd
)
if
not
b_ret
:
log
.
error
(
'IPMI
Reset
is failed: {}'
.
format
(
l_out
))
log
.
error
(
'IPMI
power cycle
is failed: {}'
.
format
(
l_out
))
else
:
log
.
info
(
'IPMI
Reset
is succeeded: {}'
.
format
(
l_out
))
log
.
info
(
'IPMI
power cycle
is succeeded: {}'
.
format
(
l_out
))
# delete s_tmp
os
.
unlink
(
s_tmp
)
...
...
@@ -467,22 +472,18 @@ def show_console_machine(name):
d
=
ast
.
literal_eval
(
r
.
value
)
ipmi_ip
=
d
[
'ipmi_ip'
]
#s_tmp = '/tmp/pass'
#
with open(s_tmp, 'w') as f:
#
f.write(IPMIPASS)
s_tmp
=
'/tmp/{}.pass'
.
format
(
name
)
with
open
(
s_tmp
,
'w'
)
as
f
:
f
.
write
(
IPMIPASS
)
# deactivate first.
#s_cmd = '{} -I lanplus -H {} -U {} -f {} sol deactivate'\
# .format(IPMITOOL, ipmi_ip, IPMIUSER, s_tmp)
s_cmd
=
'{} -h {} -u {} -p "{}" --deactivate'
\
.
format
(
IPMICONSOLE
,
ipmi_ip
,
IPMIUSER
,
IPMIPASS
)
s_cmd
=
'{} -I lanplus -H {} -U {} -f {} sol deactivate'
\
.
format
(
IPMITOOL
,
ipmi_ip
,
IPMIUSER
,
s_tmp
)
log
.
debug
(
s_cmd
)
cmd
(
s_cmd
)
s_pidfile
=
'/tmp/{}.pid'
.
format
(
name
)
# run terminal to connect to a machine
#ipmi_cmd = '{} -I lanplus -H {} -U {} -f {} sol activate'\
# .format(IPMITOOL, ipmi_ip, IPMIUSER, s_tmp)
ipmi_cmd
=
'{} -h {} -u {} -p "{}"'
\
.
format
(
IPMICONSOLE
,
ipmi_ip
,
IPMIUSER
,
IPMIPASS
)
ipmi_cmd
=
'{} -I lanplus -H {} -U {} -f {} sol activate'
\
.
format
(
IPMITOOL
,
ipmi_ip
,
IPMIUSER
,
s_tmp
)
s_cmd
=
"shellinaboxd --background={} "
.
format
(
s_pidfile
)
+
\
"--service='/:{0}:{0}:/:{1}' "
.
format
(
PORCH_USER
,
ipmi_cmd
)
+
\
"-p {} --disable-ssl -q "
.
format
(
i_port
)
+
\
...
...
@@ -490,13 +491,16 @@ def show_console_machine(name):
log
.
debug
(
s_cmd
)
Popen
(
s_cmd
,
shell
=
True
)
# delete s_tmp after 3 seconds.
#os.unlink(s_tmp)
return
(
True
,
i_port
)
def
close_console_machine
(
name
):
"""close console."""
# Delete pass file.
s_tmp
=
'/tmp/{}.pass'
.
format
(
name
)
try
:
os
.
remove
(
s_tmp
)
except
:
pass
# ignore.
# check if terminal is running.
s_pidfile
=
'/tmp/{}.pid'
.
format
(
name
)
if
os
.
path
.
isfile
(
s_pidfile
):
...
...
porch/templates/bind_main.j2
View file @
ce3bd422
...
...
@@ -10,6 +10,11 @@
name: openssl-devel
state: present
- name: Ensure the bind-utils package installed
yum:
name: bind-utils
state: present
- name: Get bind source tarball from ftp://ftp.isc.org.
get_url:
url: http://ftp.isc.org/isc/bind9/{{ d['tag'] }}/bind-{{ d['tag'] }}.tar.gz
...
...
@@ -22,7 +27,7 @@
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
shell: ./configure --prefix=/usr/local/bind-{{ d['tag'] }} --sysconfdir=/etc --enable-querytrace --
localstatedir=/data/var --
with-tuning=large --enable-threads --enable-full-report
args:
chdir: /tmp/bind-{{ d['tag'] }}
...
...
@@ -103,6 +108,12 @@
state: directory
mode: 0755
- name: Make directory /data/var/run
file:
path: /data/var/run
state: directory
mode: 0755
- name: Change ownership of /data to named:named
command: chown -R named:named /data
...
...
porch/templates/pxelinuxcfg.j2
View file @
ce3bd422
...
...
@@ -2,4 +2,4 @@ default porch-generated
label porch-generated
kernel {{ data['fai_kernel_url'] }}
append initrd={{ data['fai_initrd_url'] }} ip=dhcp root=live:{{ data['fai_squash_url'] }} aufs FAI_FLAGS=verbose,sshd,reboot FAI_CONFIG_SRC={{ data['fai_config_url'] }} FAI_ACTION=install {% if data['type'] == 'PM' %} console=tty0 console=ttyS
1
,115200n8 {% endif %} net.ifnames=0 edd=off
append initrd={{ data['fai_initrd_url'] }} ip=dhcp root=live:{{ data['fai_squash_url'] }} aufs FAI_FLAGS=verbose,sshd,reboot FAI_CONFIG_SRC={{ data['fai_config_url'] }} FAI_ACTION=install {% if data['type'] == 'PM' %} console=tty0 console=ttyS
0
,115200n8 {% endif %} net.ifnames=0 edd=off
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