/
dnszone.go
183 lines (152 loc) · 10.5 KB
/
dnszone.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package compute
import (
"yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/apis"
)
/*
Architecture For DnsZone
+-----------+ +----------------+ +-----------+
| RecordSet | | TrafficPolicy | | RecordSet | +-------------+
| (A) | | (Aliyun) | | (TXT) | | Vpc1 |
| | | | | | | (Aws) |
| | | | | | | |
+-----------------------+ | | | | | | +-----------------+ | |
API | DnsZone example.com | | RecordSet | | TrafficPolicy | | RecordSet | | DnsZone abc.app | | Vpc2 |
| (Public) | ------>| (AAAA) | -----------------> | (Tencent) | <-------------| (CAA) | <-------------| (Private) |-----> | (Tencent) |
+-----------------------+ | | | | | | +-----------------+ | |
^ | | | | | | ^ | |
| | | | | | | | | Vpc3 |
| | RecordSet | | TrafficPolicy | | RecordSet | | | (Aws) |
| | (NS) | | (Aws) | | (PTR) | | +-------------+
| +-----------+ +----------------+ +-----------+ |
| |
| |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| |
v |
+-----------------+ |
| | |
| | +----------+ v
| example.com <-------------> | Account1 | +----------+ +---------------+
| | | (Aliyun) | | Account3 | <-------> | abc.app |
| | +----------+ +------------+ | (Aws) | | |
| | | Account2 | +----------+ | |
| example.com <-------------------------------------------------------> | (Tencent) | | |
Cache | | +------------+ | |
| | | |
| | +----------+ | |
| example.com <-------------> | Account4 | <--------------------------------------------------------------------------------> | abc.app |
| | | (Aliyun) | | |
| | +----------+ +---------------+
+-----------------+
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
************* *************** *************
**** **** **** **** **** ****
Public Cloud ** Aliyun ** ** Tencent ** ** Aws **
**** **** **** **** **** ****
************* *************** *************
*/
const (
DNS_ZONE_STATUS_AVAILABLE = compute.DNS_ZONE_STATUS_AVAILABLE // 可用
DNS_ZONE_STATUS_CREATING = "creating" // 创建中
DNS_ZONE_STATUS_CREATE_FAILE = "create_failed" // 创建失败
DNS_ZONE_STATUS_UNCACHING = "uncaching" // 云上资源删除中
DNS_ZONE_STATUS_UNCACHE_FAILED = "uncache_failed" // 云上资源删除失败
DNS_ZONE_STATUS_CACHING = "caching" // 云上资源创建中
DNS_ZONE_STATUS_CACHE_FAILED = "cache_failed" // 云上资源创建失败
DNS_ZONE_STATUS_SYNC_VPCS = "sync_vpcs" // 同步VPC中
DNS_ZONE_STATUS_SYNC_VPCS_FAILED = "sync_vpcs_failed" // 同步VPC失败
DNS_ZONE_STATUS_SYNC_RECORD_SETS = "sync_record_sets" // 同步解析列表中
DNS_ZONE_STATUS_SYNC_RECORD_SETS_FAILED = "sync_record_sets_failed" // 同步解析列表失败
DNS_ZONE_STATUS_DELETING = "deleting" // 删除中
DNS_ZONE_STATUS_DELETE_FAILED = "delete_failed" // 删除失败
DNS_ZONE_STATUS_UNKNOWN = compute.DNS_ZONE_STATUS_UNKNOWN // 未知
)
type DnsZoneFilterListBase struct {
DnsZoneId string `json:"dns_zone_id"`
}
type DnsZoneCreateInput struct {
apis.EnabledStatusInfrasResourceBaseCreateInput
// 区域类型
//
//
// | 类型 | 说明 |
// |---------- |---------|
// | PublicZone | 公有 |
// | PrivateZone | 私有 |
ZoneType string `json:"zone_type"`
// 额外参数
// VPC id列表, 仅在zone_type为PrivateZone时生效, vpc列表必须属于同一个账号
VpcIds []string `json:"vpc_ids"`
// 云账号Id, 仅在zone_type为PublicZone时生效, 若为空则不会在云上创建
CloudaccountId string `json:"cloudaccount_id"`
// 额外信息
Options *jsonutils.JSONDict `json:"options"`
}
type DnsZoneDetails struct {
apis.EnabledStatusInfrasResourceBaseDetails
SDnsZone
// Dns记录数量
DnsRecordsetCount int `json:"dns_recordset_count"`
// 关联vpc数量
VpcCount int `json:"vpc_count"`
// Cache info
CloudCaches []jsonutils.JSONObject `json:"cloud_caches"`
}
type DnsZoneListInput struct {
apis.EnabledStatusInfrasResourceBaseListInput
// 区域类型
//
//
// | 类型 | 说明 |
// |---------- |---------|
// | PublicZone | 公有 |
// | PrivateZone | 私有 |
ZoneType string `json:"zone_type"`
// Filter dns zone By vpc
VpcId string `json:"vpc_id"`
WithCache bool `json:"with_cache"`
}
type DnsZoneSyncStatusInput struct {
}
type DnsZoneCacheInput struct {
// 云账号Id
//
//
// | 要求 |
// |---------- |
// | 1. dns zone 状态必须为available |
// | 2. dns zone zone_type 必须为PublicZone |
// | 3. 指定云账号未在云上创建相应的 dns zone |
CloudaccountId string
}
type DnsZoneUnacheInput struct {
// 云账号Id
CloudaccountId string
}
type DnsZoneAddVpcsInput struct {
// VPC id列表
VpcIds []string `json:"vpc_ids"`
}
type DnsZoneRemoveVpcsInput struct {
// VPC id列表
VpcIds []string `json:"vpc_ids"`
}
type DnsZoneSyncRecordSetsInput struct {
}
type DnsZonePurgeInput struct {
}