github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/environs/instances/instance.go (about) 1 // Copyright 2018 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package instances 5 6 import ( 7 "github.com/juju/juju/core/instance" 8 corenetwork "github.com/juju/juju/core/network" 9 "github.com/juju/juju/core/network/firewall" 10 "github.com/juju/juju/environs/context" 11 ) 12 13 // Instance represents the the realization of a machine in state. 14 type Instance interface { 15 // Id returns a provider-generated identifier for the Instance. 16 Id() instance.Id 17 18 // Status returns the provider-specific status for the instance. 19 Status(context.ProviderCallContext) instance.Status 20 21 // Addresses returns a list of hostnames or ip addresses 22 // associated with the instance. 23 Addresses(context.ProviderCallContext) (corenetwork.ProviderAddresses, error) 24 } 25 26 // InstanceFirewaller provides instance-level firewall functionality 27 type InstanceFirewaller interface { 28 // OpenPorts opens the given port ranges on the instance, which 29 // should have been started with the given machine id. 30 OpenPorts(ctx context.ProviderCallContext, machineId string, rules firewall.IngressRules) error 31 32 // ClosePorts closes the given port ranges on the instance, which 33 // should have been started with the given machine id. 34 ClosePorts(ctx context.ProviderCallContext, machineId string, rules firewall.IngressRules) error 35 36 // IngressRules returns the set of ingress rules for the instance, 37 // which should have been applied to the given machine id. The 38 // rules are returned as sorted by network.SortIngressRules(). 39 // It is expected that there be only one ingress rule result for a given 40 // port range - the rule's SourceCIDRs will contain all applicable source 41 // address rules for that port range. 42 IngressRules(ctx context.ProviderCallContext, machineId string) (firewall.IngressRules, error) 43 }