Skip to content

Commit eec54c7

Browse files
committed
Developing...
1 parent 025ff61 commit eec54c7

File tree

429 files changed

+54892
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

429 files changed

+54892
-176
lines changed

Gopkg.lock

Lines changed: 136 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@
2525
# unused-packages = true
2626

2727

28+
[[override]]
29+
branch = "master"
30+
name = "github.com/docker/distribution"
31+
32+
[[override]]
33+
name = "github.com/docker/go-connections"
34+
version = "0.3.0"
35+
36+
[[override]]
37+
branch = "master"
38+
name = "github.com/docker/docker"
39+
40+
[[override]]
41+
name = "github.com/gorilla/mux"
42+
version = "1.6.1"
43+
44+
2845
[prune]
2946
go-tests = true
3047
unused-packages = true

Makefile

Lines changed: 5 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,29 @@
1-
##################### CARAVELA's MAKEFILE #########################
1+
################ CARAVELA's SIMULATOR MAKEFILE ###############
22
GOCMD=go
33

44
######### Builtin GO tools #########
55
GOBUILD=$(GOCMD) build
66
GOINSTALL=$(GOCMD) install
77
GOCLEAN=$(GOCMD) clean
8-
GOTEST=$(GOCMD) test
9-
GOVET=$(GOCMD) vet
10-
11-
GOGET=$(GOCMD) get
12-
13-
######### External GO tools #########
14-
GOLINT=golint
15-
GOCOV=gocov
16-
GOCOVHTML=gocov-html
17-
GODEPGRAPH=godepgraph
188

199
############ Output Files ###########
2010
EXE=.exe
21-
BINARY_NAME=caravela$(EXE)
22-
BINARY_NAME_LINUX=$(BINARY_NAME)_linux$(EXE)
23-
BINARY_NAME_WIN=$(BINARY_NAME)_win$(EXE)
11+
BINARY_NAME=caravela_sim$(EXE)
2412

25-
############################## COMMANDS ############################
13+
########################## COMMANDS ############################
2614

27-
all: test build
15+
all: build
2816

2917
build:
3018
@echo Building for the current machine settings...
3119
$(GOBUILD) -o $(BINARY_NAME) -v
3220

33-
build-linux:
34-
@echo Building for linux...
35-
env GOOS=linux $(GOBUILD) -o $(BINARY_NAME) -v
36-
37-
build-windows:
38-
@echo Building for windows...
39-
env GOOS=windows $(GOBUILD) -o $(BINARY_NAME) -v
40-
4121
clean:
4222
@echo Cleaning project...
4323
$(GOCLEAN)
4424
rm -f $(BINARY_NAME)
45-
rm -f $(BINARY_NAME_LINUX)
46-
rm -f $(BINARY_NAME_WIN)
4725

4826
install:
49-
@echo Installing CARAVELA in the local GO environment...
27+
@echo Installing CARAVELA-SIM in the local GO environment...
5028
$(GOINSTALL) -v -gcflags "-N -l" .
5129

52-
test:
53-
@echo Testing...
54-
$(GOTEST) -v ./...
55-
56-
test-cov:
57-
@echo Testing and coverage report generation...
58-
$(GOCOV) test ./... | $(GOCOVHTML) > coverage.html
59-
60-
test-verify:
61-
$(MAKE) test
62-
@echo Running vet tool to static analyze the code
63-
$(GOVET) -v ./...
64-
@echo Running lint tool to static analyze the code style
65-
66-
dep-graph:
67-
@echo Generating package import dependency graph...
68-
$(GODEPGRAPH) -s -p github.com/docker github.com/strabox/caravela | dot -Tpng -o importsGraph.png
69-
70-
docker-build:
71-
@echo Building Docker container...
72-
docker build --build-arg exec_file=$(BINARY_NAME) --rm -t strabox/caravela:latest .
73-
74-
docker-upload:
75-
@echo Building Docker container and uploading to DockerHub...
76-
docker build --build-arg exec_file=$(BINARY_NAME) --rm -t strabox/caravela:latest .
77-
docker push strabox/caravela:latest
78-
79-
install-external-tools:
80-
@echo Installing external tools...
81-
@echo Installing lint - Code style analyzer (from google)
82-
$(GOGET) github.com/golang/lint
83-
@echo Installing gocov - Code coverage generator
84-
$(GOGET) github.com/axw/gocov/gocov
85-
@echo Installing gocov-html - Code coverage html generator
86-
$(GOGET) -u gopkg.in/matm/v1/gocov-html
87-
@echo Installing godepgraph - Code package dependency graph generator
88-
$(GOGET) github.com/kisielk/godepgraph
89-
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,70 @@
11
package caravela
22

33
import (
4+
"github.com/strabox/caravela-sim/simulation"
45
"github.com/strabox/caravela/api/rest"
56
"github.com/strabox/caravela/configuration"
67
nodeAPI "github.com/strabox/caravela/node/api"
78
)
89

910
type RemoteClientMock struct {
10-
// TODO
11+
sim simulation.Simulator
1112
}
1213

13-
func NewRemoteClientMock() *RemoteClientMock {
14-
return &RemoteClientMock{}
14+
func NewRemoteClientMock(sim simulation.Simulator) *RemoteClientMock {
15+
return &RemoteClientMock{
16+
sim: sim,
17+
}
1518
}
1619

20+
/*
21+
===============================================================================
22+
Caravela Remote Client Interface
23+
===============================================================================
24+
*/
25+
1726
func (mock *RemoteClientMock) CreateOffer(fromSupplierIP string, fromSupplierGUID string, toTraderIP string,
1827
toTraderGUID string, offerID int64, amount int, cpus int, ram int) error {
19-
// Do Nothing
28+
29+
mock.sim.NodeByGUID(toTraderGUID).Discovery().CreateOffer(fromSupplierGUID, fromSupplierIP, toTraderGUID,
30+
offerID, amount, cpus, ram)
2031
return nil
2132
}
2233

2334
func (mock *RemoteClientMock) RefreshOffer(toSupplierIP string, fromTraderGUID string, offerID int64) (bool, error) {
24-
// Do Nothing
25-
return false, nil
35+
return mock.sim.NodeByIP(toSupplierIP).Discovery().RefreshOffer(offerID, fromTraderGUID), nil
2636
}
2737

2838
func (mock *RemoteClientMock) RemoveOffer(fromSupplierIP string, fromSupplierGUID, toTraderIP string,
2939
toTraderGUID string, offerID int64) error {
30-
// Do Nothing
40+
41+
mock.sim.NodeByGUID(toTraderGUID).Discovery().RemoveOffer(fromSupplierIP, fromSupplierGUID, toTraderGUID, offerID)
3142
return nil
3243
}
3344

3445
func (mock *RemoteClientMock) GetOffers(toTraderIP string, toTraderGUID string, relay bool,
3546
fromNodeGUID string) ([]nodeAPI.Offer, error) {
36-
// Do Nothing
37-
return nil, nil
47+
48+
offers := mock.sim.NodeByGUID(toTraderGUID).Discovery().GetOffers(toTraderGUID, relay, fromNodeGUID)
49+
return offers, nil
3850
}
3951

4052
func (mock *RemoteClientMock) AdvertiseOffersNeighbor(toNeighborTraderIP string, toNeighborTraderGUID string,
4153
fromTraderGUID string, traderOfferingGUID string, traderOfferingIP string) error {
42-
// Do Nothing
54+
55+
mock.sim.NodeByGUID(toNeighborTraderGUID).Discovery().AdvertiseNeighborOffers(toNeighborTraderGUID, fromTraderGUID,
56+
traderOfferingIP, traderOfferingGUID)
4357
return nil
4458
}
4559

4660
func (mock *RemoteClientMock) LaunchContainer(toSupplierIP string, fromBuyerIP string, offerID int64, containerImageKey string,
4761
portMappings []rest.PortMapping, containerArgs []string, cpus int, ram int) error {
48-
// Do Nothing
49-
return nil
62+
63+
return mock.sim.NodeByIP(toSupplierIP).Scheduler().Launch(fromBuyerIP, offerID, containerImageKey, portMappings, containerArgs,
64+
cpus, ram)
5065
}
5166

5267
func (mock *RemoteClientMock) ObtainConfiguration(systemsNodeIP string) (*configuration.Configuration, error) {
53-
// Do Nothing
68+
// Do Nothing (For now not necessary for the simulation)
5469
return nil, nil
5570
}

0 commit comments

Comments
 (0)