network_const.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package compute
  15. import (
  16. "time"
  17. "yunion.io/x/cloudmux/pkg/apis/compute"
  18. )
  19. type TNetworkType string
  20. const (
  21. // # DEFAULT_BANDWIDTH = options.default_bandwidth
  22. // in mbps, maximal is 100Tbps
  23. MAX_BANDWIDTH = 100000000
  24. NETWORK_TYPE_GUEST = TNetworkType(compute.NETWORK_TYPE_GUEST)
  25. NETWORK_TYPE_BAREMETAL = TNetworkType("baremetal")
  26. NETWORK_TYPE_CONTAINER = TNetworkType("container")
  27. NETWORK_TYPE_PXE = TNetworkType("pxe")
  28. NETWORK_TYPE_IPMI = TNetworkType("ipmi")
  29. NETWORK_TYPE_EIP = TNetworkType("eip")
  30. NETWORK_TYPE_HOSTLOCAL = TNetworkType("hostlocal")
  31. STATIC_ALLOC = "static"
  32. MAX_NETWORK_NAME_LEN = 11
  33. EXTRA_DNS_UPDATE_TARGETS = "__extra_dns_update_targets"
  34. NETWORK_STATUS_INIT = "init"
  35. NETWORK_STATUS_PENDING = compute.NETWORK_STATUS_PENDING
  36. NETWORK_STATUS_AVAILABLE = compute.NETWORK_STATUS_AVAILABLE
  37. NETWORK_STATUS_UNAVAILABLE = compute.NETWORK_STATUS_UNAVAILABLE
  38. NETWORK_STATUS_FAILED = "failed"
  39. NETWORK_STATUS_UNKNOWN = "unknown"
  40. NETWORK_STATUS_START_DELETE = "start_delete"
  41. NETWORK_STATUS_DELETING = compute.NETWORK_STATUS_DELETING
  42. NETWORK_STATUS_DELETED = "deleted"
  43. NETWORK_STATUS_DELETE_FAILED = "delete_failed"
  44. )
  45. const (
  46. NETWORK_DRIVER_VIRTIO = "virtio"
  47. NETWORK_DRIVER_E1000 = "e1000"
  48. NETWORK_DRIVER_VMXNET3 = "vmxnet3"
  49. NETWORK_DRIVER_VFIO = "vfio-pci"
  50. )
  51. var (
  52. ALL_NETWORK_TYPES = []TNetworkType{
  53. NETWORK_TYPE_GUEST,
  54. NETWORK_TYPE_BAREMETAL,
  55. NETWORK_TYPE_CONTAINER,
  56. NETWORK_TYPE_PXE,
  57. NETWORK_TYPE_IPMI,
  58. NETWORK_TYPE_EIP,
  59. NETWORK_TYPE_HOSTLOCAL,
  60. }
  61. REGIONAL_NETWORK_PROVIDERS = []string{
  62. CLOUD_PROVIDER_HUAWEI,
  63. CLOUD_PROVIDER_HCSO,
  64. CLOUD_PROVIDER_HCSOP,
  65. CLOUD_PROVIDER_HCS,
  66. CLOUD_PROVIDER_CTYUN,
  67. CLOUD_PROVIDER_UCLOUD,
  68. CLOUD_PROVIDER_GOOGLE,
  69. CLOUD_PROVIDER_OPENSTACK,
  70. CLOUD_PROVIDER_JDCLOUD,
  71. CLOUD_PROVIDER_H3C,
  72. }
  73. )
  74. func IsInNetworkTypes(netType TNetworkType, types []TNetworkType) bool {
  75. for _, t := range types {
  76. if t == netType {
  77. return true
  78. }
  79. }
  80. return false
  81. }
  82. type IPAllocationDirection string
  83. const (
  84. IPAllocationStepdown IPAllocationDirection = "stepdown"
  85. IPAllocationStepup IPAllocationDirection = "stepup"
  86. IPAllocationRandom IPAllocationDirection = "random"
  87. IPAllocationNone IPAllocationDirection = "none"
  88. IPAllocationDefault = ""
  89. )
  90. type SNetworkUsedAddress struct {
  91. IpAddr string `json:"ip_addr"`
  92. Ip6Addr string `json:"ip6_addr"`
  93. MacAddr string `json:"mac_addr"`
  94. Owner string `json:"owner"`
  95. OwnerId string `json:"owner_id"`
  96. OwnerStatus string `json:"owner_status"`
  97. OwnerType string `json:"owner_type"`
  98. AssociateId string `json:"associate_id"`
  99. AssociateType string `json:"associate_type"`
  100. CreatedAt time.Time `json:"created_at"`
  101. }