yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/esxi/guestos.go (about)

     1  // Copyright 2019 Yunion
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package esxi
    16  
    17  type TOSType string
    18  
    19  type TOSArch string
    20  
    21  const (
    22  	LINUX   = TOSType("Linux")
    23  	WINDOWS = TOSType("Windows")
    24  	MACOS   = TOSType("macOS")
    25  	FREEBSD = TOSType("FreeBSD")
    26  	SOLARIS = TOSType("Solaris")
    27  	VMWARE  = TOSType("VMware")
    28  
    29  	X86    = TOSArch("x86")
    30  	X86_64 = TOSArch("x86_64")
    31  )
    32  
    33  type SOsInfo struct {
    34  	OsType         TOSType
    35  	OsDistribution string
    36  	OsVersion      string
    37  	OsArch         TOSArch
    38  }
    39  
    40  func asian(ver string, arch TOSArch) SOsInfo {
    41  	return SOsInfo{LINUX, "Asianux Server", ver, arch}
    42  }
    43  
    44  func centos4_5(arch TOSArch) SOsInfo {
    45  	return centos("4/5", arch)
    46  }
    47  
    48  func centos(ver string, arch TOSArch) SOsInfo {
    49  	return SOsInfo{LINUX, "CentOS", ver, arch}
    50  }
    51  
    52  func coreos(ver string, arch TOSArch) SOsInfo {
    53  	return SOsInfo{LINUX, "CoreOS Linux", ver, arch}
    54  }
    55  
    56  func macos(ver string, arch TOSArch) SOsInfo {
    57  	return SOsInfo{MACOS, "Mac OS", ver, arch}
    58  }
    59  
    60  func debian(ver string, arch TOSArch) SOsInfo {
    61  	return SOsInfo{LINUX, "Debian", ver, arch}
    62  }
    63  
    64  func eComStationGuest(ver string, arch TOSArch) SOsInfo {
    65  	return SOsInfo{"", "eComStationGuest", ver, arch}
    66  }
    67  
    68  func fedora(ver string, arch TOSArch) SOsInfo {
    69  	return SOsInfo{LINUX, "Fedora", ver, arch}
    70  }
    71  
    72  func freebsd(arch TOSArch) SOsInfo {
    73  	return SOsInfo{FREEBSD, "FreeBSD", "", arch}
    74  }
    75  
    76  func rhel(ver string, arch TOSArch) SOsInfo {
    77  	return SOsInfo{LINUX, "RedHat Enterprise Linux", ver, arch}
    78  
    79  }
    80  
    81  func suse(ver string, arch TOSArch) SOsInfo {
    82  	return SOsInfo{LINUX, "SuSE", ver, arch}
    83  }
    84  
    85  func opensuse(arch TOSArch) SOsInfo {
    86  	return SOsInfo{LINUX, "OpenSuSE", "?", arch}
    87  
    88  }
    89  
    90  func oracle(ver string, arch TOSArch) SOsInfo {
    91  	return SOsInfo{LINUX, "Oracle", ver, arch}
    92  }
    93  
    94  func linux(ver string, arch TOSArch) SOsInfo {
    95  	return SOsInfo{LINUX, "Generic", ver, arch}
    96  }
    97  
    98  func windows(dist string, arch TOSArch) SOsInfo {
    99  	return SOsInfo{WINDOWS, dist, "", arch}
   100  }
   101  
   102  func solaris(ver string, arch TOSArch) SOsInfo {
   103  	return SOsInfo{SOLARIS, "Solaris", ver, arch}
   104  }
   105  
   106  func turbo(arch TOSArch) SOsInfo {
   107  	return SOsInfo{LINUX, "Turbo Linux", "?", arch}
   108  }
   109  
   110  func ubuntu(arch TOSArch) SOsInfo {
   111  	return SOsInfo{LINUX, "Ubuntu", "?", arch}
   112  }
   113  
   114  func mandriva(arch TOSArch) SOsInfo {
   115  	return SOsInfo{LINUX, "Mandriva", "?", arch}
   116  }
   117  
   118  func mandrake(arch TOSArch) SOsInfo {
   119  	return SOsInfo{LINUX, "Mandrake", "?", arch}
   120  }
   121  
   122  func vmware(ver string) SOsInfo {
   123  	return SOsInfo{VMWARE, "ESX", ver, X86_64}
   124  }
   125  
   126  var (
   127  	GuestOsInfo = map[string]SOsInfo{
   128  		"asianux3_64Guest":        asian("3", X86_64),
   129  		"asianux3Guest":           asian("3", X86),
   130  		"asianux4_64Guest":        asian("4", X86_64),
   131  		"asianux4Guest":           asian("4", X86),
   132  		"asianux5_64Guest":        asian("5", X86_64),
   133  		"asianux7_64Guest":        asian("7", X86_64),
   134  		"centos6_64Guest":         centos("6", X86_64),
   135  		"centos64Guest":           centos4_5(X86_64),
   136  		"centos6Guest":            centos("6", X86),
   137  		"centos7_64Guest":         centos("7", X86_64),
   138  		"centos7Guest":            centos("7", X86),
   139  		"centosGuest":             centos4_5(X86),
   140  		"coreos64Guest":           coreos("", X86_64),
   141  		"darwin10_64Guest":        macos("10.6", X86_64),
   142  		"darwin10Guest":           macos("10.6", X86),
   143  		"darwin11_64Guest":        macos("10.7", X86_64),
   144  		"darwin11Guest":           macos("10.7", X86),
   145  		"darwin12_64Guest":        macos("10.8", X86_64),
   146  		"darwin13_64Guest":        macos("10.9", X86_64),
   147  		"darwin14_64Guest":        macos("10.10", X86_64),
   148  		"darwin15_64Guest":        macos("10.11", X86_64),
   149  		"darwin16_64Guest":        macos("10.12", X86_64),
   150  		"darwin64Guest":           macos("10.5", X86_64),
   151  		"darwinGuest":             macos("10.5", X86),
   152  		"debian10_64Guest":        debian("10", X86_64),
   153  		"debian10Guest":           debian("10", X86),
   154  		"debian4_64Guest":         debian("4", X86_64),
   155  		"debian4Guest":            debian("4", X86),
   156  		"debian5_64Guest":         debian("5", X86_64),
   157  		"debian5Guest":            debian("5", X86),
   158  		"debian6_64Guest":         debian("6", X86_64),
   159  		"debian6Guest":            debian("6", X86),
   160  		"debian7_64Guest":         debian("7", X86_64),
   161  		"debian7Guest":            debian("7", X86),
   162  		"debian8_64Guest":         debian("8", X86_64),
   163  		"debian8Guest":            debian("8", X86),
   164  		"debian9_64Guest":         debian("9", X86_64),
   165  		"debian9Guest":            debian("9", X86),
   166  		"eComStation2Guest":       eComStationGuest("2.0", X86),
   167  		"eComStationGuest":        eComStationGuest("1.x", X86),
   168  		"fedora64Guest":           fedora("?", X86_64),
   169  		"fedoraGuest":             fedora("?", X86),
   170  		"freebsd64Guest":          freebsd(X86_64),
   171  		"freebsdGuest":            freebsd(X86),
   172  		"genericLinuxGuest":       linux("?", X86),
   173  		"mandrakeGuest":           mandrake(X86),
   174  		"mandriva64Guest":         mandriva(X86_64),
   175  		"mandrivaGuest":           mandriva(X86),
   176  		"opensuse64Guest":         opensuse(X86_64),
   177  		"opensuseGuest":           opensuse(X86),
   178  		"oracleLinux6_64Guest":    oracle("6", X86_64),
   179  		"oracleLinux64Guest":      oracle("4/5", X86_64),
   180  		"oracleLinux6Guest":       oracle("6", X86),
   181  		"oracleLinux7_64Guest":    oracle("7", X86_64),
   182  		"oracleLinux7Guest":       oracle("7", X86),
   183  		"oracleLinuxGuest":        oracle("4/5", X86),
   184  		"other24xLinux64Guest":    linux("2.4", X86_64),
   185  		"other24xLinuxGuest":      linux("2.4", X86),
   186  		"other26xLinux64Guest":    linux("2.6", X86_64),
   187  		"other26xLinuxGuest":      linux("2.6", X86),
   188  		"other3xLinux64Guest":     linux("3.x", X86_64),
   189  		"other3xLinuxGuest":       linux("3.x", X86_64),
   190  		"otherLinux64Guest":       linux("2.2", X86_64),
   191  		"otherLinuxGuest":         linux("2.2", X86),
   192  		"redhatGuest":             rhel("2.1", X86),
   193  		"rhel2Guest":              rhel("2", X86),
   194  		"rhel3_64Guest":           rhel("3", X86_64),
   195  		"rhel3Guest":              rhel("3", X86),
   196  		"rhel4_64Guest":           rhel("4", X86_64),
   197  		"rhel4Guest":              rhel("4", X86),
   198  		"rhel5_64Guest":           rhel("5", X86_64),
   199  		"rhel5Guest":              rhel("5", X86),
   200  		"rhel6_64Guest":           rhel("6", X86_64),
   201  		"rhel6Guest":              rhel("6", X86),
   202  		"rhel7_64Guest":           rhel("7", X86_64),
   203  		"rhel7Guest":              rhel("7", X86),
   204  		"sles10_64Guest":          suse("10", X86_64),
   205  		"sles10Guest":             suse("10", X86),
   206  		"sles11_64Guest":          suse("11", X86_64),
   207  		"sles11Guest":             suse("11", X86),
   208  		"sles12_64Guest":          suse("12", X86_64),
   209  		"sles12Guest":             suse("12", X86),
   210  		"sles64Guest":             suse("9", X86_64),
   211  		"slesGuest":               suse("9", X86),
   212  		"solaris10_64Guest":       solaris("10", X86_64),
   213  		"solaris10Guest":          solaris("10", X86),
   214  		"solaris11_64Guest":       solaris("11", X86_64),
   215  		"solaris6Guest":           solaris("6", X86),
   216  		"solaris7Guest":           solaris("7", X86),
   217  		"solaris8Guest":           solaris("8", X86),
   218  		"solaris9Guest":           solaris("9", X86),
   219  		"suse64Guest":             suse("?", X86_64),
   220  		"suseGuest":               suse("?", X86),
   221  		"turboLinux64Guest":       turbo(X86_64),
   222  		"turboLinuxGuest":         turbo(X86),
   223  		"ubuntu64Guest":           ubuntu(X86_64),
   224  		"ubuntuGuest":             ubuntu(X86),
   225  		"vmkernel5Guest":          vmware("5"),
   226  		"vmkernel65Guest":         vmware("6.5"),
   227  		"vmkernel6Guest":          vmware("6"),
   228  		"vmkernelGuest":           vmware("4"),
   229  		"win2000AdvServGuest":     windows("Windows 2000 Advanced Server", X86),
   230  		"win2000ProGuest":         windows("Windows 2000 Professional", X86),
   231  		"win2000ServGuest":        windows("Windows 2000 Server", X86),
   232  		"win31Guest":              windows("Windows 3.1", X86),
   233  		"win95Guest":              windows("Windows 95", X86),
   234  		"win98Guest":              windows("Windows 98", X86),
   235  		"windows7_64Guest":        windows("Windows 7", X86_64),
   236  		"windows7Guest":           windows("Windows 7", X86_64),
   237  		"windows7Server64Guest":   windows("Windows Server 2008 R2", X86_64),
   238  		"windows8_64Guest":        windows("Windows 8", X86_64),
   239  		"windows8Guest":           windows("Windows 8", X86),
   240  		"windows8Server64Guest":   windows("Windows 8 Server", X86_64),
   241  		"windows9_64Guest":        windows("Windows 10", X86_64),
   242  		"windows9Guest":           windows("Windows 10", X86),
   243  		"windows9Server64Guest":   windows("Windows 10 Server", X86_64),
   244  		"windowsHyperVGuest":      windows("Windows Hyper-V", X86_64),
   245  		"winLonghorn64Guest":      windows("Windows Longhorn", X86_64),
   246  		"winLonghornGuest":        windows("Windows Longhorn", X86),
   247  		"winMeGuest":              windows("Windows Millenium Edition", X86),
   248  		"winNetBusinessGuest":     windows("Windows Small Business Server 2003", X86),
   249  		"winNetDatacenter64Guest": windows("Windows Server 2003 Datacenter Edition", X86_64),
   250  		"winNetDatacenterGuest":   windows("Windows Server 2003 Datacenter Edition", X86),
   251  		"winNetEnterprise64Guest": windows("Windows Server 2003 Enterprise Edition", X86_64),
   252  		"winNetEnterpriseGuest":   windows("Windows Server 2003 Enterprise Edition", X86),
   253  		"winNetStandard64Guest":   windows("Windows Server 2003 Standard Edition", X86_64),
   254  		"winNetStandardGuest":     windows("Windows Server 2003 Standard Edition", X86),
   255  		"winNetWebGuest":          windows("Windows Server 2003 Web Edition", X86),
   256  		"winNTGuest":              windows("Windows NT 4", X86),
   257  		"winVista64Guest":         windows("Windows Vista", X86_64),
   258  		"winVistaGuest":           windows("Windows Vista", X86),
   259  		"winXPHomeGuest":          windows("Windows XP Home Edition", X86),
   260  		"winXPPro64Guest":         windows("Windows XP Professional Edition", X86_64),
   261  		"winXPProGuest":           windows("Windows XP Professional", X86),
   262  	}
   263  )