openstack.compute.ServerGroup
Explore with Pulumi AI
Manages a V2 Server Group resource within OpenStack.
Example Usage
Compute service API version 2.63 or below:
import * as pulumi from "@pulumi/pulumi";
import * as openstack from "@pulumi/openstack";
const test_sg = new openstack.compute.ServerGroup("test-sg", {
name: "my-sg",
policies: "anti-affinity",
});
const test_instance = new openstack.compute.Instance("test-instance", {
name: "my-instance",
imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
flavorId: "3",
schedulerHints: [{
group: test_sg.id,
}],
networks: [{
name: "my_network",
}],
});
import pulumi
import pulumi_openstack as openstack
test_sg = openstack.compute.ServerGroup("test-sg",
name="my-sg",
policies="anti-affinity")
test_instance = openstack.compute.Instance("test-instance",
name="my-instance",
image_id="ad091b52-742f-469e-8f3c-fd81cadf0743",
flavor_id="3",
scheduler_hints=[{
"group": test_sg.id,
}],
networks=[{
"name": "my_network",
}])
package main
import (
"github.com/pulumi/pulumi-openstack/sdk/v5/go/openstack/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := compute.NewServerGroup(ctx, "test-sg", &compute.ServerGroupArgs{
Name: pulumi.String("my-sg"),
Policies: pulumi.String("anti-affinity"),
})
if err != nil {
return err
}
_, err = compute.NewInstance(ctx, "test-instance", &compute.InstanceArgs{
Name: pulumi.String("my-instance"),
ImageId: pulumi.String("ad091b52-742f-469e-8f3c-fd81cadf0743"),
FlavorId: pulumi.String("3"),
SchedulerHints: compute.InstanceSchedulerHintArray{
&compute.InstanceSchedulerHintArgs{
Group: test_sg.ID(),
},
},
Networks: compute.InstanceNetworkArray{
&compute.InstanceNetworkArgs{
Name: pulumi.String("my_network"),
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using OpenStack = Pulumi.OpenStack;
return await Deployment.RunAsync(() =>
{
var test_sg = new OpenStack.Compute.ServerGroup("test-sg", new()
{
Name = "my-sg",
Policies = "anti-affinity",
});
var test_instance = new OpenStack.Compute.Instance("test-instance", new()
{
Name = "my-instance",
ImageId = "ad091b52-742f-469e-8f3c-fd81cadf0743",
FlavorId = "3",
SchedulerHints = new[]
{
new OpenStack.Compute.Inputs.InstanceSchedulerHintArgs
{
Group = test_sg.Id,
},
},
Networks = new[]
{
new OpenStack.Compute.Inputs.InstanceNetworkArgs
{
Name = "my_network",
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.openstack.compute.ServerGroup;
import com.pulumi.openstack.compute.ServerGroupArgs;
import com.pulumi.openstack.compute.Instance;
import com.pulumi.openstack.compute.InstanceArgs;
import com.pulumi.openstack.compute.inputs.InstanceSchedulerHintArgs;
import com.pulumi.openstack.compute.inputs.InstanceNetworkArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var test_sg = new ServerGroup("test-sg", ServerGroupArgs.builder()
.name("my-sg")
.policies("anti-affinity")
.build());
var test_instance = new Instance("test-instance", InstanceArgs.builder()
.name("my-instance")
.imageId("ad091b52-742f-469e-8f3c-fd81cadf0743")
.flavorId("3")
.schedulerHints(InstanceSchedulerHintArgs.builder()
.group(test_sg.id())
.build())
.networks(InstanceNetworkArgs.builder()
.name("my_network")
.build())
.build());
}
}
resources:
test-sg:
type: openstack:compute:ServerGroup
properties:
name: my-sg
policies: anti-affinity
test-instance:
type: openstack:compute:Instance
properties:
name: my-instance
imageId: ad091b52-742f-469e-8f3c-fd81cadf0743
flavorId: '3'
schedulerHints:
- group: ${["test-sg"].id}
networks:
- name: my_network
Compute service API version 2.64 or above:
import * as pulumi from "@pulumi/pulumi";
import * as openstack from "@pulumi/openstack";
const test_sg = new openstack.compute.ServerGroup("test-sg", {
name: "my-sg",
policies: "anti-affinity",
rules: {
maxServerPerHost: 3,
},
});
const test_instance = new openstack.compute.Instance("test-instance", {
name: "my-instance",
imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
flavorId: "3",
schedulerHints: [{
group: test_sg.id,
}],
networks: [{
name: "my_network",
}],
});
import pulumi
import pulumi_openstack as openstack
test_sg = openstack.compute.ServerGroup("test-sg",
name="my-sg",
policies="anti-affinity",
rules={
"max_server_per_host": 3,
})
test_instance = openstack.compute.Instance("test-instance",
name="my-instance",
image_id="ad091b52-742f-469e-8f3c-fd81cadf0743",
flavor_id="3",
scheduler_hints=[{
"group": test_sg.id,
}],
networks=[{
"name": "my_network",
}])
package main
import (
"github.com/pulumi/pulumi-openstack/sdk/v5/go/openstack/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := compute.NewServerGroup(ctx, "test-sg", &compute.ServerGroupArgs{
Name: pulumi.String("my-sg"),
Policies: pulumi.String("anti-affinity"),
Rules: &compute.ServerGroupRulesArgs{
MaxServerPerHost: pulumi.Int(3),
},
})
if err != nil {
return err
}
_, err = compute.NewInstance(ctx, "test-instance", &compute.InstanceArgs{
Name: pulumi.String("my-instance"),
ImageId: pulumi.String("ad091b52-742f-469e-8f3c-fd81cadf0743"),
FlavorId: pulumi.String("3"),
SchedulerHints: compute.InstanceSchedulerHintArray{
&compute.InstanceSchedulerHintArgs{
Group: test_sg.ID(),
},
},
Networks: compute.InstanceNetworkArray{
&compute.InstanceNetworkArgs{
Name: pulumi.String("my_network"),
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using OpenStack = Pulumi.OpenStack;
return await Deployment.RunAsync(() =>
{
var test_sg = new OpenStack.Compute.ServerGroup("test-sg", new()
{
Name = "my-sg",
Policies = "anti-affinity",
Rules = new OpenStack.Compute.Inputs.ServerGroupRulesArgs
{
MaxServerPerHost = 3,
},
});
var test_instance = new OpenStack.Compute.Instance("test-instance", new()
{
Name = "my-instance",
ImageId = "ad091b52-742f-469e-8f3c-fd81cadf0743",
FlavorId = "3",
SchedulerHints = new[]
{
new OpenStack.Compute.Inputs.InstanceSchedulerHintArgs
{
Group = test_sg.Id,
},
},
Networks = new[]
{
new OpenStack.Compute.Inputs.InstanceNetworkArgs
{
Name = "my_network",
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.openstack.compute.ServerGroup;
import com.pulumi.openstack.compute.ServerGroupArgs;
import com.pulumi.openstack.compute.inputs.ServerGroupRulesArgs;
import com.pulumi.openstack.compute.Instance;
import com.pulumi.openstack.compute.InstanceArgs;
import com.pulumi.openstack.compute.inputs.InstanceSchedulerHintArgs;
import com.pulumi.openstack.compute.inputs.InstanceNetworkArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var test_sg = new ServerGroup("test-sg", ServerGroupArgs.builder()
.name("my-sg")
.policies("anti-affinity")
.rules(ServerGroupRulesArgs.builder()
.maxServerPerHost(3)
.build())
.build());
var test_instance = new Instance("test-instance", InstanceArgs.builder()
.name("my-instance")
.imageId("ad091b52-742f-469e-8f3c-fd81cadf0743")
.flavorId("3")
.schedulerHints(InstanceSchedulerHintArgs.builder()
.group(test_sg.id())
.build())
.networks(InstanceNetworkArgs.builder()
.name("my_network")
.build())
.build());
}
}
resources:
test-sg:
type: openstack:compute:ServerGroup
properties:
name: my-sg
policies: anti-affinity
rules:
maxServerPerHost: 3
test-instance:
type: openstack:compute:Instance
properties:
name: my-instance
imageId: ad091b52-742f-469e-8f3c-fd81cadf0743
flavorId: '3'
schedulerHints:
- group: ${["test-sg"].id}
networks:
- name: my_network
Policies
affinity
- All instances/servers launched in this group will be hosted on the same compute node.anti-affinity
- All instances/servers launched in this group will be hosted on different compute nodes.soft-affinity
- All instances/servers launched in this group will be hosted on the same compute node if possible, but if not possible they still will be scheduled instead of failure. To use this policy your OpenStack environment should support Compute service API 2.15 or above.soft-anti-affinity
- All instances/servers launched in this group will be hosted on different compute nodes if possible, but if not possible they still will be scheduled instead of failure. To use this policy your OpenStack environment should support Compute service API 2.15 or above.
Create ServerGroup Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ServerGroup(name: string, args?: ServerGroupArgs, opts?: CustomResourceOptions);
@overload
def ServerGroup(resource_name: str,
args: Optional[ServerGroupArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def ServerGroup(resource_name: str,
opts: Optional[ResourceOptions] = None,
name: Optional[str] = None,
policies: Optional[str] = None,
region: Optional[str] = None,
rules: Optional[ServerGroupRulesArgs] = None,
value_specs: Optional[Mapping[str, str]] = None)
func NewServerGroup(ctx *Context, name string, args *ServerGroupArgs, opts ...ResourceOption) (*ServerGroup, error)
public ServerGroup(string name, ServerGroupArgs? args = null, CustomResourceOptions? opts = null)
public ServerGroup(String name, ServerGroupArgs args)
public ServerGroup(String name, ServerGroupArgs args, CustomResourceOptions options)
type: openstack:compute:ServerGroup
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args ServerGroupArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args ServerGroupArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args ServerGroupArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ServerGroupArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ServerGroupArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var serverGroupResource = new OpenStack.Compute.ServerGroup("serverGroupResource", new()
{
Name = "string",
Policies = "string",
Region = "string",
Rules = new OpenStack.Compute.Inputs.ServerGroupRulesArgs
{
MaxServerPerHost = 0,
},
ValueSpecs =
{
{ "string", "string" },
},
});
example, err := compute.NewServerGroup(ctx, "serverGroupResource", &compute.ServerGroupArgs{
Name: pulumi.String("string"),
Policies: pulumi.String("string"),
Region: pulumi.String("string"),
Rules: &compute.ServerGroupRulesArgs{
MaxServerPerHost: pulumi.Int(0),
},
ValueSpecs: pulumi.StringMap{
"string": pulumi.String("string"),
},
})
var serverGroupResource = new ServerGroup("serverGroupResource", ServerGroupArgs.builder()
.name("string")
.policies("string")
.region("string")
.rules(ServerGroupRulesArgs.builder()
.maxServerPerHost(0)
.build())
.valueSpecs(Map.of("string", "string"))
.build());
server_group_resource = openstack.compute.ServerGroup("serverGroupResource",
name="string",
policies="string",
region="string",
rules={
"max_server_per_host": 0,
},
value_specs={
"string": "string",
})
const serverGroupResource = new openstack.compute.ServerGroup("serverGroupResource", {
name: "string",
policies: "string",
region: "string",
rules: {
maxServerPerHost: 0,
},
valueSpecs: {
string: "string",
},
});
type: openstack:compute:ServerGroup
properties:
name: string
policies: string
region: string
rules:
maxServerPerHost: 0
valueSpecs:
string: string
ServerGroup Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The ServerGroup resource accepts the following input properties:
- Name string
- A unique name for the server group. Changing this creates a new server group.
- Policies string
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- Region string
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - Rules
Pulumi.
Open Stack. Compute. Inputs. Server Group Rules - The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - Value
Specs Dictionary<string, string> - Map of additional options.
- Name string
- A unique name for the server group. Changing this creates a new server group.
- Policies string
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- Region string
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - Rules
Server
Group Rules Args - The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - Value
Specs map[string]string - Map of additional options.
- name String
- A unique name for the server group. Changing this creates a new server group.
- policies String
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- region String
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - rules
Server
Group Rules - The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - value
Specs Map<String,String> - Map of additional options.
- name string
- A unique name for the server group. Changing this creates a new server group.
- policies string
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- region string
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - rules
Server
Group Rules - The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - value
Specs {[key: string]: string} - Map of additional options.
- name str
- A unique name for the server group. Changing this creates a new server group.
- policies str
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- region str
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - rules
Server
Group Rules Args - The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - value_
specs Mapping[str, str] - Map of additional options.
- name String
- A unique name for the server group. Changing this creates a new server group.
- policies String
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- region String
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - rules Property Map
- The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - value
Specs Map<String> - Map of additional options.
Outputs
All input properties are implicitly available as output properties. Additionally, the ServerGroup resource produces the following output properties:
Look up Existing ServerGroup Resource
Get an existing ServerGroup resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: ServerGroupState, opts?: CustomResourceOptions): ServerGroup
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
members: Optional[Sequence[str]] = None,
name: Optional[str] = None,
policies: Optional[str] = None,
region: Optional[str] = None,
rules: Optional[ServerGroupRulesArgs] = None,
value_specs: Optional[Mapping[str, str]] = None) -> ServerGroup
func GetServerGroup(ctx *Context, name string, id IDInput, state *ServerGroupState, opts ...ResourceOption) (*ServerGroup, error)
public static ServerGroup Get(string name, Input<string> id, ServerGroupState? state, CustomResourceOptions? opts = null)
public static ServerGroup get(String name, Output<String> id, ServerGroupState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Members List<string>
- The instances that are part of this server group.
- Name string
- A unique name for the server group. Changing this creates a new server group.
- Policies string
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- Region string
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - Rules
Pulumi.
Open Stack. Compute. Inputs. Server Group Rules - The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - Value
Specs Dictionary<string, string> - Map of additional options.
- Members []string
- The instances that are part of this server group.
- Name string
- A unique name for the server group. Changing this creates a new server group.
- Policies string
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- Region string
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - Rules
Server
Group Rules Args - The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - Value
Specs map[string]string - Map of additional options.
- members List<String>
- The instances that are part of this server group.
- name String
- A unique name for the server group. Changing this creates a new server group.
- policies String
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- region String
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - rules
Server
Group Rules - The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - value
Specs Map<String,String> - Map of additional options.
- members string[]
- The instances that are part of this server group.
- name string
- A unique name for the server group. Changing this creates a new server group.
- policies string
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- region string
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - rules
Server
Group Rules - The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - value
Specs {[key: string]: string} - Map of additional options.
- members Sequence[str]
- The instances that are part of this server group.
- name str
- A unique name for the server group. Changing this creates a new server group.
- policies str
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- region str
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - rules
Server
Group Rules Args - The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - value_
specs Mapping[str, str] - Map of additional options.
- members List<String>
- The instances that are part of this server group.
- name String
- A unique name for the server group. Changing this creates a new server group.
- policies String
- A list of exactly one policy name to associate with the server group. See the Policies section for more information. Changing this creates a new server group.
- region String
- The region in which to obtain the V2 Compute client.
If omitted, the
region
argument of the provider is used. Changing this creates a new server group. - rules Property Map
- The rules which are applied to specified
policy
. Currently, only themax_server_per_host
rule is supported for theanti-affinity
policy. - value
Specs Map<String> - Map of additional options.
Supporting Types
ServerGroupRules, ServerGroupRulesArgs
- Max
Server intPer Host
- Max
Server intPer Host
- max
Server IntegerPer Host
- max
Server numberPer Host
- max
Server NumberPer Host
Import
Server Groups can be imported using the id
, e.g.
$ pulumi import openstack:compute/serverGroup:ServerGroup test-sg 1bc30ee9-9d5b-4c30-bdd5-7f1e663f5edf
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- OpenStack pulumi/pulumi-openstack
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
openstack
Terraform Provider.