1// Copyright 2016-2020 The Libsacloud Authors 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 ostype is define OS type of SakuraCloud public archive 16package ostype 17 18//go:generate stringer -type=ArchiveOSTypes 19 20// ArchiveOSTypes パブリックアーカイブOS種別 21type ArchiveOSTypes int 22 23const ( 24 // CentOS OS種別:CentOS 25 CentOS ArchiveOSTypes = iota 26 // CentOS8 OS種別:CentOS8 27 CentOS8 28 // CentOS7 OS種別:CentOS7 29 CentOS7 30 // CentOS6 OS種別:CentOS6 31 CentOS6 32 // Ubuntu OS種別:Ubuntu 33 Ubuntu 34 // Ubuntu1804 OS種別:Ubuntu(Bionic) 35 Ubuntu1804 36 // Ubuntu1604 OS種別:Ubuntu(Xenial) 37 Ubuntu1604 38 // Debian OS種別:Debian 39 Debian 40 // Debian10 OS種別:Debian10 41 Debian10 42 // Debian9 OS種別:Debian9 43 Debian9 44 // CoreOS OS種別:CoreOS 45 CoreOS 46 // RancherOS OS種別:RancherOS 47 RancherOS 48 // K3OS OS種別: k3OS 49 K3OS 50 // Kusanagi OS種別:Kusanagi(CentOS) 51 Kusanagi 52 // SophosUTM OS種別:Sophos UTM 53 SophosUTM 54 // FreeBSD OS種別:FreeBSD 55 FreeBSD 56 // Netwiser OS種別: Netwiser Virtual Edition 57 Netwiser 58 // OPNsense OS種別: OPNsense 59 OPNsense 60 // Windows2016 OS種別:Windows Server 2016 Datacenter Edition 61 Windows2016 62 // Windows2016RDS OS種別:Windows Server 2016 RDS 63 Windows2016RDS 64 // Windows2016RDSOffice OS種別:Windows Server 2016 RDS(Office) 65 Windows2016RDSOffice 66 // Windows2016SQLServerWeb OS種別:Windows Server 2016 SQLServer(Web) 67 Windows2016SQLServerWeb 68 // Windows2016SQLServerStandard OS種別:Windows Server 2016 SQLServer 2016(Standard) 69 Windows2016SQLServerStandard 70 // Windows2016SQLServer2017Standard OS種別:Windows Server 2016 SQLServer 2017(Standard) 71 Windows2016SQLServer2017Standard 72 // Windows2016SQLServerStandardAll OS種別:Windows Server 2016 SQLServer(Standard) + RDS + Office 73 Windows2016SQLServerStandardAll 74 // Windows2016SQLServer2017StandardAll OS種別:Windows Server 2016 SQLServer 2017(Standard) + RDS + Office 75 Windows2016SQLServer2017StandardAll 76 // Windows2019 OS種別:Windows Server 2019 Datacenter Edition 77 Windows2019 78 // Custom OS種別:カスタム 79 Custom 80) 81 82// OSTypeShortNames OSTypeとして利用できる文字列のリスト 83var OSTypeShortNames = []string{ 84 "centos", "centos8", "centos7", "centos6", 85 "ubuntu", "ubuntu1804", "ubuntu1604", 86 "debian", "debian10", "debian9", 87 "coreos", "rancheros", "k3os", "kusanagi", "sophos-utm", "freebsd", 88 "netwiser", "opnsense", 89 "windows2016", "windows2016-rds", "windows2016-rds-office", 90 "windows2016-sql-web", "windows2016-sql-standard", "windows2016-sql-standard-all", 91 "windows2016-sql2017-standard", "windows2016-sql2017-standard-all", 92 "windows2019", 93} 94 95// IsWindows Windowsか 96func (o ArchiveOSTypes) IsWindows() bool { 97 switch o { 98 case Windows2016, Windows2016RDS, Windows2016RDSOffice, 99 Windows2016SQLServerWeb, Windows2016SQLServerStandard, Windows2016SQLServerStandardAll, 100 Windows2016SQLServer2017Standard, Windows2016SQLServer2017StandardAll, 101 Windows2019: 102 return true 103 default: 104 return false 105 } 106} 107 108// IsSupportDiskEdit ディスクの修正機能をフルサポートしているか(Windowsは一部サポートのためfalseを返す) 109func (o ArchiveOSTypes) IsSupportDiskEdit() bool { 110 switch o { 111 case CentOS, CentOS8, CentOS7, CentOS6, 112 Ubuntu, Ubuntu1804, Ubuntu1604, 113 Debian, Debian10, Debian9, 114 CoreOS, RancherOS, K3OS, Kusanagi, FreeBSD: 115 return true 116 default: 117 return false 118 } 119} 120 121// StrToOSType 文字列からArchiveOSTypesへの変換 122func StrToOSType(osType string) ArchiveOSTypes { 123 switch osType { 124 case "centos": 125 return CentOS 126 case "centos8": 127 return CentOS8 128 case "centos7": 129 return CentOS7 130 case "centos6": 131 return CentOS6 132 case "ubuntu": 133 return Ubuntu 134 case "ubuntu1804": 135 return Ubuntu1804 136 case "ubuntu1604": 137 return Ubuntu1604 138 case "debian": 139 return Debian 140 case "debian10": 141 return Debian10 142 case "debian9": 143 return Debian9 144 case "coreos": 145 return CoreOS 146 case "rancheros": 147 return RancherOS 148 case "k3os": 149 return K3OS 150 case "kusanagi": 151 return Kusanagi 152 case "sophos-utm": 153 return SophosUTM 154 case "freebsd": 155 return FreeBSD 156 case "netwiser": 157 return Netwiser 158 case "opnsense": 159 return OPNsense 160 case "windows2016": 161 return Windows2016 162 case "windows2016-rds": 163 return Windows2016RDS 164 case "windows2016-rds-office": 165 return Windows2016RDSOffice 166 case "windows2016-sql-web": 167 return Windows2016SQLServerWeb 168 case "windows2016-sql-standard": 169 return Windows2016SQLServerStandard 170 case "windows2016-sql2017-standard": 171 return Windows2016SQLServer2017Standard 172 case "windows2016-sql-standard-all": 173 return Windows2016SQLServerStandardAll 174 case "windows2016-sql2017-standard-all": 175 return Windows2016SQLServer2017StandardAll 176 case "windows2019": 177 return Windows2019 178 default: 179 return Custom 180 } 181} 182