Skip to content

Commit 658b293

Browse files
authored
Merge pull request #11 from aristanetworks/release-v0.2.0
Release v0.2.0
2 parents 9af4295 + a60cacb commit 658b293

38 files changed

+385
-86
lines changed

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
language: go
22
go:
3-
- 1.5.1
3+
- 1.7.3
44
before_install:
55
- go get golang.org/x/tools/cmd/cover
66
- go get github.com/golang/lint/golint
7-
- go get golang.org/x/tools/cmd/vet
87
install:
98
- go list ./... | grep -v examples | go get
109
before_script:

CHANGELOG.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
# Changelog
22

3-
## 0.1.0 (2015-11-11)
3+
## v0.1.0 (2015-11-11)
44

55
Initial public release
66

77
- Add documentation
88
- Add unit tests
9+
10+
## v0.2.0 (2016-12-15)
11+
12+
**Implemented enhancements:**
13+
- Add unix socket support [\#4](https://github.com/aristanetworks/goeapi/issues/4)
14+
- Add support for Connect Timeout [\#2]( https://github.com/aristanetworks/goeapi/issues/2)
15+
16+
17+
**Fixed Bugs:**
18+
- Bump up travis to go1.7 [\#10](https://github.com/aristanetworks/goeapi/issues/10)
19+
- Url endpoint shouldn't terminate in '/' [\#8]( https://github.com/aristanetworks/goeapi/issues/8)
20+
- Fix examples and vet issues [\#6]( https://github.com/aristanetworks/goeapi/issues/6)

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015, Arista Networks
1+
Copyright (c) 2015-2016, Arista Networks
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ The following configuration options are available for defining node entries:
9393
* **transport** - Configures the type of transport connection to use. The default value is _https_. Valid values are:
9494
* http
9595
* https
96+
* socket
9697
* **port** - Configures the port to use for the eAPI connection. (Currently Not Implemented)
9798

9899
_Note:_ See the EOS User Manual found at arista.com for more details on configuring eAPI values.
@@ -321,15 +322,16 @@ corresponding test cases otherwise the pull request will be rejected.
321322

322323
# License
323324

324-
Copyright (c) 2015, Arista Networks, Inc. All rights reserved.
325+
Copyright (c) 2015-2016, Arista Networks
326+
Inc. All rights reserved.
325327

326328
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
327329

328-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
330+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
329331

330-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
332+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
331333

332-
Neither the name of Arista Networks nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
334+
* Neither the name of Arista Networks nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
333335

334336
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
335337

client.go

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 2015, Arista Networks, Inc.
2+
// Copyright (c) 2015-2016, Arista Networks, Inc.
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,12 @@ import (
4444
"github.com/vaughan0/go-ini"
4545
)
4646

47+
//
48+
const (
49+
RunningConfig = "running-config"
50+
StartupConfig = "startup-config"
51+
)
52+
4753
// A Node represents a single device for sending and receiving eAPI messages
4854
//
4955
// Node provides an instance for communicating with Arista EOS
@@ -111,7 +117,7 @@ func (n *Node) RunningConfig() string {
111117
if n.runningConfig != "" {
112118
return n.runningConfig
113119
}
114-
n.runningConfig, _ = n.GetConfig("running-config", "all")
120+
n.runningConfig, _ = n.GetConfig(RunningConfig, "all")
115121
return n.runningConfig
116122
}
117123

@@ -124,7 +130,7 @@ func (n *Node) StartupConfig() string {
124130
if n.startupConfig != "" {
125131
return n.startupConfig
126132
}
127-
n.startupConfig, _ = n.GetConfig("startup-config", "")
133+
n.startupConfig, _ = n.GetConfig(StartupConfig, "")
128134
return n.startupConfig
129135
}
130136

@@ -184,7 +190,7 @@ func (n *Node) GetHandle(encoding string) (*EapiReqHandle, error) {
184190
// Returns:
185191
// Will return a string of the config requested or error if failure
186192
func (n *Node) GetConfig(config string, params string) (string, error) {
187-
if config != "running-config" && config != "startup-config" {
193+
if config != RunningConfig && config != StartupConfig {
188194
return "", fmt.Errorf("Invalid config type: %s", config)
189195
}
190196
commands := []string{strings.TrimSpace("show " + config + " " + params)}
@@ -208,11 +214,11 @@ func (n *Node) GetConfig(config string, params string) (string, error) {
208214
// Error returned on failure.
209215
func (n *Node) GetSection(regex string, config string) (string, error) {
210216
var params string
211-
if config == "" || config == "running-config" {
212-
config = "running-config"
217+
if config == "" || config == RunningConfig {
218+
config = RunningConfig
213219
params = "all"
214220
}
215-
if config != "running-config" && config != "startup-config" {
221+
if config != RunningConfig && config != StartupConfig {
216222
return "", fmt.Errorf("Invalid config type: %s", config)
217223
}
218224
sectionRegex, err := regexp.Compile(regex)
@@ -593,8 +599,7 @@ func (e *EapiConfig) AddConnection(name string) ini.Section {
593599
// This method wil load the connection:localhost profile into the client
594600
// configuration if it is not already present.
595601
func (e *EapiConfig) addDefaultConnection() {
596-
name := "localhost"
597-
conn := e.GetConnection(name)
602+
conn := e.GetConnection("localhost")
598603
if conn == nil {
599604
e.AddConnection("localhost")["transport"] = "socket"
600605
}

client_test.go

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 2015, Arista Networks, Inc.
2+
// Copyright (c) 2015-2016, Arista Networks, Inc.
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
@@ -459,6 +459,21 @@ func TestClientConnectInvalidTransport_UnitTest(t *testing.T) {
459459
}
460460
}
461461

462+
func TestClientConnectTimeout_UnitTest(t *testing.T) {
463+
node := &Node{}
464+
465+
// 1.1.1.2 is assumed to be an unreachable bogus address
466+
conn, err := Connect("http", "1.1.1.2", "admin", "admin", 80)
467+
if err != nil {
468+
t.Fatal("Error in connect.")
469+
}
470+
conn.SetTimeout(5)
471+
node.SetConnection(conn)
472+
if _, err = node.GetConfig("running-config", "all"); err == nil {
473+
t.Fatal("Should timeout and return error")
474+
}
475+
}
476+
462477
func TestClientNodeEnablePasswd_UnitTest(t *testing.T) {
463478
node := &Node{}
464479
node.EnableAuthentication("root")
@@ -545,7 +560,7 @@ func TestClientNodeGetSection_SystemTest(t *testing.T) {
545560
if found := re.MatchString(section); !found {
546561
t.Fatalf("Failed to obtain section from startup-config")
547562
}
548-
section, err = dut.GetSection(invalidRegexp, "startup-config")
563+
_, err = dut.GetSection(invalidRegexp, "startup-config")
549564
if err == nil {
550565
t.Fatalf("Invalid regexp didn't fail")
551566
}

eapi.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 2015, Arista Networks, Inc.
2+
// Copyright (c) 2015-2016, Arista Networks, Inc.
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without

eapi_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 2015, Arista Networks, Inc.
2+
// Copyright (c) 2015-2016, Arista Networks, Inc.
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without

0 commit comments

Comments
 (0)