Skip to content

Commit

Permalink
Merge pull request #500 from abstractmj/dev_mars
Browse files Browse the repository at this point in the history
feature: support tencent cloud in bcs-cloudnetwork-agent; issue #499
  • Loading branch information
DeveloperJim authored Jun 29, 2020
2 parents 676a004 + 2fe5225 commit 8fa7832
Show file tree
Hide file tree
Showing 8 changed files with 737 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (s *Server) initCloudClient() error {
client = eniaws.New(s.instanceIP)
case options.CloudTencent:
blog.Infof("create qcloud cloud client")
client = eniqcloud.New()
client = eniqcloud.New(s.instanceIP)
default:
return fmt.Errorf("invalid cloud %s", s.opt.Cloud)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ type IPAddress struct {

// NetworkInterfaceAttachment attachment for network interface
type NetworkInterfaceAttachment struct {
Index int `json:"index,omitempty"`
Index int `json:"index,omitempty"`
// for aws
AttachmentID string `json:"attachmentId,omitempty"`
InstanceID string `json:"instanceId"`
// for tencent cloud
EniID string `json:"eniID,omitempty"`
InstanceID string `json:"instanceId"`
}

// ElasticNetworkInterface status for elastic network interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ import (
type Client struct {
// AccessID access id
AccessID string

// AccessSecret access secret
AccessSecret string

// SessionToken session token
SessionToken string

// Region aws region
Region string

// VpcID aws vpc id
VpcID string

// Instance IP
InstanceIP string

// SecurityGroups aws security groups
SecurityGroups []string

// SubnetIDs ids for subnet
SubnetIDs []string

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
// create eni
func (c *Client) createEni(name string, ipNum int) (*ec2.NetworkInterface, error) {
// find available subnets, ipNum is secondary ip number
subnet, err := c.getAvailableSubnet(ipNum + 1)
subnet, err := c.getAvailableSubnet(ipNum)
if err != nil {
blog.Errorf("get available subnet when create eni")
return nil, err
Expand Down Expand Up @@ -125,7 +125,6 @@ func (c *Client) assignIPsToEni(eniID string, ipNum int) error {
}

blog.V(2).Infof("aws AssignPrivateIpAddresses response %s", resp.String())

return nil
}

Expand All @@ -143,7 +142,6 @@ func (c *Client) unassignIPsFromEni(eniID string, addrs []string) error {
}

blog.V(2).Infof("aws UnassignPrivateIpAddresses response %s", resp.String())

return nil
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.,
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* 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 qcloud

const (
// ENV_NAME_TENCENTCLOUD_REGION env name of tencent cloud region
ENV_NAME_TENCENTCLOUD_REGION = "TENCENTCLOUD_REGION"
// ENV_NAME_TENCENTCLOUD_VPC env name of tencent cloud vpc
ENV_NAME_TENCENTCLOUD_VPC = "TENCENTCLOUD_VPC"
// ENV_NAME_TENCENTCLOUD_SUBNETS env name of tencent cloud vpc
ENV_NAME_TENCENTCLOUD_SUBNETS = "TENCENTCLOUD_SUBNETS"
// ENV_NAME_TENCENTCLOUD_SECURITY_GROUPS env name of tencent cloud security groups used by enis
ENV_NAME_TENCENTCLOUD_SECURITY_GROUPS = "TENCENTCLOUD_SECURITY_GROUPS"
// ENV_NAME_TENCENTCLOUD_ACCESS_KEY_ID env name of tencent cloud secret id
ENV_NAME_TENCENTCLOUD_ACCESS_KEY_ID = "TENCENTCLOUD_ACCESS_KEY_ID"
// ENV_NAME_TENCENTCLOUD_ACCESS_KEY env name of tencent cloud secret key
ENV_NAME_TENCENTCLOUD_ACCESS_KEY = "TENCENTCLOUD_ACCESS_KEY"

// ENI_STATUS_PENDING eni pending status
ENI_STATUS_PENDING = "PENDING"
// ENI_STATUS_AVAILABLE eni available status
ENI_STATUS_AVAILABLE = "AVAILABLE"
// ENI_STATUS_ATTACHING eni attaching status
ENI_STATUS_ATTACHING = "ATTACHING"
// ENI_STATUS_DETACHING eni detaching status
ENI_STATUS_DETACHING = "DETACHING"
// ENI_STATUS_DELETING eni deleting status
ENI_STATUS_DELETING = "DELETING"

// status determined by eni Attachment field

// ENI_STATUS_DETACHED eni detached status
ENI_STATUS_DETACHED = "DETACHED"
// ENI_STATUS_ATTACHED eni attached status
ENI_STATUS_ATTACHED = "ATTACHED"

// DEFAULT_CHECK_NUM default check number
DEFAULT_CHECK_NUM = 5
// DEFAULT_CHECK_INTERVAL default check interval, unit second
DEFAULT_CHECK_INTERVAL = 3
)
Loading

0 comments on commit 8fa7832

Please sign in to comment.