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