Skip to content

Commit

Permalink
Merge pull request #93 from pearcec/delete_network_view_#92
Browse files Browse the repository at this point in the history
Add DeleteNetworkView with tests
  • Loading branch information
AvRajath authored Apr 15, 2020
2 parents 9100659 + e758fdd commit 6432f76
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 24 deletions.
53 changes: 29 additions & 24 deletions object_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions object_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6432f76

Please sign in to comment.