From ad73cc4035a232e9c2093e08e24b8b03a10c580b Mon Sep 17 00:00:00 2001 From: Giovanni Siciliano Date: Fri, 21 Apr 2023 13:47:28 -0700 Subject: [PATCH] Add Tags to the IpConfiguration datastructure. Add function to get the PrimaryIpAddress from a Network Interface --- .../moc_cloudagent_networkinterface.pb.go | 19 +++++++++++++++++++ .../moc_cloudagent_networkinterface.proto | 1 + 2 files changed, 20 insertions(+) diff --git a/rpc/cloudagent/network/moc_cloudagent_networkinterface.pb.go b/rpc/cloudagent/network/moc_cloudagent_networkinterface.pb.go index 4eea0e53..c743e0fd 100644 --- a/rpc/cloudagent/network/moc_cloudagent_networkinterface.pb.go +++ b/rpc/cloudagent/network/moc_cloudagent_networkinterface.pb.go @@ -201,6 +201,7 @@ type IpConfiguration struct { Allocation common.IPAllocationMethod `protobuf:"varint,6,opt,name=allocation,proto3,enum=moc.IPAllocationMethod" json:"allocation,omitempty"` Gateway string `protobuf:"bytes,7,opt,name=gateway,proto3" json:"gateway,omitempty"` InboundNatRules []*InboundNatRule `protobuf:"bytes,8,rep,name=inboundNatRules,proto3" json:"inboundNatRules,omitempty"` + Tags *common.Tags `protobuf:"bytes,9,opt,name=tags,proto3" json:"tags,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -287,6 +288,13 @@ func (m *IpConfiguration) GetInboundNatRules() []*InboundNatRule { return nil } +func (m *IpConfiguration) GetTags() *common.Tags { + if m != nil { + return m.Tags + } + return nil +} + type NetworkInterface struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` @@ -359,6 +367,17 @@ func (m *NetworkInterface) GetIpConfigurations() []*IpConfiguration { return nil } +func (m *NetworkInterface) GetPrimaryIpConfiguration() *IpConfiguration { + if m != nil { + for _, ipConfig := range m.IpConfigurations { + if ipConfig.Primary { + return ipConfig + } + } + } + return nil +} + func (m *NetworkInterface) GetMacaddress() string { if m != nil { return m.Macaddress diff --git a/rpc/cloudagent/network/networkinterface/moc_cloudagent_networkinterface.proto b/rpc/cloudagent/network/networkinterface/moc_cloudagent_networkinterface.proto index d9e48862..188c6705 100644 --- a/rpc/cloudagent/network/networkinterface/moc_cloudagent_networkinterface.proto +++ b/rpc/cloudagent/network/networkinterface/moc_cloudagent_networkinterface.proto @@ -33,6 +33,7 @@ message IpConfiguration { IPAllocationMethod allocation = 6; string gateway = 7; repeated InboundNatRule inboundNatRules = 8; + Tags tags = 9; } message NetworkInterface {