github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/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  	"github.com/juju/juju/environs/context"
     9  	"github.com/juju/juju/network"
    10  )
    11  
    12  // Instance represents the the realization of a machine in state.
    13  type Instance interface {
    14  	// Id returns a provider-generated identifier for the Instance.
    15  	Id() instance.Id
    16  
    17  	// Status returns the provider-specific status for the instance.
    18  	Status(context.ProviderCallContext) instance.Status
    19  
    20  	// Addresses returns a list of hostnames or ip addresses
    21  	// associated with the instance.
    22  	Addresses(context.ProviderCallContext) ([]network.Address, error)
    23  }
    24  
    25  // InstanceFirewaller provides instance-level firewall functionality
    26  type InstanceFirewaller interface {
    27  	// OpenPorts opens the given port ranges on the instance, which
    28  	// should have been started with the given machine id.
    29  	OpenPorts(ctx context.ProviderCallContext, machineId string, rules []network.IngressRule) error
    30  
    31  	// ClosePorts closes the given port ranges on the instance, which
    32  	// should have been started with the given machine id.
    33  	ClosePorts(ctx context.ProviderCallContext, machineId string, rules []network.IngressRule) error
    34  
    35  	// IngressRules returns the set of ingress rules for the instance,
    36  	// which should have been applied to the given machine id. The
    37  	// rules are returned as sorted by network.SortIngressRules().
    38  	// It is expected that there be only one ingress rule result for a given
    39  	// port range - the rule's SourceCIDRs will contain all applicable source
    40  	// address rules for that port range.
    41  	IngressRules(ctx context.ProviderCallContext, machineId string) ([]network.IngressRule, error)
    42  }