Skip to content

adminset二次修改 #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmdb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class Meta:


class Host(models.Model):
hostname = models.CharField(max_length=50, verbose_name=u"主机名", unique=True)
ip = models.GenericIPAddressField(u"管理IP", max_length=15)
hostname = models.CharField(max_length=50, verbose_name=u"主机名")
ip = models.GenericIPAddressField(u"管理IP", max_length=15, unique=True)
idc = models.ForeignKey(Idc, verbose_name=u"所在机房", on_delete=models.SET_NULL, null=True, blank=True)
other_ip = models.CharField(u"其它IP", max_length=100, blank=True)
asset_no = models.CharField(u"资产编号", max_length=50, blank=True)
Expand Down
9 changes: 8 additions & 1 deletion install/client/adminset_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ def log(log_name, path=None):
def get_ip():
try:
hostname = socket.getfqdn(socket.gethostname())
ipaddr = socket.gethostbyname(hostname)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('223.5.5.5', 80))
ipaddr = s.getsockname()[0]

except Exception as msg:
print(msg)
ipaddr = ''

finally:
s.close()

return ipaddr


Expand Down
28 changes: 14 additions & 14 deletions install/server/auto_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ systemctl enable webssh.service
echo "####install database####"
echo "installing a new mariadb...."
yum install -y mariadb-server mariadb-devel
service mariadb start
systemctl mariadb start
chkconfig mariadb on
mysql -e "CREATE DATABASE if not exists adminset DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"

Expand Down Expand Up @@ -109,13 +109,13 @@ source /etc/profile
scp $adminset_dir/install/server/adminset.service /usr/lib/systemd/system
systemctl daemon-reload
chkconfig adminset on
service adminset start
systemctl adminset start

#安装redis
echo "####install redis####"
yum install redis -y
chkconfig redis on
service redis start
systemctl redis start

# 安装celery
echo "####install celery####"
Expand All @@ -128,16 +128,16 @@ chmod +x $config_dir/celery/start_celery.sh
systemctl daemon-reload
chkconfig celery on
chkconfig beat on
service celery start
service beat start
systemctl celery start
systemctl beat start

# 安装nginx
echo "####install nginx####"
yum install nginx -y
chkconfig nginx on
scp $adminset_dir/install/server/nginx/adminset.conf /etc/nginx/conf.d
scp $adminset_dir/install/server/nginx/nginx.conf /etc/nginx
service nginx start
systemctl nginx start
nginx -s reload

# create ssh config
Expand All @@ -154,14 +154,14 @@ scp $adminset_dir/install/server/ssh/config ~/.ssh/config
# 完成安装
echo "##############install finished###################"
systemctl daemon-reload
service redis restart
service mariadb restart
service adminset restart
service celery restart
service beat restart
service mongod restart
service sshd restart
service webssh restart
systemctl redis restart
systemctl mariadb restart
systemctl adminset restart
systemctl celery restart
systemctl beat restart
systemctl mongod restart
systemctl sshd restart
systemctl webssh restart
echo "please access website http://server_ip"
echo "you have installed adminset successfully!!!"
echo "################################################"
2 changes: 1 addition & 1 deletion templates/config/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h4>{{ tips }}</h4>
</div>
</div>
<hr>
<p><b>Reids</b></p>
<p><b>Redis</b></p>
<div class="form-group">
<label for="_host" class="col-sm-2 control-label">Host:</label>
<div class="col-sm-10">
Expand Down