ClusterResource.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxVPS product developed. (2017-06-07)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. * ******************************************************************** */
  19. namespace MGProvision\Proxmox\v2\models;
  20. /**
  21. * Description of ClusterResource
  22. *
  23. * @author Pawel Kopec <pawelk@modulesgarden.com>
  24. * @version 1.0.0
  25. */
  26. class ClusterResource extends AbstractObject
  27. {
  28. protected $name;
  29. protected $vmid;
  30. protected $node;
  31. protected $template;
  32. protected $type;
  33. protected $status;
  34. public function getName()
  35. {
  36. return $this->name;
  37. }
  38. public function isCustom(){
  39. return preg_match('/^custom[0-9]*/',$this->getName());
  40. }
  41. public function matchName($serviceid){
  42. return preg_match('/^custom'.$serviceid.'-*/',$this->getName());
  43. }
  44. public function getVmid()
  45. {
  46. return $this->vmid;
  47. }
  48. public function getNode()
  49. {
  50. return $this->node;
  51. }
  52. public function getTemplate()
  53. {
  54. return $this->template;
  55. }
  56. public function setName($name)
  57. {
  58. $this->name = $name;
  59. return $this;
  60. }
  61. public function setVmid($vmid)
  62. {
  63. $this->vmid = $vmid;
  64. return $this;
  65. }
  66. public function setNode($node)
  67. {
  68. $this->node = $node;
  69. return $this;
  70. }
  71. public function setTemplate($template)
  72. {
  73. $this->template = $template;
  74. return $this;
  75. }
  76. public function getType()
  77. {
  78. return $this->type;
  79. }
  80. public function setType($type)
  81. {
  82. $this->type = $type;
  83. return $this;
  84. }
  85. public function getStatus()
  86. {
  87. return $this->status;
  88. }
  89. public function setStatus($status)
  90. {
  91. $this->status = $status;
  92. return $this;
  93. }
  94. public function getVm()
  95. {
  96. switch ($this->type)
  97. {
  98. case 'qemu' :
  99. return new Kvm($this->node, $this->vmid);
  100. break;
  101. case 'lxc':
  102. return new Lxc($this->node, $this->vmid);
  103. break;
  104. default :
  105. throw new \Exception(sprintf("Unkown virtualization %s type", $this->type));
  106. }
  107. }
  108. }