ProductConveter.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. <?php
  2. namespace ModulesGarden\ProxmoxAddon\App\Configuration\Addon\Update;
  3. use ModulesGarden\ProxmoxAddon\App\Models\ProductConfiguration;
  4. class ProductConveter
  5. {
  6. const data = [
  7. "virtualization_type" => [
  8. "newSetting" => "virtualization",
  9. 'newValue' => ["KVM" => "qemu", "LXC" => "lxc"]
  10. ],
  11. "default_node" => [
  12. "newSetting" => "defaultNode",
  13. 'newValue' => ["Server-Node" => "serverNode", "Auto-Node" => "autoNode"]
  14. ],
  15. "console_ip" => [
  16. "newSetting" => "consoleHost",
  17. 'newValue' => []
  18. ],
  19. "lxc_randomHostname" => [
  20. "newSetting" => "randomHostname",
  21. 'newValue' => ["0" => "off", "1" => "on"]
  22. ],
  23. "available_resources" => [
  24. "newSetting" => "checkResources",
  25. 'newValue' => ["0" => "off", "1" => "on"]
  26. ],
  27. "backupVmBeforeRebuild" => [
  28. "newSetting" => "backupVmBeforeReinstall",
  29. 'newValue' => ["0" => "off", "1" => "on"]
  30. ],
  31. "default_node" => [
  32. "newSetting" => "defaultNode",
  33. 'newValue' => ["Server-Node" => "serverNode", "Auto-Node" => "autoNode"]
  34. ],
  35. "user_prefix" => [
  36. "newSetting" => "userPrefix",
  37. 'newValue' => []
  38. ],
  39. "user_comment" => [
  40. "newSetting" => "userComment",
  41. 'newValue' => []
  42. ],
  43. "oneUserPerVps" => [
  44. "newSetting" => "oneUserPerVps",
  45. 'newValue' => ["0" => "off", "1" => "on"]
  46. ],
  47. "domains" => [
  48. "newSetting" => "realm",
  49. 'newValue' => []
  50. ],
  51. "roles" => [
  52. "newSetting" => "userRole",
  53. 'newValue' => []
  54. ],
  55. "welcomeEmailTemplateId" => [
  56. "newSetting" => "welcomeEmailTemplateId",
  57. 'newValue' => []
  58. ],
  59. "rebootVmAfterChangePackage" => [
  60. "newSetting" => "rebootVmAfterChangePackage",
  61. 'newValue' => ["0" => "off", "1" => "on"]
  62. ],
  63. "deleteBackups" => [
  64. "newSetting" => "deleteBackups",
  65. 'newValue' => ["0" => "off", "1" => "on"]
  66. ],
  67. "useServerNameservers" => [
  68. "newSetting" => "serverNameservers",
  69. 'newValue' => ["0" => "off", "1" => "on"]
  70. ],
  71. "lxc_storage" => [
  72. "newSetting" => "storage",
  73. 'newValue' => []
  74. ],
  75. "lxc_arch" => [
  76. "newSetting" => "arch",
  77. 'newValue' => []
  78. ],
  79. "lxc_cmode" => [
  80. "newSetting" => "cmode",
  81. 'newValue' => []
  82. ],
  83. "lxc_console" => [
  84. "newSetting" => "console",
  85. 'newValue' => ["0" => "off", "1" => "on"]
  86. ],
  87. "lxc_ostype" => [
  88. "newSetting" => "ostype",
  89. 'newValue' => []
  90. ],
  91. "lxc_onboot" => [
  92. "newSetting" => "onboot",
  93. 'newValue' => ["0" => "off", "1" => "on"]
  94. ],
  95. "lxc_pool" => [
  96. "newSetting" => "pool",
  97. 'newValue' => []
  98. ],
  99. "lxc_protection" => [
  100. "newSetting" => "protection",
  101. 'newValue' => ["0" => "off", "1" => "on"]
  102. ],
  103. "lxc_description" => [
  104. "newSetting" => "description",
  105. 'newValue' => []
  106. ],
  107. "lxc_startup" => [
  108. "newSetting" => "startup",
  109. 'newValue' => []
  110. ],
  111. "lxc_ostemplates" => [
  112. "newSetting" => "permissionOsTemplates",
  113. 'newValue' => []
  114. ],
  115. "lxc_tty" => [
  116. "newSetting" => "tty",
  117. 'newValue' => []
  118. ],
  119. "lxc_unprivileged" => [
  120. "newSetting" => "unprivileged",
  121. 'newValue' => ["0" => "off", "1" => "on"]
  122. ],
  123. "lxc_sshKeyPairs" => [
  124. "newSetting" => "sshKeyPairs",
  125. 'newValue' => ["0" => "off", "1" => "on"]
  126. ],
  127. "lxc_sshDeletePrivateKey" => [
  128. "newSetting" => "sshDeletePrivateKey",
  129. 'newValue' => ["0" => "off", "1" => "on"]
  130. ],
  131. "lxc_ostemplate" => [
  132. "newSetting" => "osTemplate",
  133. 'newValue' => []
  134. ],
  135. "lxc_cpulimit" => [
  136. "newSetting" => "cpulimit",
  137. 'newValue' => []
  138. ],
  139. "lxc_cores" => [
  140. "newSetting" => "cores",
  141. 'newValue' => []
  142. ],
  143. "lxc_cores" => [
  144. "newSetting" => "cores",
  145. 'newValue' => []
  146. ],
  147. "lxc_swap" => [
  148. "newSetting" => "swap",
  149. 'newValue' => []
  150. ],
  151. "lxc_cpuunits" => [
  152. "newSetting" => "cpuunits",
  153. 'newValue' => []
  154. ],
  155. "lxc_memory" => [
  156. "newSetting" => "memory",
  157. 'newValue' => []
  158. ],
  159. "lxc_disk" => [
  160. "newSetting" => "diskSize",
  161. 'newValue' => []
  162. ],
  163. "lxc_AdditionalDisksSpace" => [
  164. "newSetting" => "additionalDiskSize",
  165. 'newValue' => []
  166. ],
  167. "lxc_ipv4" => [
  168. "newSetting" => "ipv4",
  169. 'newValue' => []
  170. ],
  171. "lxc_ipv6" => [
  172. "newSetting" => "ipv6",
  173. 'newValue' => []
  174. ],
  175. "lxc_snapshots_limit" => [
  176. "newSetting" => "snapshotMaxFiles",
  177. 'newValue' => []
  178. ],
  179. "lxc_backup_limit_gb" => [
  180. "newSetting" => "backupMaxFiles",
  181. 'newValue' => []
  182. ],
  183. "lxc_backup_limit_maxfile" => [
  184. "newSetting" => "backupMaxFiles",
  185. 'newValue' => []
  186. ],
  187. "lxc_bandwidth_limit" => [
  188. "newSetting" => "bandwidth",
  189. 'newValue' => []
  190. ],
  191. "lxc_lan_rate" => [
  192. "newSetting" => "rate",
  193. 'newValue' => []
  194. ],
  195. "lxc_minimum_rate" => [
  196. "newSetting" => "minimumRate",
  197. 'newValue' => []
  198. ],
  199. "lxc_mpStorage" => [
  200. "newSetting" => "mountPointStorage",
  201. 'newValue' => []
  202. ],
  203. "lxc_mpAcl" => [
  204. "newSetting" => "mountPointAcl",
  205. 'newValue' => []
  206. ],
  207. "lxc_mpRo" => [
  208. "newSetting" => "mountPointRo",
  209. 'newValue' => ["0" => "off", "1" => "on"]
  210. ],
  211. "lxc_mpQuota" => [
  212. "newSetting" => "mountPointQuota",
  213. 'newValue' => []
  214. ],
  215. "lxc_mpReplicate" => [
  216. "newSetting" => "mountPointReplicate",
  217. 'newValue' => []
  218. ],
  219. "lxc_ipv4_mode" => [
  220. "newSetting" => "ipv4NetworkMode",
  221. 'newValue' => []
  222. ],
  223. "lxc_ipv6_mode" => [
  224. "newSetting" => "ipv6NetworkMode",
  225. 'newValue' => []
  226. ],
  227. "lxc_bridge" => [
  228. "newSetting" => "bridge",
  229. 'newValue' => []
  230. ],
  231. "lxc_vlantag_from" => [
  232. "newSetting" => "tagFrom",
  233. 'newValue' => []
  234. ],
  235. "lxc_vlantag_to" => [
  236. "newSetting" => "tagTo",
  237. 'newValue' => []
  238. ],
  239. "lxc_private_bridge" => [
  240. "newSetting" => "privateBridge",
  241. 'newValue' => []
  242. ],
  243. "lxc_firewall" => [
  244. "newSetting" => "networkFirewall",
  245. 'newValue' => ["0" => "off", "1" => "on"]
  246. ],
  247. "kvm_ostype" => [
  248. "newSetting" => "ostype",
  249. 'newValue' => []
  250. ],
  251. "kvm_acpi" => [
  252. "newSetting" => "acpi",
  253. 'newValue' => ['Enable' => "on", 'Disable' => "off"]
  254. ],
  255. "kvm_agent" => [
  256. "newSetting" => "agent",
  257. 'newValue' => ['Enable' => "on", 'Disable' => "off"]
  258. ],
  259. "kvm_args" => [
  260. "newSetting" => "args",
  261. 'newValue' => []
  262. ],
  263. "kvm_autostart" => [
  264. "newSetting" => "autostart",
  265. 'newValue' => ['Enable' => "on", 'Disable' => "off"]
  266. ],
  267. "kvm_balloon" => [
  268. "newSetting" => "balloon",
  269. 'newValue' => []
  270. ],
  271. "kvm_shares" => [
  272. "newSetting" => "shares",
  273. 'newValue' => []
  274. ],
  275. "kvm_cdrom" => [
  276. "newSetting" => "cdrom",
  277. 'newValue' => []
  278. ],
  279. "kvm_cpu" => [
  280. "newSetting" => "cpu",
  281. 'newValue' => []
  282. ],
  283. "kvm_numa" => [
  284. "newSetting" => "numa",
  285. 'newValue' => ['1' => "on", '0' => "off"]
  286. ],
  287. "kvm_pcid" => [
  288. "newSetting" => "pcid",
  289. 'newValue' => ['1' => "on", '0' => "off"]
  290. ],
  291. "kvm_spec-ctrl" => [
  292. "newSetting" => "spec-ctrl",
  293. 'newValue' => ['1' => "on", '0' => "off"]
  294. ],
  295. "kvm_description" => [
  296. "newSetting" => "description",
  297. 'newValue' => []
  298. ],
  299. "kvm_freeze" => [
  300. "newSetting" => "freeze",
  301. 'newValue' => ['Enable' => "on", 'Disable' => "off"]
  302. ],
  303. "kvm_hotplug" => [
  304. "newSetting" => "hotplug",
  305. 'newValue' => ['Enable' => "on", 'Disable' => "off"]
  306. ],
  307. "kvm_cdrom" => [
  308. "newSetting" => "cdrom",
  309. 'newValue' => ['Enable' => "on", 'Disable' => "off"]
  310. ],
  311. "kvm_keyboard" => [
  312. "newSetting" => "keyboard",
  313. 'newValue' => []
  314. ],
  315. "kvm_kvm" => [
  316. "newSetting" => "kvm",
  317. 'newValue' => ['Enable' => "on", 'Disable' => "off"]
  318. ],
  319. "kvm_localtime" => [
  320. "newSetting" => "localtime",
  321. 'newValue' => ['Yes' => "on", 'No' => "off"]
  322. ],
  323. "kvm_migrate_downtime" => [
  324. "newSetting" => "migrate_downtime",
  325. 'newValue' => []
  326. ],
  327. "kvm_onboot" => [
  328. "newSetting" => "onboot",
  329. 'newValue' => ['Yes' => "on", 'No' => "off"]
  330. ],
  331. "kvm_pool" => [
  332. "newSetting" => "pool",
  333. 'newValue' => []
  334. ],
  335. "kvm_reboot" => [
  336. "newSetting" => "reboot",
  337. 'newValue' => ['Enable' => "on", 'Disable' => "off"]
  338. ],
  339. "kvm_startdate" => [
  340. "newSetting" => "startdate",
  341. 'newValue' => []
  342. ],
  343. "kvm_startup" => [
  344. "newSetting" => "startup",
  345. 'newValue' => []
  346. ],
  347. "kvm_storage" => [
  348. "newSetting" => "diskStorage",
  349. 'newValue' => []
  350. ],
  351. "kvm_tablet" => [
  352. "newSetting" => "tablet",
  353. 'newValue' => ['Enable' => "on", 'Disable' => "off"]
  354. ],
  355. "kvm_tdf" => [
  356. "newSetting" => "tdf",
  357. 'newValue' => ['Enable' => "on", 'Disable' => "off"]
  358. ],
  359. "kvm_vga" => [
  360. "newSetting" => "vga",
  361. 'newValue' => []
  362. ],
  363. "kvm_watchdog" => [
  364. "newSetting" => "watchdog",
  365. 'newValue' => []
  366. ],
  367. "default_kvm_name" => [
  368. "newSetting" => "containerPrefix",
  369. 'newValue' => []
  370. ],
  371. "kvm_client_name_for_vps" => [
  372. "newSetting" => "clientNameForContainer",
  373. 'newValue' => [0 => 0, 1 => "emptyHostnameOnly", 2 => "overwriteHostname", 3 => "overwriteHostnameWithPrefix"]
  374. ],
  375. "kvm_os_template" => [
  376. "newSetting" => "permissionOsTemplates",
  377. 'newValue' => []
  378. ],
  379. "kvm_templatesInAllNodes" => [
  380. "newSetting" => "osTemplatesInAllNodes",
  381. 'newValue' => ['1' => "on", '0' => "off"]
  382. ],
  383. "kvm_cloneMode" => [
  384. "newSetting" => "cloneMode",
  385. 'newValue' => []
  386. ],
  387. "kvm_vmTemplate" => [
  388. "newSetting" => "osTemplate",
  389. 'newValue' => []
  390. ],
  391. "kvm_sockets" => [
  392. "newSetting" => "sockets",
  393. 'newValue' => []
  394. ],
  395. "kvm_cores" => [
  396. "newSetting" => "cores",
  397. 'newValue' => []
  398. ],
  399. "kvm_vcpus" => [
  400. "newSetting" => "vcpus",
  401. 'newValue' => []
  402. ],
  403. "kvm_cpulimit" => [
  404. "newSetting" => "cpulimit",
  405. 'newValue' => []
  406. ],
  407. "kvm_cpuunits" => [
  408. "newSetting" => "cpuunits",
  409. 'newValue' => []
  410. ],
  411. "kvm_memory" => [
  412. "newSetting" => "memory",
  413. 'newValue' => []
  414. ],
  415. "kvm_disk_space" => [
  416. "newSetting" => "diskSize",
  417. 'newValue' => []
  418. ],
  419. "kvm_AdditionalDisksSpace" => [
  420. "newSetting" => "additionalDiskSize",
  421. 'newValue' => []
  422. ],
  423. "kvm_lan_rate" => [
  424. "newSetting" => "rate",
  425. 'newValue' => []
  426. ],
  427. "kvm_minimum_rate" => [
  428. "newSetting" => "minimumRate",
  429. 'newValue' => []
  430. ],
  431. "kvm_ip_addresses" => [
  432. "newSetting" => "ipv4",
  433. 'newValue' => []
  434. ],
  435. "kvm_ipv6_addresses" => [
  436. "newSetting" => "ipv6",
  437. 'newValue' => []
  438. ],
  439. "kvm_backup_limit_gb" => [
  440. "newSetting" => "backupMaxSize",
  441. 'newValue' => []
  442. ],
  443. "kvm_backup_limit_maxfile" => [
  444. "newSetting" => "backupMaxFiles",
  445. 'newValue' => []
  446. ],
  447. "kvm_bandwidth_limit" => [
  448. "newSetting" => "bandwidth",
  449. 'newValue' => []
  450. ],
  451. "kvm_cdrom_isoimage" => [
  452. "newSetting" => "isoImage",
  453. 'newValue' => []
  454. ],
  455. "kvm_disk_storage" => [
  456. "newSetting" => "diskStorage",
  457. 'newValue' => []
  458. ],
  459. "kvm_disk_type" => [
  460. "newSetting" => "diskType",
  461. 'newValue' => ['IDE' => "ide", 'SATA' => 'sata', 'VIRTIO' => 'virtio', 'SCSI' => 'scsi']
  462. ],
  463. "kvm_disk_format" => [
  464. "newSetting" => "diskFormat",
  465. 'newValue' => []
  466. ],
  467. "kvm_disk_cache" => [
  468. "newSetting" => "diskCache",
  469. 'newValue' => []
  470. ],
  471. "kvm_scsihw" => [
  472. "newSetting" => "scsihw",
  473. 'newValue' => []
  474. ],
  475. "kvm_discard" => [
  476. "newSetting" => "discard",
  477. 'newValue' => ['1' => "on", '0' => "off"]
  478. ],
  479. "kvm_replicate" => [
  480. "newSetting" => "replicate",
  481. 'newValue' => ['1' => "on", '0' => "off"]
  482. ],
  483. "kvm_ioThread" => [
  484. "newSetting" => "ioThread",
  485. 'newValue' => ['1' => "on", '0' => "off"]
  486. ],
  487. "kvm_AdditionalDisksStorage" => [
  488. "newSetting" => "additionalDiskStorage",
  489. 'newValue' => []
  490. ],
  491. "kvm_AdditionalDisksType" => [
  492. "newSetting" => "additionalDiskType",
  493. 'newValue' => ['IDE' => "ide", 'SATA' => 'sata', 'VIRTIO' => 'virtio', 'SCSI' => 'scsi']
  494. ],
  495. "kvm_AdditionalDisksFrmats" => [
  496. "newSetting" => "additionalDiskFormat",
  497. 'newValue' => []
  498. ],
  499. "kvm_AdditionalDiskCache" => [
  500. "newSetting" => "additionalDiskCache",
  501. 'newValue' => []
  502. ],
  503. "kvm_AdditionalDiskReplicate" => [
  504. "newSetting" => "additionalDiskReplicate",
  505. 'newValue' => ['1' => "on", '0' => "off"]
  506. ],
  507. "kvm_AdditionalDiskDiscard" => [
  508. "newSetting" => "additionalDiskDiscard",
  509. 'newValue' => ['1' => "on", '0' => "off"]
  510. ],
  511. "kvm_AdditionalDiskIoThread" => [
  512. "newSetting" => "additionalDiskIoThread",
  513. 'newValue' => ['1' => "on", '0' => "off"]
  514. ],
  515. "kvm_AdditionalDiskAllowBackups" => [
  516. "newSetting" => "permissionAdditionalDiskBackup",
  517. 'newValue' => ['1' => "on", '0' => "off"]
  518. ],
  519. "kvm_DiskReadLimit" => [
  520. "newSetting" => "mbps_rd",
  521. 'newValue' => []
  522. ],
  523. "kvm_DiskWriteLimit" => [
  524. "newSetting" => "mbps_wr",
  525. 'newValue' => []
  526. ],
  527. "kvm_iops_rd" => [
  528. "newSetting" => "iops_rd",
  529. 'newValue' => []
  530. ],
  531. "kvm_iops_rd" => [
  532. "newSetting" => "iops_rd",
  533. 'newValue' => []
  534. ],
  535. "kvm_iops_rd_max" => [
  536. "newSetting" => "iops_rd_max",
  537. 'newValue' => []
  538. ],
  539. "kvm_iops_wr" => [
  540. "newSetting" => "iops_wr",
  541. 'newValue' => []
  542. ],
  543. "kvm_iops_wr_max" => [
  544. "newSetting" => "iops_wr_max",
  545. 'newValue' => []
  546. ],
  547. "kvm_AdditionalDiskReadLimit" => [
  548. "newSetting" => "additionalDiskMbps_rd",
  549. 'newValue' => []
  550. ],
  551. "kvm_AdditionalDiskWriteLimit" => [
  552. "newSetting" => "additionalDiskMbps_wr",
  553. 'newValue' => []
  554. ],
  555. "kvm_AdditionalDiskIops_rd" => [
  556. "newSetting" => "additionalDiskIops_rd",
  557. 'newValue' => []
  558. ],
  559. "kvm_AdditionalDiskIops_rd_max" => [
  560. "newSetting" => "additionalDiskIops_rd_max",
  561. 'newValue' => []
  562. ],
  563. "kvm_AdditionalDiskIops_wr" => [
  564. "newSetting" => "additionalDiskIops_wr",
  565. 'newValue' => []
  566. ],
  567. "kvm_AdditionalDiskIops_wr_max" => [
  568. "newSetting" => "additionalDiskIops_wr_max",
  569. 'newValue' => []
  570. ],
  571. "kvm_cdrom_type" => [
  572. "newSetting" => "cdromType",
  573. 'newValue' => []
  574. ],
  575. "kvm_isoimages" => [
  576. "newSetting" => "permissionIsoImages",
  577. 'newValue' => []
  578. ],
  579. "kvm_lan_bridge" => [
  580. "newSetting" => "bridge",
  581. 'newValue' => []
  582. ],
  583. "kvm_lan_network_model" => [
  584. "newSetting" => "networkModel",
  585. 'newValue' => []
  586. ],
  587. "kvm_disable_additional_nic" => [
  588. "newSetting" => "oneNetworkDevice",
  589. 'newValue' => ['No' => "off", 'Yes' => "on"]
  590. ],
  591. "kvm_vlantag_from" => [
  592. "newSetting" => "tagFrom",
  593. 'newValue' => []
  594. ],
  595. "kvm_vlantag_to" => [
  596. "newSetting" => "tagTo",
  597. 'newValue' => []
  598. ],
  599. "kvm_private_bridge" => [
  600. "newSetting" => "privateBridge",
  601. 'newValue' => []
  602. ],
  603. "kvm_private_lan_network_model" => [
  604. "newSetting" => "networkPrivateModel",
  605. 'newValue' => []
  606. ],
  607. "kvm_network_firewall" => [
  608. "newSetting" => "networkFirewall",
  609. 'newValue' => ['0' => "off", '1' => "on"]
  610. ],
  611. "kvm_queues" => [
  612. "newSetting" => "queues",
  613. 'newValue' => []
  614. ],
  615. "kvm_boot_1" => [
  616. "newSetting" => "bootDevice1",
  617. 'newValue' => ["Hard Disk" => "c", "Network" => "n", "CD-ROM" => "d"]
  618. ],
  619. "kvm_boot_2" => [
  620. "newSetting" => "bootDevice2",
  621. 'newValue' => ["Hard Disk" => "c", "Network" => "n", "CD-ROM" => "d"]
  622. ],
  623. "kvm_boot_3" => [
  624. "newSetting" => "bootDevice3",
  625. 'newValue' => ["Hard Disk" => "c", "Network" => "n", "CD-ROM" => "d"]
  626. ],
  627. "kvm_bootdisk" => [
  628. "newSetting" => "bootdisk",
  629. 'newValue' => ["Hard Disk" => "c", "Network" => "n", "CD-ROM" => "d"]
  630. ],
  631. "backup_storage" => [
  632. "newSetting" => "backupStorage",
  633. 'newValue' => ["Hard Disk" => "c", "Network" => "n", "CD-ROM" => "d"]
  634. ],
  635. "backup_routing" => [
  636. "newSetting" => "backupRouting",
  637. 'newValue' => ['No' => "off", 'Yes' => "on"]
  638. ],
  639. "backup_delete_older_than" => [
  640. "newSetting" => "backupStoreDays",
  641. 'newValue' => []
  642. ],
  643. "firewall_interfaces" => [
  644. "newSetting" => "firewallInterfaces",
  645. 'newValue' => []
  646. ],
  647. "firewall_rules_limit" => [
  648. "newSetting" => "firewallMaxRules",
  649. 'newValue' => []
  650. ],
  651. "kvm_ipset_ip_filter" => [
  652. "newSetting" => "ipsetIpFilter",
  653. 'newValue' => ['0' => "off", '1' => "on"]
  654. ],
  655. "cluster_state" => [
  656. "newSetting" => "clusterState",
  657. 'newValue' => []
  658. ],
  659. "cluster_group" => [
  660. "newSetting" => "clusterGroup",
  661. 'newValue' => []
  662. ],
  663. "cluster_max_restart" => [
  664. "newSetting" => "clusterMaxRestart",
  665. 'newValue' => []
  666. ],
  667. "cluster_max_relocate" => [
  668. "newSetting" => "clusterMaxRelocate",
  669. 'newValue' => []
  670. ],
  671. "serviceCreationFailed" => [
  672. "newSetting" => "serviceCreationFailedTemplateId",
  673. 'newValue' => []
  674. ],
  675. "toDoList" => [
  676. "newSetting" => "toDoList",
  677. 'newValue' => ['0' => "off", '1' => "on"]
  678. ],
  679. "upgradeNotification" => [
  680. "newSetting" => "upgradeNotificationTemplateId",
  681. 'newValue' => []
  682. ],
  683. "kvm_cloudInit" => [
  684. "newSetting" => "cloudInit",
  685. 'newValue' => ['0' => "off", '1' => "on"]
  686. ],
  687. "kvm_cloudInitServiceUserName" => [
  688. "newSetting" => "cloudInitServiceUsername",
  689. 'newValue' => ['0' => "off", '1' => "on"]
  690. ],
  691. "kvm_cloudInitServicePassword" => [
  692. "newSetting" => "cloudInitServicePassword",
  693. 'newValue' => ['0' => "off", '1' => "on"]
  694. ],
  695. "'kvm_cloudInitServiceNameservers" => [
  696. "newSetting" => "cloudInitServiceNameservers",
  697. 'newValue' => ['0' => "off", '1' => "on"]
  698. ],
  699. "kvm_searchdomain" => [
  700. "newSetting" => "searchdomain",
  701. 'newValue' => []
  702. ],
  703. "kvm_ciuser" => [
  704. "newSetting" => "ciuser",
  705. 'newValue' => []
  706. ],
  707. "loadBalancer" => [
  708. "newSetting" => "loadBalancer",
  709. 'newValue' => ['0' => "off", '1' => "on"]
  710. ],
  711. "loadBalancerOnUpgrade" => [
  712. "newSetting" => "loadBalancerOnUpgrade",
  713. 'newValue' => ['0' => "off", '1' => "on"]
  714. ],
  715. "loadBalancerShutdownOnUpgrade" => [
  716. "newSetting" => "loadBalancerShutdownOnUpgrade",
  717. 'newValue' => ['0' => "off", '1' => "on"]
  718. ],
  719. "loadBalancerStopOnUpgrade" => [
  720. "newSetting" => "loadBalancerStopOnUpgrade",
  721. 'newValue' => ['0' => "off", '1' => "on"]
  722. ],
  723. "per_boot" => [
  724. "newSetting" => "permissionStart",
  725. 'newValue' => ['No' => "off", 'Yes' => "on"]
  726. ],
  727. "per_reboot" => [
  728. "newSetting" => "permissionReboot",
  729. 'newValue' => ['No' => "off", 'Yes' => "on"]
  730. ],
  731. "per_stop" => [
  732. "newSetting" => "permissionStop",
  733. 'newValue' => ['No' => "off", 'Yes' => "on"]
  734. ],
  735. "per_shutdown" => [
  736. "newSetting" => "permissionShutdown",
  737. 'newValue' => ['No' => "off", 'Yes' => "on"]
  738. ],
  739. "per_novnc_console" => [
  740. "newSetting" => "permissionNovnc",
  741. 'newValue' => ['0' => "off", '1' => "on"]
  742. ],
  743. "per_spice_console" => [
  744. "newSetting" => "permissionSpice",
  745. 'newValue' => ['No' => "off", 'Yes' => "on"]
  746. ],
  747. "xtermjsConsole" => [
  748. "newSetting" => "permissionXtermjs",
  749. 'newValue' => ['0' => "off", '1' => "on"]
  750. ],
  751. "per_reinstallation" => [
  752. "newSetting" => "permissionReinstall",
  753. 'newValue' => ['No' => "off", 'Yes' => "on"]
  754. ],
  755. "kvm_per_kvm_templates" => [
  756. "newSetting" => "permissionOsTemplate",
  757. 'newValue' => ['0' => "off", '1' => "on"]
  758. ],
  759. "kvm_per_iso_images" => [
  760. "newSetting" => "permissionIsoImage",
  761. 'newValue' => ['0' => "off", '1' => "on"]
  762. ],
  763. "kvm_snapshots_limit" => [
  764. "newSetting" => "snapshotMaxFiles",
  765. 'newValue' => []
  766. ],
  767. "per_mrtg_graphics" => [
  768. "newSetting" => "permissionGraph",
  769. 'newValue' => ['No' => "off", 'Yes' => "on"]
  770. ],
  771. "backup_list" => [
  772. "newSetting" => "permissionBackup",
  773. 'newValue' => ['No' => "off", 'Yes' => "on"]
  774. ],
  775. "backup_jobs" => [
  776. "newSetting" => "permissionBackupJob",
  777. 'newValue' => ['No' => "off", 'Yes' => "on"]
  778. ],
  779. "per_task_history" => [
  780. "newSetting" => "permissionTaskHistory",
  781. 'newValue' => ['No' => "off", 'Yes' => "on"]
  782. ],
  783. "per_network" => [
  784. "newSetting" => "permissionNetwork",
  785. 'newValue' => ['No' => "off", 'Yes' => "on"]
  786. ],
  787. "per_snapshots" => [
  788. "newSetting" => "permissionSnapshot",
  789. 'newValue' => ['No' => "off", 'Yes' => "on"]
  790. ],
  791. "per_firewall" => [
  792. "newSetting" => "permissionFirewall",
  793. 'newValue' => ['No' => "off", 'Yes' => "on"]
  794. ],
  795. "per_firewallOptions" => [
  796. "newSetting" => "permissionFirewall",
  797. 'newValue' => ['0' => "off", '1' => "on"]
  798. ],
  799. "per_DisksManagement" => [
  800. "newSetting" => "permissionDisk",
  801. 'newValue' => ['0' => "off", '1' => "on"]
  802. ],
  803. "memory_unit" => [
  804. "newSetting" => "memoryUnit",
  805. 'newValue' => []
  806. ],
  807. "swap_unit" => [
  808. "newSetting" => "swapUnit",
  809. 'newValue' => []
  810. ],
  811. "disk_unit" => [
  812. "newSetting" => "diskUnit",
  813. 'newValue' => []
  814. ],
  815. "adisk_unit" => [
  816. "newSetting" => "additionalDiskUnit",
  817. 'newValue' => []
  818. ],
  819. ];
  820. /**
  821. * @param $key
  822. * @param $value
  823. * @param $productId
  824. * @return ProductConfiguration|null
  825. */
  826. public function convert($key, $value, $productId)
  827. {
  828. if (!self::data[$key] && !self::data[$key]['newSetting'])
  829. {
  830. return null;
  831. }
  832. $setting = new ProductConfiguration();
  833. $setting->setting = self::data[$key]['newSetting'];
  834. if (preg_match("/\[\"/", $value))
  835. {
  836. $value = \json_decode($value, true);
  837. }
  838. $isset = !empty(self::data[$key]['newValue'][$value]);
  839. if ($isset && !is_array($value))
  840. {
  841. $setting->value = self::data[$key]['newValue'][$value];
  842. }else if(is_array($value) && $isset){
  843. $newValue=[];
  844. foreach($value as &$v){
  845. $oldValue = $v;
  846. if(!empty(self::data[$key]['newValue'][$oldValue])){
  847. $newValue[]=self::data[$key]['newValue'][$oldValue];
  848. }
  849. }
  850. $setting->value = $newValue;
  851. }
  852. else
  853. {
  854. $setting->value = $value;
  855. }
  856. $setting->product_id = $productId;
  857. return $setting;
  858. }
  859. public function exist(ProductConfiguration $setting)
  860. {
  861. return ProductConfiguration::ofProductId($setting->product_id)->ofSetting($setting->setting)->count();
  862. }
  863. }