本文整理匯總了Golang中github.com/cloudfoundry-incubator/bbs/models.NewActualLRPNetInfo函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewActualLRPNetInfo函數的具體用法?Golang NewActualLRPNetInfo怎麽用?Golang NewActualLRPNetInfo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewActualLRPNetInfo函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ActualLRPNetInfoFromContainer
func ActualLRPNetInfoFromContainer(container executor.Container) (*models.ActualLRPNetInfo, error) {
ports := []*models.PortMapping{}
for _, portMapping := range container.Ports {
ports = append(ports, models.NewPortMapping(uint32(portMapping.HostPort), uint32(portMapping.ContainerPort)))
}
actualLRPNetInfo := models.NewActualLRPNetInfo(container.ExternalIP, ports...)
err := actualLRPNetInfo.Validate()
if err != nil {
return nil, err
}
return &actualLRPNetInfo, nil
}
示例2: NewValidActualLRP
func NewValidActualLRP(guid string, index int32) *models.ActualLRP {
actualLRP := &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey(guid, index, "some-domain"),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey("some-guid", "some-cell"),
ActualLRPNetInfo: models.NewActualLRPNetInfo("some-address", models.NewPortMapping(2222, 4444)),
CrashCount: 33,
CrashReason: "badness",
State: models.ActualLRPStateRunning,
Since: 1138,
ModificationTag: models.ModificationTag{
Epoch: "some-epoch",
Index: 999,
},
}
err := actualLRP.Validate()
Expect(err).NotTo(HaveOccurred())
return actualLRP
}
示例3: lrpForState
func lrpForState(state string, timeInState time.Duration) models.ActualLRP {
var actualLRPKey = models.NewActualLRPKey("some-process-guid", 1, "tests")
var instanceKey = models.NewActualLRPInstanceKey("some-instance-guid", "some-cell")
lrp := models.ActualLRP{
ActualLRPKey: actualLRPKey,
State: state,
Since: clock.Now().Add(-timeInState).UnixNano(),
}
switch state {
case models.ActualLRPStateUnclaimed:
case models.ActualLRPStateCrashed:
lrp.CrashReason = "crashed"
case models.ActualLRPStateClaimed:
lrp.ActualLRPInstanceKey = instanceKey
case models.ActualLRPStateRunning:
lrp.ActualLRPInstanceKey = instanceKey
lrp.ActualLRPNetInfo = models.NewActualLRPNetInfo("1.2.3.4", &models.PortMapping{ContainerPort: 1234, HostPort: 5678})
}
return lrp
}
示例4: itValidatesAbsenceOfNetInfo
func itValidatesAbsenceOfNetInfo(lrp *models.ActualLRP) {
Context("when net info is set", func() {
BeforeEach(func() {
lrp.ActualLRPNetInfo = models.NewActualLRPNetInfo("1.2.3.4")
})
It("validate returns an error", func() {
err := lrp.Validate()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("net info"))
})
})
Context("when net info is not set", func() {
BeforeEach(func() {
lrp.ActualLRPNetInfo = models.ActualLRPNetInfo{}
})
It("validate does not return an error", func() {
Expect(lrp.Validate()).NotTo(HaveOccurred())
})
})
}
示例5:
"index": 2,
"state": "RUNNING",
"since": 1138,
"cell_id":"some-cell-id",
"domain":"some-domain",
"crash_count": 1,
"modification_tag": {
"epoch": "some-guid",
"index": 50
}
}`
BeforeEach(func() {
lrpKey = models.NewActualLRPKey("some-guid", 2, "some-domain")
instanceKey = models.NewActualLRPInstanceKey("some-instance-guid", "some-cell-id")
netInfo = models.NewActualLRPNetInfo("1.2.3.4", models.NewPortMapping(5678, 8080), models.NewPortMapping(1234, 8081))
lrp = models.ActualLRP{
ActualLRPKey: lrpKey,
ActualLRPInstanceKey: instanceKey,
ActualLRPNetInfo: netInfo,
CrashCount: 1,
State: models.ActualLRPStateRunning,
Since: 1138,
ModificationTag: models.ModificationTag{
Epoch: "some-guid",
Index: 50,
},
}
})
示例6:
logger = lager.NewLogger("test")
logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG))
responseRecorder = httptest.NewRecorder()
handler = handlers.NewActualLRPHandler(fakeBBS, fakeLegacyBBS, logger)
actualLRP1 = models.NewRunningActualLRP(
models.NewActualLRPKey(
"process-guid-0",
1,
"domain-0",
),
models.NewActualLRPInstanceKey(
"instance-guid-0",
"cell-id-0",
),
models.NewActualLRPNetInfo("1.1.1.1", models.NewPortMapping(80, 5050)),
1138,
)
actualLRP2 = models.NewClaimedActualLRP(
models.NewActualLRPKey(
"process-guid-1",
2,
"domain-1",
),
models.NewActualLRPInstanceKey(
"instance-guid-1",
"cell-id-1",
),
4444,
)
示例7:
Domain: "domain",
Instances: 1,
RootFs: "some:rootfs",
Action: models.WrapAction(&models.RunAction{Path: "/bin/true", User: "name"}),
}
index int32 = 0
lrpKey = models.NewActualLRPKey(desiredLRP.ProcessGuid, index, desiredLRP.Domain)
alphaInstanceKey = models.NewActualLRPInstanceKey(alphaInstanceGuid, alphaCellID)
betaInstanceKey = models.NewActualLRPInstanceKey(betaInstanceGuid, betaCellID)
omegaInstanceKey = models.NewActualLRPInstanceKey(omegaInstanceGuid, omegaCellID)
emptyInstanceKey = models.ActualLRPInstanceKey{}
alphaPorts = models.NewPortMapping(9872, 2349)
alphaNetInfo = models.NewActualLRPNetInfo(alphaAddress, alphaPorts)
betaPorts = models.NewPortMapping(9868, 2353)
betaNetInfo = models.NewActualLRPNetInfo(betaAddress, betaPorts)
omegaPorts = models.NewPortMapping(9876, 2345)
omegaNetInfo = models.NewActualLRPNetInfo(omegaAddress, omegaPorts)
emptyNetInfo = models.EmptyActualLRPNetInfo()
)
type testable interface {
Test()
}
type evacuationTest struct {
Name string
Subject func() (bool, error)
InstanceLRP lrpSetupFunc
示例8:
dummyMessage = routing_table.RegistryMessageFor(dummyEndpoint, routing_table.Routes{Hostnames: []string{"baz.com"}, LogGuid: logGuid})
messagesToEmit = routing_table.MessagesToEmit{
RegistrationMessages: []routing_table.RegistryMessage{dummyMessage},
}
schedulingInfoResponse = &models.DesiredLRPSchedulingInfo{
DesiredLRPKey: models.NewDesiredLRPKey(processGuid, "domain", logGuid),
Routes: cfroutes.CFRoutes{{Hostnames: []string{"route-1", "route-2"}, Port: containerPort}}.RoutingInfo(),
}
actualResponses = []*models.ActualLRPGroup{
{
Instance: &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey(processGuid, 1, "domain"),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey(instanceGuid, "cell-id"),
ActualLRPNetInfo: models.NewActualLRPNetInfo(lrpHost, models.NewPortMapping(1234, containerPort)),
State: models.ActualLRPStateRunning,
},
},
{
Instance: &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey("", 1, ""),
State: models.ActualLRPStateUnclaimed,
},
},
}
bbsClient.DesiredLRPSchedulingInfosReturns([]*models.DesiredLRPSchedulingInfo{schedulingInfoResponse}, nil)
bbsClient.ActualLRPGroupsReturns(actualResponses, nil)
fakeMetricSender = fake_metrics_sender.NewFakeMetricSender()
示例9:
Describe("Process", func() {
const sessionPrefix = "test.ordinary-lrp-processor."
var (
desiredLRP *models.DesiredLRP
expectedLrpKey models.ActualLRPKey
expectedInstanceKey models.ActualLRPInstanceKey
expectedNetInfo models.ActualLRPNetInfo
expectedSessionName string
)
BeforeEach(func() {
desiredLRP = model_helpers.NewValidDesiredLRP("process-guid")
expectedLrpKey = models.NewActualLRPKey("process-guid", 2, "domain")
expectedInstanceKey = models.NewActualLRPInstanceKey("instance-guid", "cell-id")
expectedNetInfo = models.NewActualLRPNetInfo("1.2.3.4", models.NewPortMapping(61999, 8080))
})
Context("when given an LRP container", func() {
var container executor.Container
BeforeEach(func() {
container = newLRPContainer(expectedLrpKey, expectedInstanceKey, expectedNetInfo)
})
JustBeforeEach(func() {
processor.Process(logger, container)
})
Context("and the container is INVALID", func() {
BeforeEach(func() {
示例10:
BeforeEach(func() {
bbsRunner = testrunner.New(bbsBinPath, bbsArgs)
bbsProcess = ginkgomon.Invoke(bbsRunner)
filter = models.ActualLRPFilter{}
expectedActualLRPGroups = []*models.ActualLRPGroup{}
actualActualLRPGroups = []*models.ActualLRPGroup{}
baseLRPKey = models.NewActualLRPKey(baseProcessGuid, baseIndex, baseDomain)
baseLRPInstanceKey = models.NewActualLRPInstanceKey(baseInstanceGuid, cellID)
evacuatingLRPInstanceKey = models.NewActualLRPInstanceKey(evacuatingInstanceGuid, cellID)
otherLRPKey = models.NewActualLRPKey(otherProcessGuid, otherIndex, otherDomain)
otherLRPInstanceKey = models.NewActualLRPInstanceKey(otherInstanceGuid, otherCellID)
netInfo = models.NewActualLRPNetInfo("127.0.0.1", models.NewPortMapping(8080, 80))
unclaimedLRPKey = models.NewActualLRPKey(unclaimedProcessGuid, unclaimedIndex, unclaimedDomain)
crashingLRPKey = models.NewActualLRPKey(crashingProcessGuid, crashingIndex, crashingDomain)
crashingLRPInstanceKey = models.NewActualLRPInstanceKey(crashingInstanceGuid, otherCellID)
baseLRP = &models.ActualLRP{
ActualLRPKey: baseLRPKey,
ActualLRPInstanceKey: baseLRPInstanceKey,
ActualLRPNetInfo: netInfo,
State: models.ActualLRPStateRunning,
Since: time.Now().UnixNano(),
}
evacuatingLRP = &models.ActualLRP{
示例11:
Describe("ActualLRPProtoToResponse", func() {
var actualLRP *models.ActualLRP
BeforeEach(func() {
actualLRP = &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey(
"process-guid-0",
3,
"some-domain",
),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey(
"instance-guid-0",
"cell-id-0",
),
ActualLRPNetInfo: models.NewActualLRPNetInfo(
"address-0",
models.NewPortMapping(9876, 2345),
),
State: models.ActualLRPStateRunning,
CrashCount: 42,
Since: 99999999999,
ModificationTag: models.ModificationTag{
Epoch: "some-guid",
Index: 50,
},
}
})
It("serializes all the fields", func() {
expectedResponse := receptor.ActualLRPResponse{
ProcessGuid: "process-guid-0",
InstanceGuid: "instance-guid-0",
示例12:
evacuatingLRP *models.ActualLRP
otherDomainLRP *models.ActualLRP
otherCellIdLRP *models.ActualLRP
baseLRPKey models.ActualLRPKey
baseLRPInstanceKey models.ActualLRPInstanceKey
otherLRPInstanceKey models.ActualLRPInstanceKey
netInfo models.ActualLRPNetInfo
)
BeforeEach(func() {
baseLRPKey = models.NewActualLRPKey(baseProcessGuid, baseIndex, baseDomain)
baseLRPInstanceKey = models.NewActualLRPInstanceKey(baseInstanceGuid, cellID)
otherLRPInstanceKey = models.NewActualLRPInstanceKey(otherInstanceGuid, otherCellID)
netInfo = models.NewActualLRPNetInfo("127.0.0.1", models.NewPortMapping(8080, 80))
baseLRP = &models.ActualLRP{
ActualLRPKey: baseLRPKey,
ActualLRPInstanceKey: baseLRPInstanceKey,
ActualLRPNetInfo: netInfo,
State: models.ActualLRPStateRunning,
Since: clock.Now().UnixNano(),
}
evacuatingLRP = &models.ActualLRP{
ActualLRPKey: baseLRPKey,
ActualLRPInstanceKey: models.NewActualLRPInstanceKey(evacuatingInstanceGuid, cellID),
ActualLRPNetInfo: netInfo,
State: models.ActualLRPStateRunning,
Since: clock.Now().UnixNano() - 1000,
示例13:
It("should not be included in the results", func() {
routes := routing_table.RoutesByRoutingKeyFromSchedulingInfos([]*models.DesiredLRPSchedulingInfo{
{DesiredLRPKey: models.NewDesiredLRPKey("abc", "tests", "abc-guid"), Routes: nil},
})
Expect(routes).To(HaveLen(0))
})
})
})
Describe("EndpointsByRoutingKeyFromActuals", func() {
It("should build a map of endpoints, ignoring those without ports", func() {
endpoints := routing_table.EndpointsByRoutingKeyFromActuals([]*routing_table.ActualLRPRoutingInfo{
{
ActualLRP: &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey("abc", 0, "domain"),
ActualLRPNetInfo: models.NewActualLRPNetInfo("1.1.1.1", models.NewPortMapping(11, 44), models.NewPortMapping(66, 99)),
},
},
{
ActualLRP: &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey("abc", 1, "domain"),
ActualLRPNetInfo: models.NewActualLRPNetInfo("2.2.2.2", models.NewPortMapping(22, 44), models.NewPortMapping(88, 99)),
},
},
{
ActualLRP: &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey("def", 0, "domain"),
ActualLRPNetInfo: models.NewActualLRPNetInfo("3.3.3.3", models.NewPortMapping(33, 55)),
},
},
{
示例14:
diegoSSHRouteMessage := json.RawMessage(diegoSSHRoutePayload)
desiredLRP = &models.DesiredLRP{
ProcessGuid: "some-guid",
Instances: 2,
Routes: &models.Routes{
routes.DIEGO_SSH: &diegoSSHRouteMessage,
},
LogGuid: "log-guid",
}
actualLRPGroup = &models.ActualLRPGroup{
Instance: &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey("some-guid", 1, "some-domain"),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey("some-instance-guid", "some-cell-id"),
ActualLRPNetInfo: models.NewActualLRPNetInfo("1.2.3.4", models.NewPortMapping(3333, 1111)),
},
}
bbsClient = new(fake_bbs.FakeClient)
bbsClient.ActualLRPGroupByProcessGuidAndIndexReturns(actualLRPGroup, nil)
bbsClient.DesiredLRPByProcessGuidReturns(desiredLRP, nil)
credentials = []byte("some-user:some-password")
permissionsBuilder = authenticators.NewPermissionsBuiler(bbsClient)
remoteAddr, err := net.ResolveIPAddr("ip", "1.1.1.1")
Expect(err).NotTo(HaveOccurred())
metadata = &fake_ssh.FakeConnMetadata{}
metadata.RemoteAddrReturns(remoteAddr)
示例15:
Context("when a create event occurs", func() {
var (
actualLRPGroup *models.ActualLRPGroup
actualLRP *models.ActualLRP
actualLRPRoutingInfo *routing_table.ActualLRPRoutingInfo
)
Context("when the resulting LRP is in the RUNNING state", func() {
BeforeEach(func() {
actualLRP = &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey(expectedProcessGuid, 1, "domain"),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey(expectedInstanceGuid, "cell-id"),
ActualLRPNetInfo: models.NewActualLRPNetInfo(
expectedHost,
models.NewPortMapping(expectedExternalPort, expectedContainerPort),
models.NewPortMapping(expectedExternalPort, expectedAdditionalContainerPort),
),
State: models.ActualLRPStateRunning,
}
actualLRPGroup = &models.ActualLRPGroup{
Instance: actualLRP,
}
actualLRPRoutingInfo = &routing_table.ActualLRPRoutingInfo{
ActualLRP: actualLRP,
Evacuating: false,
}
})