fix bug jms sync
parent
54ee9da58c
commit
684bf3f756
|
@ -25,6 +25,8 @@ alibabacloud_rds20140815==2.1.2
|
||||||
alibabacloud_r_kvstore20150101==2.20.7
|
alibabacloud_r_kvstore20150101==2.20.7
|
||||||
alibabacloud_bssopenapi20171214==2.0.6
|
alibabacloud_bssopenapi20171214==2.0.6
|
||||||
aliyun-python-sdk-cms==7.0.32
|
aliyun-python-sdk-cms==7.0.32
|
||||||
|
alibabacloud_dds20151201==8.1.1
|
||||||
|
alibabacloud_polardb20170801==5.4.0
|
||||||
tencentcloud-sdk-python-common==3.0.779
|
tencentcloud-sdk-python-common==3.0.779
|
||||||
tencentcloud-sdk-python-cvm==3.0.779
|
tencentcloud-sdk-python-cvm==3.0.779
|
||||||
tencentcloud-sdk-python-cdb==3.0.779
|
tencentcloud-sdk-python-cdb==3.0.779
|
||||||
|
|
|
@ -197,6 +197,12 @@ def redis(account,region):
|
||||||
|
|
||||||
config = open_api_models.Config(access_key_id=ak,access_key_secret=sk)
|
config = open_api_models.Config(access_key_id=ak,access_key_secret=sk)
|
||||||
config.endpoint = 'r-kvstore.aliyuncs.com'
|
config.endpoint = 'r-kvstore.aliyuncs.com'
|
||||||
|
if region == "ap-southeast-1":
|
||||||
|
config.endpoint = f'r-kvstore.{region}.aliyuncs.com'
|
||||||
|
elif region == "eu-central-1":
|
||||||
|
config.endpoint = f'r-kvstore.{region}.aliyuncs.com'
|
||||||
|
elif region == "us-west-1":
|
||||||
|
config.endpoint = f'r-kvstore.{region}.aliyuncs.com'
|
||||||
client = R_kvstore20150101Client(config)
|
client = R_kvstore20150101Client(config)
|
||||||
PageNumber = 1
|
PageNumber = 1
|
||||||
nextpage = True
|
nextpage = True
|
||||||
|
@ -259,6 +265,12 @@ def rds(account,region):
|
||||||
|
|
||||||
config = open_api_models.Config(access_key_id=ak,access_key_secret=sk)
|
config = open_api_models.Config(access_key_id=ak,access_key_secret=sk)
|
||||||
config.endpoint = 'rds.aliyuncs.com'
|
config.endpoint = 'rds.aliyuncs.com'
|
||||||
|
if region == "ap-southeast-1":
|
||||||
|
config.endpoint = f'rds.{region}.aliyuncs.com'
|
||||||
|
elif region == "eu-central-1":
|
||||||
|
config.endpoint = f'rds.{region}.aliyuncs.com'
|
||||||
|
elif region == "us-west-1":
|
||||||
|
config.endpoint = f'rds.{region}.aliyuncs.com'
|
||||||
client = Rds20140815Client(config)
|
client = Rds20140815Client(config)
|
||||||
|
|
||||||
next_token = '0'
|
next_token = '0'
|
||||||
|
@ -342,6 +354,12 @@ def polardb(account, region):
|
||||||
|
|
||||||
config = open_api_models.Config(access_key_id=ak, access_key_secret=sk)
|
config = open_api_models.Config(access_key_id=ak, access_key_secret=sk)
|
||||||
config.endpoint = 'polardb.aliyuncs.com'
|
config.endpoint = 'polardb.aliyuncs.com'
|
||||||
|
if region == "ap-southeast-1":
|
||||||
|
config.endpoint = f'polardb.{region}.aliyuncs.com'
|
||||||
|
elif region == "eu-central-1":
|
||||||
|
config.endpoint = f'polardb.{region}.aliyuncs.com'
|
||||||
|
elif region == "us-west-1":
|
||||||
|
config.endpoint = f'polardb.{region}.aliyuncs.com'
|
||||||
client = polardb20170801Client(config) # 使用PolarDB客户端
|
client = polardb20170801Client(config) # 使用PolarDB客户端
|
||||||
|
|
||||||
page_number = 1
|
page_number = 1
|
||||||
|
@ -354,9 +372,7 @@ def polardb(account, region):
|
||||||
dbtype="MySQL",
|
dbtype="MySQL",
|
||||||
region_id=region,
|
region_id=region,
|
||||||
page_number=page_number,
|
page_number=page_number,
|
||||||
|
|
||||||
)
|
)
|
||||||
print("------------------------------------------")
|
|
||||||
|
|
||||||
cluster_info = client.describe_dbclusters_with_options(describe_dbclusters_request, runtime)
|
cluster_info = client.describe_dbclusters_with_options(describe_dbclusters_request, runtime)
|
||||||
cluster_list = cluster_info.body.to_map()['Items']['DBCluster']
|
cluster_list = cluster_info.body.to_map()['Items']['DBCluster']
|
||||||
|
@ -380,6 +396,7 @@ def polardb(account, region):
|
||||||
else:
|
else:
|
||||||
page_number += 1
|
page_number += 1
|
||||||
try:
|
try:
|
||||||
|
print("-------------1", polardb_dict)
|
||||||
for iid in polardb_dict.keys():
|
for iid in polardb_dict.keys():
|
||||||
logger.info(f'【ali_PolarDB】===> {iid}')
|
logger.info(f'【ali_PolarDB】===> {iid}')
|
||||||
describe_dbcluster_attribute_request = polardb_20170801_models.DescribeDBClusterEndpointsRequest(
|
describe_dbcluster_attribute_request = polardb_20170801_models.DescribeDBClusterEndpointsRequest(
|
||||||
|
@ -437,6 +454,12 @@ def mongodb(account, region):
|
||||||
|
|
||||||
config = open_api_models.Config(access_key_id=ak, access_key_secret=sk)
|
config = open_api_models.Config(access_key_id=ak, access_key_secret=sk)
|
||||||
config.endpoint = 'mongodb.aliyuncs.com'
|
config.endpoint = 'mongodb.aliyuncs.com'
|
||||||
|
if region == "ap-southeast-1":
|
||||||
|
config.endpoint = f'mongodb.{region}.aliyuncs.com'
|
||||||
|
elif region == "eu-central-1":
|
||||||
|
config.endpoint = f'mongodb.{region}.aliyuncs.com'
|
||||||
|
elif region == "us-west-1":
|
||||||
|
config.endpoint = f'mongodb.{region}.aliyuncs.com'
|
||||||
client = Dds20151201Client(config) # 使用MongoDB客户端
|
client = Dds20151201Client(config) # 使用MongoDB客户端
|
||||||
|
|
||||||
page_number = 1
|
page_number = 1
|
||||||
|
|
|
@ -42,9 +42,6 @@ def w2consul(vendor,account,region,mongodb_dict):
|
||||||
if ip == None:
|
if ip == None:
|
||||||
ip = v['ip']
|
ip = v['ip']
|
||||||
instance = f'{ip}:{port}'
|
instance = f'{ip}:{port}'
|
||||||
if vendor == 'alicloud' and iid in consul_mongodb_iid_list and v['cpu'] == '无':
|
|
||||||
continue
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'id': iid,
|
'id': iid,
|
||||||
'name': service_name,
|
'name': service_name,
|
||||||
|
@ -60,7 +57,7 @@ def w2consul(vendor,account,region,mongodb_dict):
|
||||||
'account': account,
|
'account': account,
|
||||||
'itype': v['itype'],
|
'itype': v['itype'],
|
||||||
'vendor': vendors.get(vendor,'未找到'),
|
'vendor': vendors.get(vendor,'未找到'),
|
||||||
'os': "mysql",
|
'os': "mongodb",
|
||||||
'ver': v['ver'],
|
'ver': v['ver'],
|
||||||
'domain':v['domain'],
|
'domain':v['domain'],
|
||||||
'exp': v['exp'],
|
'exp': v['exp'],
|
||||||
|
|
|
@ -42,9 +42,6 @@ def w2consul(vendor,account,region,rds_dict):
|
||||||
if ip == None:
|
if ip == None:
|
||||||
ip = v['ip']
|
ip = v['ip']
|
||||||
instance = f'{ip}:{port}'
|
instance = f'{ip}:{port}'
|
||||||
if vendor == 'alicloud' and iid in consul_rds_iid_list and v['cpu'] == '无':
|
|
||||||
continue
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'id': iid,
|
'id': iid,
|
||||||
'name': service_name,
|
'name': service_name,
|
||||||
|
|
|
@ -42,9 +42,6 @@ def w2consul(vendor,account,region,rds_dict):
|
||||||
if ip == None:
|
if ip == None:
|
||||||
ip = v['ip']
|
ip = v['ip']
|
||||||
instance = f'{ip}:{port}'
|
instance = f'{ip}:{port}'
|
||||||
if vendor == 'alicloud' and iid in consul_rds_iid_list and v['cpu'] == '无':
|
|
||||||
continue
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'id': iid,
|
'id': iid,
|
||||||
'name': service_name,
|
'name': service_name,
|
||||||
|
|
|
@ -5,13 +5,6 @@ from units.config_log import *
|
||||||
resource_type = ["ecs", "redis", "rds", "mongodb", "polardb"]
|
resource_type = ["ecs", "redis", "rds", "mongodb", "polardb"]
|
||||||
|
|
||||||
|
|
||||||
def exist_ssh_port(port,protocols):
|
|
||||||
for protocol in protocols:
|
|
||||||
if protocol.get('name') == 'ssh':
|
|
||||||
return protocol.get('port', port) if protocol.get('port') != port else port
|
|
||||||
return port
|
|
||||||
|
|
||||||
|
|
||||||
# 创建节点
|
# 创建节点
|
||||||
def create_node(jms_url,headers, node_id, account):
|
def create_node(jms_url,headers, node_id, account):
|
||||||
node_url = f"{jms_url}/api/v1/assets/nodes/{node_id}/children/"
|
node_url = f"{jms_url}/api/v1/assets/nodes/{node_id}/children/"
|
||||||
|
@ -86,7 +79,7 @@ def update_jms(jms_ver,jms_url,headers,new_node_dict,node_id,cloud,account,ecs_i
|
||||||
if jms_ver == 'V3':
|
if jms_ver == 'V3':
|
||||||
ecs_url = f"{jms_url}/api/v1/assets/hosts/"
|
ecs_url = f"{jms_url}/api/v1/assets/hosts/"
|
||||||
proto,proto_port = protocols[0].split('/')
|
proto,proto_port = protocols[0].split('/')
|
||||||
port = exist_ssh_port(proto_port, jms_ecs_dict.get(ip, {}).get("protocols", []))
|
port = proto_port
|
||||||
payload = {
|
payload = {
|
||||||
"address": ip,
|
"address": ip,
|
||||||
"name": iname,
|
"name": iname,
|
||||||
|
@ -136,7 +129,12 @@ def update_jms(jms_ver,jms_url,headers,new_node_dict,node_id,cloud,account,ecs_i
|
||||||
try:
|
try:
|
||||||
if ip in jms_ecs_dict.keys():
|
if ip in jms_ecs_dict.keys():
|
||||||
jms_group = '无' if jms_ecs_dict[ip]['node'].split('/')[-1] == '未分组' else jms_ecs_dict[ip]['node'].split('/')[-1]
|
jms_group = '无' if jms_ecs_dict[ip]['node'].split('/')[-1] == '未分组' else jms_ecs_dict[ip]['node'].split('/')[-1]
|
||||||
if jms_ecs_dict[ip]['name'] != iname or jms_group != v['ent']:
|
is_update = False
|
||||||
|
for p in jms_ecs_dict.get(ip, {}).get("protocols", []):
|
||||||
|
if p['name'] == proto and int(p['port']) != int(port):
|
||||||
|
is_update = True
|
||||||
|
break
|
||||||
|
if jms_ecs_dict[ip]['name'] != iname or jms_group != v['ent'] or is_update:
|
||||||
response = requests.request("PUT", f"{ecs_url}{jms_ecs_dict[ip]['id']}/", headers=headers, data = json.dumps(payload))
|
response = requests.request("PUT", f"{ecs_url}{jms_ecs_dict[ip]['id']}/", headers=headers, data = json.dumps(payload))
|
||||||
logger.info(f" 【JMS】update:主机名:{response.json().get('hostname',response.json())},{response.status_code}")
|
logger.info(f" 【JMS】update:主机名:{response.json().get('hostname',response.json())},{response.status_code}")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# Assuming localhost, substitute with actual Consul server address.
|
# Assuming localhost, substitute with actual Consul server address.
|
||||||
export CONSUL_HTTP_TOKEN=xxxxxx
|
export CONSUL_HTTP_TOKEN=234dbcac-25df-42d3-965a-af4193474a56
|
||||||
CONSUL_HOST="http://172.26.32.83:8500"
|
CONSUL_HOST="http://172.26.32.83:8500"
|
||||||
|
|
||||||
# Get all instances of the service
|
# Get all instances of the service
|
||||||
SERVICE_INSTANCES=$(curl -s -H "X-Consul-Token: $CONSUL_HTTP_TOKEN" "${CONSUL_HOST}/v1/catalog/service/alicloud_dreame_devops_rds")
|
SERVICE_INSTANCES=$(curl -s -H "X-Consul-Token: $CONSUL_HTTP_TOKEN" "${CONSUL_HOST}/v1/catalog/service/alicloud_dreame_app_mongodb")
|
||||||
|
|
||||||
# Extract the service IDs and deregister each
|
# Extract the service IDs and deregister each
|
||||||
echo "${SERVICE_INSTANCES}" | jq -r '.[].ServiceID' | while read SERVICE_ID; do
|
echo "${SERVICE_INSTANCES}" | jq -r '.[].ServiceID' | while read SERVICE_ID; do
|
||||||
|
|
|
@ -149,7 +149,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
jms_config: { ver: 'V2', url: '', token: '', linuxport: '22', linuxuid: '', winport: '3389', winuid: '',
|
jms_config: { ver: 'V2', url: '', token: '', linuxport: '22', linuxuid: '', winport: '3389', winuid: '',
|
||||||
redisport: '6379', redisuid: '', mysqlport: '3306', mysqluid: '', mongodbport: '3317', mongodbuid: '', custom_ecs_info: '' },
|
redisport: '6379', redisuid: '', mysqlport: '3306', mysqluid: '', mongodbport: '3717', mongodbuid: '', custom_ecs_info: '' },
|
||||||
listLoading: false,
|
listLoading: false,
|
||||||
dialogFormVisible: false,
|
dialogFormVisible: false,
|
||||||
query: { vendor: '', account: '' },
|
query: { vendor: '', account: '' },
|
||||||
|
|
Loading…
Reference in New Issue