| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- namespace MGProvision\Proxmox\v2\models;
- class CdRom extends AbstractObject {
- protected $id;
- protected $storage;
- protected $isoFile;
- protected $path;
- protected $media;
- protected $location;
- public function __construct($id, $config=null) {
- $this->id = $id;
- if ($config) {
- $config = self::asArray($config);
- $this->location = key($config);
- $ex = explode(":", $this->location );
- $config['storage'] = $ex[0];
- $config['isoFile'] = $ex[1];
- $this->setAttributes($config);
- }
- }
- /**
- * @return mixed
- */
- public function getPath()
- {
- return $this->path;
- }
- /**
- * @param mixed $path
- */
- public function setPath($path)
- {
- $this->path = $path;
- }
- /**
- * @return mixed
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param mixed $id
- */
- public function setId($id)
- {
- $this->id = $id;
- }
- /**
- * @return mixed
- */
- public function getStorage()
- {
- return $this->storage;
- }
- /**
- * @param mixed $storage
- */
- public function setStorage($storage)
- {
- $this->storage = $storage;
- }
- /**
- * @return mixed
- */
- public function getIsoFile()
- {
- return $this->isoFile;
- }
- /**
- * @param mixed $isoFile
- */
- public function setIsoFile($isoFile)
- {
- $this->isoFile = $isoFile;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getMedia()
- {
- return $this->media;
- }
- /**
- * @param mixed $media
- */
- public function setMedia($media)
- {
- $this->media = $media;
- }
- /**
- * @return int|string|null
- */
- public function getLocation()
- {
- return $this->location;
- }
- /**
- * @param int|string|null $location
- */
- public function setLocation($location)
- {
- $this->location = $location;
- if(preg_match("/\:/", $location)){
- $ex = explode(":", $this->location );
- $this->setStorage($ex[0]);
- $this->setIsoFile($ex[1]);
- }
- $this->location = $location;
- return $this;
- }
- public function asConfig(){
- $filable=['media'];
- $config = [];
- $config[]= $this->getLocation();
- $this->toConfig($filable, $config);
- return implode(",", $config);
- }
- public function update(){
- return $this->api()->put($this->getPath(), [$this->getId()=> $this->asConfig()]);
- }
- }
|