diff --git a/cns/NetworkContainerContract.go b/cns/NetworkContainerContract.go index 6e6fd5272c..1816e5187c 100644 --- a/cns/NetworkContainerContract.go +++ b/cns/NetworkContainerContract.go @@ -23,10 +23,10 @@ const ( const ( AzureContainerInstance = "AzureContainerInstance" WebApps = "WebApps" - ClearContainer = "ClearContainer" Docker = "Docker" Basic = "Basic" JobObject = "JobObject" + COW = "COW" // Container on Windows ) // Orchestrator Types @@ -171,7 +171,7 @@ type AttachContainerToNetworkResponse struct { Response Response } -// DetachNetworkContainerToNetworkResponse specifies response of detaching network container from network. +// DetachContainerFromNetworkResponse specifies response of detaching network container from network. type DetachContainerFromNetworkResponse struct { Response Response } diff --git a/cns/restserver/api.go b/cns/restserver/api.go index de294c3e00..25d60e3ca2 100644 --- a/cns/restserver/api.go +++ b/cns/restserver/api.go @@ -26,6 +26,7 @@ const ( UnexpectedError = 99 ) +// ReturnCodeToString - Converts an error code to appropriate string. func ReturnCodeToString(returnCode int) (s string) { switch returnCode { case Success: diff --git a/cns/restserver/restserver.go b/cns/restserver/restserver.go index 09dc55b80f..9ee6894a09 100644 --- a/cns/restserver/restserver.go +++ b/cns/restserver/restserver.go @@ -191,7 +191,7 @@ func (service *HTTPRestService) Stop() { log.Printf("[Azure CNS] Service stopped.") } -// Get dnc/service partition key +// GetPartitionKey - Get dnc/service partition key func (service *HTTPRestService) GetPartitionKey() (dncPartitionKey string) { service.lock.Lock() dncPartitionKey = service.dncPartitionKey @@ -1025,13 +1025,13 @@ func (service *HTTPRestService) saveNetworkContainerGoalState(req cns.CreateNetw switch req.NetworkContainerType { case cns.AzureContainerInstance: fallthrough - case cns.ClearContainer: - fallthrough case cns.Docker: fallthrough case cns.Basic: fallthrough case cns.JobObject: + fallthrough + case cns.COW: switch service.state.OrchestratorType { case cns.Kubernetes: fallthrough diff --git a/cns/restserver/restserver_test.go b/cns/restserver/restserver_test.go index c787da44e6..98806a21d3 100644 --- a/cns/restserver/restserver_test.go +++ b/cns/restserver/restserver_test.go @@ -580,7 +580,7 @@ func TestCreateNetworkContainer(t *testing.T) { // Test create network container of type JobObject fmt.Println("TestCreateNetworkContainer: JobObject") - err := creatOrUpdateNetworkContainerWithName(t, "testJobObject", "11.0.0.5", "JobObject") + err := creatOrUpdateNetworkContainerWithName(t, "testJobObject", "10.1.0.5", "JobObject") if err != nil { t.Errorf("Failed to save the goal state for network container of type JobObject "+ " due to error: %+v", err) @@ -596,13 +596,13 @@ func TestCreateNetworkContainer(t *testing.T) { // Test create network container of type WebApps fmt.Println("TestCreateNetworkContainer: WebApps") - err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "11.0.0.5", "WebApps") + err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "192.0.0.5", "WebApps") if err != nil { t.Errorf("creatOrUpdateWebAppContainerWithName failed Err:%+v", err) t.Fatal(err) } - err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "11.0.0.6", "WebApps") + err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "192.0.0.6", "WebApps") if err != nil { t.Errorf("Updating interface failed Err:%+v", err) t.Fatal(err) @@ -616,6 +616,21 @@ func TestCreateNetworkContainer(t *testing.T) { t.Fatal(err) } + // Test create network container of type COW + err = creatOrUpdateNetworkContainerWithName(t, "testCOWContainer", "10.0.0.5", "COW") + if err != nil { + t.Errorf("Failed to save the goal state for network container of type COW"+ + " due to error: %+v", err) + t.Fatal(err) + } + + fmt.Println("Deleting the saved goal state for network container of type COW") + err = deleteNetworkAdapterWithName(t, "testCOWContainer") + if err != nil { + t.Errorf("Failed to delete the saved goal state due to error: %+v", err) + t.Fatal(err) + } + } func TestGetNetworkContainerByOrchestratorContext(t *testing.T) {