-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(oraclebmcs): Add Oracle BMCS server group creator (#1295)
- Loading branch information
Showing
2 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...spinnaker/orca/clouddriver/tasks/providers/oraclebmcs/OracleBMCSServerGroupCreator.groovy
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,52 @@ | ||
/* | ||
* Copyright (c) 2017 Oracle America, Inc. | ||
* | ||
* The contents of this file are subject to the Apache License Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* If a copy of the Apache License Version 2.0 was not distributed with this file, | ||
* You can obtain one at https://www.apache.org/licenses/LICENSE-2.0.html | ||
*/ | ||
package com.netflix.spinnaker.orca.clouddriver.tasks.providers.oraclebmcs | ||
|
||
import com.netflix.spinnaker.orca.clouddriver.tasks.servergroup.ServerGroupCreator | ||
import com.netflix.spinnaker.orca.kato.tasks.DeploymentDetailsAware | ||
import com.netflix.spinnaker.orca.pipeline.model.Stage | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class OracleBMCSServerGroupCreator implements ServerGroupCreator, DeploymentDetailsAware { | ||
|
||
final boolean katoResultExpected = false | ||
final String cloudProvider = "oraclebmcs" | ||
|
||
@Override | ||
List<Map> getOperations(Stage stage) { | ||
def operation = [:] | ||
|
||
operation.putAll(stage.context) | ||
|
||
if (operation.account && !operation.credentials) { | ||
operation.credentials = operation.account | ||
} | ||
|
||
withImageFromPrecedingStage(stage, null, cloudProvider) { | ||
operation.imageId = operation.imageId ?: it.imageId | ||
} | ||
|
||
withImageFromDeploymentDetails(stage, null, cloudProvider) { | ||
operation.imageId = operation.imageId ?: it.imageId | ||
} | ||
|
||
if (!operation.imageId) { | ||
throw new IllegalStateException("No imageId could be found in ${stage.context.region}.") | ||
} | ||
|
||
return [[(ServerGroupCreator.OPERATION): operation]] | ||
} | ||
|
||
@Override | ||
Optional<String> getHealthProviderName() { | ||
return Optional.of("Oracle") | ||
} | ||
} | ||
|
73 changes: 73 additions & 0 deletions
73
...naker/orca/clouddriver/tasks/providers/oraclebmcs/OracleBMCSServerGroupCreatorSpec.groovy
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,73 @@ | ||
/* | ||
* Copyright (c) 2017 Oracle America, Inc. | ||
* | ||
* The contents of this file are subject to the Apache License Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* If a copy of the Apache License Version 2.0 was not distributed with this file, | ||
* You can obtain one at https://www.apache.org/licenses/LICENSE-2.0.html | ||
*/ | ||
package com.netflix.spinnaker.orca.clouddriver.tasks.providers.oraclebmcs | ||
|
||
import com.netflix.spinnaker.orca.pipeline.model.Pipeline | ||
import com.netflix.spinnaker.orca.pipeline.model.Stage | ||
import spock.lang.Specification | ||
|
||
class OracleBMCSServerGroupCreatorSpec extends Specification { | ||
|
||
def "should get operations"() { | ||
given: | ||
def ctx = [ | ||
account : "abc", | ||
region : "north-pole", | ||
zone : "north-pole-1", | ||
deploymentDetails: [[imageId: "testImageId", region: "north-pole"]], | ||
] | ||
def stage = new Stage(new Pipeline(), "whatever", ctx) | ||
|
||
when: | ||
def ops = new OracleBMCSServerGroupCreator().getOperations(stage) | ||
|
||
then: | ||
ops == [ | ||
[ | ||
"createServerGroup": [ | ||
account : "abc", | ||
credentials : "abc", | ||
imageId : "testImageId", | ||
region : "north-pole", | ||
zone : "north-pole-1", | ||
deploymentDetails: [[imageId: "testImageId", region: "north-pole"]], | ||
], | ||
] | ||
] | ||
|
||
when: "fallback to non-region matching image" | ||
ctx.region = "south-pole" | ||
ctx.zone = "south-pole-1" | ||
stage = new Stage(new Pipeline(), "whatever", ctx) | ||
ops = new OracleBMCSServerGroupCreator().getOperations(stage) | ||
|
||
then: | ||
ops == [ | ||
[ | ||
"createServerGroup": [ | ||
account : "abc", | ||
credentials : "abc", | ||
imageId : "testImageId", | ||
region : "south-pole", | ||
zone : "south-pole-1", | ||
deploymentDetails: [[imageId: "testImageId", region: "north-pole"]], | ||
], | ||
] | ||
] | ||
|
||
when: "throw error if no image found" | ||
ctx.deploymentDetails = [] | ||
stage = new Stage(new Pipeline(), "whatever", ctx) | ||
new OracleBMCSServerGroupCreator().getOperations(stage) | ||
|
||
then: | ||
IllegalStateException ise = thrown() | ||
ise.message == "No imageId could be found in south-pole." | ||
} | ||
} |