yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/openstack/routetable.go (about)

     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  
    15  package openstack
    16  
    17  import (
    18  	api "yunion.io/x/cloudmux/pkg/apis/compute"
    19  	"yunion.io/x/cloudmux/pkg/cloudprovider"
    20  	"yunion.io/x/cloudmux/pkg/multicloud"
    21  )
    22  
    23  type SRouteEntry struct {
    24  	multicloud.SResourceBase
    25  	OpenStackTags
    26  	Destination string `json:"destination"`
    27  	Nexthop     string `json:"nexthop"`
    28  }
    29  
    30  func (route *SRouteEntry) GetId() string {
    31  	return route.Destination + ":" + route.Nexthop
    32  }
    33  func (route *SRouteEntry) GetName() string {
    34  	return ""
    35  }
    36  func (route *SRouteEntry) GetGlobalId() string {
    37  	return route.GetId()
    38  }
    39  
    40  func (route *SRouteEntry) GetStatus() string {
    41  	return ""
    42  }
    43  
    44  func (route *SRouteEntry) Refresh() error {
    45  	return nil
    46  }
    47  
    48  func (route *SRouteEntry) IsEmulated() bool {
    49  	return false
    50  }
    51  
    52  func (route *SRouteEntry) GetType() string {
    53  	return api.ROUTE_ENTRY_TYPE_CUSTOM
    54  }
    55  
    56  func (route *SRouteEntry) GetCidr() string {
    57  	return route.Destination
    58  }
    59  
    60  func (route *SRouteEntry) GetNextHopType() string {
    61  	return route.Nexthop
    62  }
    63  
    64  func (route *SRouteEntry) GetNextHop() string {
    65  	return route.Nexthop
    66  }
    67  
    68  type SRouteTable struct {
    69  	multicloud.SResourceBase
    70  	OpenStackTags
    71  	vpc     *SVpc
    72  	entries []SRouteEntry
    73  	router  *SRouter
    74  }
    75  
    76  func (self *SRouteTable) GetDescription() string {
    77  	return ""
    78  }
    79  
    80  func (self *SRouteTable) GetId() string {
    81  	return self.GetGlobalId()
    82  }
    83  
    84  func (self *SRouteTable) GetGlobalId() string {
    85  	return self.router.Id
    86  }
    87  
    88  func (self *SRouteTable) GetName() string {
    89  	return self.router.Name
    90  }
    91  
    92  func (self *SRouteTable) GetRegionId() string {
    93  	return self.vpc.region.GetId()
    94  }
    95  
    96  func (self *SRouteTable) GetType() cloudprovider.RouteTableType {
    97  	return cloudprovider.RouteTableTypeSystem
    98  }
    99  
   100  func (self *SRouteTable) GetVpcId() string {
   101  	return self.vpc.GetId()
   102  }
   103  
   104  func (self *SRouteTable) GetIRoutes() ([]cloudprovider.ICloudRoute, error) {
   105  	ret := []cloudprovider.ICloudRoute{}
   106  	for index := range self.entries {
   107  		ret = append(ret, &self.entries[index])
   108  	}
   109  	return ret, nil
   110  }
   111  
   112  func (self *SRouteTable) GetStatus() string {
   113  	return self.router.Status
   114  }
   115  
   116  func (self *SRouteTable) IsEmulated() bool {
   117  	return false
   118  }
   119  
   120  func (self *SRouteTable) Refresh() error {
   121  	return nil
   122  }
   123  
   124  func (self *SRouteTable) GetAssociations() []cloudprovider.RouteTableAssociation {
   125  	result := []cloudprovider.RouteTableAssociation{}
   126  	return result
   127  }
   128  
   129  func (self *SRouteTable) CreateRoute(route cloudprovider.RouteSet) error {
   130  	return cloudprovider.ErrNotSupported
   131  }
   132  
   133  func (self *SRouteTable) UpdateRoute(route cloudprovider.RouteSet) error {
   134  	return cloudprovider.ErrNotSupported
   135  }
   136  
   137  func (self *SRouteTable) RemoveRoute(route cloudprovider.RouteSet) error {
   138  	return cloudprovider.ErrNotSupported
   139  }