From e758fdd1a49dd435983138c71d07fcfad3577a22 Mon Sep 17 00:00:00 2001 From: Christian Pearce Date: Tue, 14 Apr 2020 18:35:57 -0400 Subject: [PATCH] Add DeleteNetworkView with tests Add DeleteNetworkView with a test also sorting functions on interface This addresses issue #92 --- object_manager.go | 53 +++++++++++++++++++++++------------------- object_manager_test.go | 23 ++++++++++++++++++ 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/object_manager.go b/object_manager.go index d03c85da..0f49b587 100644 --- a/object_manager.go +++ b/object_manager.go @@ -8,39 +8,40 @@ import ( ) type IBObjectManager interface { - CreateNetworkView(name string) (*NetworkView, error) + AllocateIP(netview string, cidr string, ipAddr string, macAddress string, name string, ea EA) (*FixedAddress, error) + AllocateNetwork(netview string, cidr string, prefixLen uint, name string) (network *Network, err error) + CreateARecord(netview string, dnsview string, recordname string, cidr string, ipAddr string, ea EA) (*RecordA, error) + CreateCNAMERecord(canonical string, recordname string, dnsview string, ea EA) (*RecordCNAME, error) CreateDefaultNetviews(globalNetview string, localNetview string) (globalNetviewRef string, localNetviewRef string, err error) + CreateEADefinition(eadef EADefinition) (*EADefinition, error) + CreateHostRecord(enabledns bool, recordName string, netview string, dnsview string, cidr string, ipAddr string, macAddress string, ea EA) (*HostRecord, error) CreateNetwork(netview string, cidr string, name string) (*Network, error) CreateNetworkContainer(netview string, cidr string) (*NetworkContainer, error) - GetNetworkView(name string) (*NetworkView, error) - GetNetwork(netview string, cidr string, ea EA) (*Network, error) - GetNetworkContainer(netview string, cidr string) (*NetworkContainer, error) - AllocateIP(netview string, cidr string, ipAddr string, macAddress string, name string, ea EA) (*FixedAddress, error) - AllocateNetwork(netview string, cidr string, prefixLen uint, name string) (network *Network, err error) - UpdateFixedAddress(fixedAddrRef string, matchclient string, macAddress string, vmID string, vmName string) (*FixedAddress, error) - GetFixedAddress(netview string, cidr string, ipAddr string, macAddr string) (*FixedAddress, error) - GetFixedAddressByRef(ref string) (*FixedAddress, error) + CreateNetworkView(name string) (*NetworkView, error) + CreatePTRRecord(netview string, dnsview string, recordname string, cidr string, ipAddr string, ea EA) (*RecordPTR, error) + DeleteARecord(ref string) (string, error) + DeleteCNAMERecord(ref string) (string, error) DeleteFixedAddress(ref string) (string, error) - ReleaseIP(netview string, cidr string, ipAddr string, macAddr string) (string, error) + DeleteHostRecord(ref string) (string, error) DeleteNetwork(ref string, netview string) (string, error) + DeleteNetworkView(ref string) (string, error) + DeletePTRRecord(ref string) (string, error) + GetARecordByRef(ref string) (*RecordA, error) + GetCNAMERecordByRef(ref string) (*RecordA, error) GetEADefinition(name string) (*EADefinition, error) - CreateEADefinition(eadef EADefinition) (*EADefinition, error) - UpdateNetworkViewEA(ref string, addEA EA, removeEA EA) error - CreateHostRecord(enabledns bool, recordName string, netview string, dnsview string, cidr string, ipAddr string, macAddress string, ea EA) (*HostRecord, error) - GetHostRecordByRef(ref string) (*HostRecord, error) + GetFixedAddress(netview string, cidr string, ipAddr string, macAddr string) (*FixedAddress, error) + GetFixedAddressByRef(ref string) (*FixedAddress, error) GetHostRecord(recordName string, netview string, cidr string, ipAddr string) (*HostRecord, error) + GetHostRecordByRef(ref string) (*HostRecord, error) GetIpAddressFromHostRecord(host HostRecord) (string, error) - UpdateHostRecord(hostRref string, ipAddr string, macAddress string, vmID string, vmName string) (string, error) - DeleteHostRecord(ref string) (string, error) - CreateARecord(netview string, dnsview string, recordname string, cidr string, ipAddr string, ea EA) (*RecordA, error) - GetARecordByRef(ref string) (*RecordA, error) - DeleteARecord(ref string) (string, error) - CreateCNAMERecord(canonical string, recordname string, dnsview string, ea EA) (*RecordCNAME, error) - GetCNAMERecordByRef(ref string) (*RecordA, error) - DeleteCNAMERecord(ref string) (string, error) - CreatePTRRecord(netview string, dnsview string, recordname string, cidr string, ipAddr string, ea EA) (*RecordPTR, error) + GetNetwork(netview string, cidr string, ea EA) (*Network, error) + GetNetworkContainer(netview string, cidr string) (*NetworkContainer, error) + GetNetworkView(name string) (*NetworkView, error) GetPTRRecordByRef(ref string) (*RecordPTR, error) - DeletePTRRecord(ref string) (string, error) + ReleaseIP(netview string, cidr string, ipAddr string, macAddr string) (string, error) + UpdateFixedAddress(fixedAddrRef string, matchclient string, macAddress string, vmID string, vmName string) (*FixedAddress, error) + UpdateHostRecord(hostRref string, ipAddr string, macAddress string, vmID string, vmName string) (string, error) + UpdateNetworkViewEA(ref string, addEA EA, removeEA EA) error } type ObjectManager struct { @@ -406,6 +407,10 @@ func (objMgr *ObjectManager) DeleteNetwork(ref string, netview string) (string, return "", nil } +func (objMgr *ObjectManager) DeleteNetworkView(ref string) (string, error) { + return objMgr.connector.DeleteObject(ref) +} + func (objMgr *ObjectManager) GetEADefinition(name string) (*EADefinition, error) { var res []EADefinition diff --git a/object_manager_test.go b/object_manager_test.go index c1e4b4a5..f9780bda 100644 --- a/object_manager_test.go +++ b/object_manager_test.go @@ -1259,6 +1259,29 @@ var _ = Describe("Object Manager", func() { }) }) + Describe("Delete Network View", func() { + cmpType := "Docker" + tenantID := "01234567890abcdef01234567890abcdef" + fakeRefReturn := "networkview/ZG5zLm5ldHdvcmtfdmlldyQyMw:global_view/false" + deleteRef := fakeRefReturn + nwFakeConnector := &fakeConnector{ + deleteObjectRef: deleteRef, + fakeRefReturn: fakeRefReturn, + } + + objMgr := NewObjectManager(nwFakeConnector, cmpType, tenantID) + + var actualRef string + var err error + It("should pass expected Network View Ref to DeleteObject", func() { + actualRef, err = objMgr.DeleteNetworkView(deleteRef) + }) + It("should return expected Network View Ref", func() { + Expect(actualRef).To(Equal(fakeRefReturn)) + Expect(err).To(BeNil()) + }) + }) + Describe("Delete Fixed Address", func() { cmpType := "Docker" tenantID := "01234567890abcdef01234567890abcdef"