github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/cloudconfig/cloudinit/cloudinit_win.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Copyright 2015 Cloudbase Solutions SRL
     3  // Licensed under the AGPLv3, see LICENCE file for details.
     4  
     5  package cloudinit
     6  
     7  import (
     8  	"github.com/juju/packaging"
     9  	"github.com/juju/proxy"
    10  
    11  	"github.com/juju/juju/network"
    12  )
    13  
    14  // windowsCloudConfig is the cloudconfig type specific to Windows machines.
    15  // It mostly deals entirely with passing the equivalent of runcmds to
    16  // cloudbase-init, leaving most of the other functionalities uninmplemented.
    17  // It implements the CloudConfig interface.
    18  type windowsCloudConfig struct {
    19  	*cloudConfig
    20  }
    21  
    22  // SetPackageProxy is defined on the PackageProxyConfig interface.
    23  func (cfg *windowsCloudConfig) SetPackageProxy(url string) {
    24  }
    25  
    26  // UnsetPackageProxy is defined on the PackageProxyConfig interface.
    27  func (cfg *windowsCloudConfig) UnsetPackageProxy() {
    28  }
    29  
    30  // PackageProxy is defined on the PackageProxyConfig interface.
    31  func (cfg *windowsCloudConfig) PackageProxy() string {
    32  	return ""
    33  }
    34  
    35  // SetPackageMirror is defined on the PackageMirrorConfig interface.
    36  func (cfg *windowsCloudConfig) SetPackageMirror(url string) {
    37  }
    38  
    39  // UnsetPackageMirror is defined on the PackageMirrorConfig interface.
    40  func (cfg *windowsCloudConfig) UnsetPackageMirror() {
    41  }
    42  
    43  // PackageMirror is defined on the PackageMirrorConfig interface.
    44  func (cfg *windowsCloudConfig) PackageMirror() string {
    45  	return ""
    46  }
    47  
    48  // AddPackageSource is defined on the PackageSourcesConfig interface.
    49  func (cfg *windowsCloudConfig) AddPackageSource(src packaging.PackageSource) {
    50  }
    51  
    52  // PackageSources is defined on the PackageSourcesConfig interface.
    53  func (cfg *windowsCloudConfig) PackageSources() []packaging.PackageSource {
    54  	return nil
    55  }
    56  
    57  // AddPackagePreferences is defined on the PackageSourcesConfig interface.
    58  func (cfg *windowsCloudConfig) AddPackagePreferences(prefs packaging.PackagePreferences) {
    59  }
    60  
    61  // PackagePreferences is defined on the PackageSourcesConfig interface.
    62  func (cfg *windowsCloudConfig) PackagePreferences() []packaging.PackagePreferences {
    63  	return nil
    64  }
    65  
    66  // RenderYAML is defined on the RenderConfig interface.
    67  func (cfg *windowsCloudConfig) RenderYAML() ([]byte, error) {
    68  	return cfg.renderWindows()
    69  }
    70  
    71  // RenderScript is defined on the RenderConfig interface.
    72  func (cfg *windowsCloudConfig) RenderScript() (string, error) {
    73  	// NOTE: This shouldn't really be called on windows as it's used only for
    74  	// initialization via ssh.
    75  	script, err := cfg.renderWindows()
    76  	if err != nil {
    77  		return "", err
    78  	}
    79  
    80  	return string(script), err
    81  }
    82  
    83  // getCommandsForAddingPackages is defined on the RenderConfig interface.
    84  func (cfg *windowsCloudConfig) getCommandsForAddingPackages() ([]string, error) {
    85  	return nil, nil
    86  }
    87  
    88  // renderWindows is a helper function which renders the runCmds of the Windows
    89  // CloudConfig to a PowerShell script.
    90  func (cfg *windowsCloudConfig) renderWindows() ([]byte, error) {
    91  	winCmds := cfg.RunCmds()
    92  	var script []byte
    93  	newline := "\r\n"
    94  	header := "#ps1_sysnative\r\n"
    95  	script = append(script, header...)
    96  	for _, cmd := range winCmds {
    97  		script = append(script, newline...)
    98  		script = append(script, cmd...)
    99  	}
   100  	return script, nil
   101  }
   102  
   103  // AddPackageCommands is defined on the AdvancedPackagingConfig interface.
   104  func (cfg *windowsCloudConfig) AddPackageCommands(
   105  	aptProxySettings proxy.Settings,
   106  	aptMirror string,
   107  	addUpdateScripts bool,
   108  	addUpgradeScripts bool,
   109  ) {
   110  	return
   111  }
   112  
   113  // AddCloudArchiveCloudTools is defined on the AdvancedPackagingConfig
   114  // interface.
   115  func (cfg *windowsCloudConfig) AddCloudArchiveCloudTools() {
   116  }
   117  
   118  // addRequiredPackages is defined on the AdvancedPackagingConfig interface.
   119  func (cfg *windowsCloudConfig) addRequiredPackages() {
   120  }
   121  
   122  // updateProxySettings is defined on the AdvancedPackagingConfig interface.
   123  func (cfg *windowsCloudConfig) updateProxySettings(proxy.Settings) {
   124  }
   125  
   126  // AddNetworkConfig is defined on the NetworkingConfig interface.
   127  func (cfg *windowsCloudConfig) AddNetworkConfig(interfaces []network.InterfaceInfo) error {
   128  	return nil
   129  }