-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1067 from katiewasnothere/test_network_agent
Add test network agent for ncproxy dev work
- Loading branch information
Showing
8 changed files
with
1,555 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
|
||
"github.com/Microsoft/hcsshim/cmd/ncproxy/ncproxygrpc" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
type service struct { | ||
conf *config | ||
client ncproxygrpc.NetworkConfigProxyClient | ||
containerToNamespace map[string]string | ||
endpointToNicID map[string]string | ||
containerToNetwork map[string]string | ||
} | ||
|
||
type hnsSettings struct { | ||
SwitchName string `json:"switch_name,omitempty"` | ||
IOVSettings *ncproxygrpc.IovEndpointPolicySetting `json:"iov_settings,omitempty"` | ||
} | ||
|
||
type networkingSettings struct { | ||
HNSSettings *hnsSettings `json:"hns_settings,omitempty"` | ||
} | ||
|
||
type config struct { | ||
TTRPCAddr string `json:"ttrpc,omitempty"` | ||
GRPCAddr string `json:"grpc,omitempty"` | ||
NodeNetSvcAddr string `json:"node_net_svc_addr,omitempty"` | ||
// 0 represents no timeout and networkagent will continuously try and connect in the | ||
// background. | ||
Timeout uint32 `json:"timeout,omitempty"` | ||
NetworkingSettings *networkingSettings `json:"networking_settings,omitempty"` | ||
} | ||
|
||
// Reads config from path and returns config struct if path is valid and marshaling | ||
// succeeds | ||
func readConfig(path string) (*config, error) { | ||
data, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to read config file") | ||
} | ||
conf := &config{} | ||
if err := json.Unmarshal(data, conf); err != nil { | ||
return nil, errors.New("failed to unmarshal config data") | ||
} | ||
return conf, nil | ||
} |
Oops, something went wrong.