1 Star 0 Fork 0

opengauss_sharding/pipeline_script

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
helper_create.py 3.13 KB
一键复制 编辑 原始数据 按行查看 历史
周斌 提交于 2023-11-13 11:31 . add orm
#!/usr/bin/evn python
# -*- coding: utf-8 -*-
"""
description: please input using description
author: justbk
date: 2022/1/26
modify_records:
- 2022/1/26 justbk create this file
"""
import os, sys
IPS="""20.20.20.52
20.20.20.54
20.20.20.56
20.20.20.58
20.20.20.60
20.20.20.62
20.20.20.67
20.20.20.70
20.20.20.73
20.20.20.76
20.20.20.79
20.20.20.82
20.20.20.85
20.20.20.88"""
title="""<?xml version='1.1' encoding='UTF-8'?>
<jenkins.plugins.publish__over__ssh.BapSshPublisherPlugin_-Descriptor plugin="[email protected]">
<hostConfigurations>
"""
bottom=""" </hostConfigurations>
<commonConfig reference="../hostConfigurations/jenkins.plugins.publish__over__ssh.BapSshHostConfiguration/commonConfig"/>
<defaults class="jenkins.plugins.publish_over_ssh.options.SshPluginDefaults"/>
</jenkins.plugins.publish__over__ssh.BapSshPublisherPlugin_-Descriptor>
"""
ssh_pub = """ <jenkins.plugins.publish__over__ssh.BapSshHostConfiguration>
<name>###</name>
<hostname>$$$</hostname>
<username>peilq</username>
<secretPassword>{AQAAABAAAAAQRLnncAssGYLTRoAoFFA6ZC8lGJCIBn6CRQoTECbSRx4=}</secretPassword>
<remoteRootDir>/home/peilq/ci/test</remoteRootDir>
<port>22</port>
<commonConfig class="jenkins.plugins.publish_over_ssh.BapSshCommonConfiguration" reference="../../jenkins.plugins.publish__over__ssh.BapSshHostConfiguration/commonConfig"/>
<timeout>300000</timeout>
<overrideKey>true</overrideKey>
<disableExec>false</disableExec>
<keyInfo>
<secretPassphrase>{AQAAABAAAABA7CPzjjPhQe+y3e6v8+eNir91EPJ0ee3v+qzEwHZAYAID1A9jYR1Pjhdj/6QJgFOB8iRiyUaGZcLyXaqPnjjFHTJmi5yx5cOOagGxKoATjnA=}</secretPassphrase>
<key></key>
<keyPath></keyPath>
</keyInfo>
<jumpHost></jumpHost>
<proxyType></proxyType>
<proxyHost></proxyHost>
<proxyPort>0</proxyPort>
<proxyUser></proxyUser>
<proxyPassword></proxyPassword>
</jenkins.plugins.publish__over__ssh.BapSshHostConfiguration>
"""
ips = IPS.split("\n")
class CreateSSHConfig:
@classmethod
def run(cls):
cur_path = os.path.join(os.path.dirname(__file__), "jenkins.plugins.publish_over_ssh.BapSshPublisherPlugin.xml")
with open(cur_path, "wt") as f:
f.write(title)
for ip in ips:
cur = ssh_pub.replace("$$$", ip).replace("###", ip.split(".")[-1])
f.write(cur)
f.write(bottom)
class TagGenerate:
NAMES = ["DB", "PROXY"]
TAG = "string"
@classmethod
def get_name_tag(cls, index, name):
return "{0}_{1}".format(name, index)
@classmethod
def get_ip_tag(cls, index, name):
return "{0}_{1}_IP".format(name, index)
@classmethod
def run(cls):
for name in cls.NAMES:
for idx, ip in enumerate(ips):
print("<{0}>{1}</{0}>".format(cls.TAG, cls.get_name_tag(idx, name)))
print("<{0}>{1}</{0}>".format(cls.TAG, "{0}{1}".format(name.lower(), ip.split(".")[-1])))
print("<{0}>{1}</{0}>".format(cls.TAG, cls.get_ip_tag(idx, name)))
print("<{0}>{1}</{0}>".format(cls.TAG, ip))
#TagGenerate.run()
CreateSSHConfig.run()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/opengauss_sharding/pipeline_script.git
[email protected]:opengauss_sharding/pipeline_script.git
opengauss_sharding
pipeline_script
pipeline_script
master

搜索帮助