CloudInitDrive.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace MGProvision\Proxmox\v2\models;
  3. class CloudInitDrive extends AbstractObject {
  4. protected $path;
  5. protected $storage;
  6. protected $location;
  7. public function __construct($id, $config=null) {
  8. $this->id = $id;
  9. if ($config) {
  10. $config = self::asArray($config);
  11. $this->location = key($config);
  12. $ex = explode(":", $this->location );
  13. $config['storage'] = $ex[0];
  14. $this->setAttributes($config);
  15. }
  16. }
  17. /**
  18. * @return mixed
  19. */
  20. public function getPath()
  21. {
  22. return $this->path;
  23. }
  24. /**
  25. * @param mixed $path
  26. */
  27. public function setPath($path)
  28. {
  29. $this->path = $path;
  30. }
  31. /**
  32. * @return mixed
  33. */
  34. public function getStorage()
  35. {
  36. return $this->storage;
  37. }
  38. /**
  39. * @param mixed $storage
  40. */
  41. public function setStorage($storage)
  42. {
  43. $this->storage = $storage;
  44. }
  45. /**
  46. * @return mixed
  47. */
  48. public function getMedia()
  49. {
  50. return $this->media;
  51. }
  52. /**
  53. * @param mixed $media
  54. */
  55. public function setMedia($media)
  56. {
  57. $this->media = $media;
  58. }
  59. public function unmount(){
  60. return $this->api()->put($this->getPath(),[$this->id => 'none,media=cdrom' ]);
  61. }
  62. public function mount(){
  63. return $this->api()->put($this->getPath(),[$this->id => "{$this->storage}:cloudinit,format=raw" ]);
  64. }
  65. }