@@ -13,7 +13,7 @@ protected function getEndpoint()
1313
1414 public function all ($ pool )
1515 {
16- return $ this ->get ($ this ->getEndpoint (). $ pool. '/volumes ' );
16+ return $ this ->get ($ this ->getEndpoint () . $ pool . '/volumes ' );
1717 }
1818
1919 /**
@@ -22,10 +22,10 @@ public function all($pool)
2222 public function info (string $ pool , string $ path )
2323 {
2424 $ config = [
25- "project " => $ this ->client ->getProject ()
25+ "project " => $ this ->client ->getProject ()
2626 ];
2727
28- return $ this ->get ($ this ->getEndpoint (). $ pool. '/volumes/ ' . $ path , $ config );
28+ return $ this ->get ($ this ->getEndpoint () . $ pool . '/volumes/ ' . $ path , $ config );
2929 }
3030
3131 public function create (string $ pool , string $ name , array $ config )
@@ -34,18 +34,36 @@ public function create(string $pool, string $name, array $config)
3434 $ opts ["config " ] = $ config ;
3535
3636 $ httpConfig = [
37- "project " => $ this ->client ->getProject ()
37+ "project " => $ this ->client ->getProject ()
3838 ];
3939
40- return $ this ->post ($ this ->getEndpoint ().$ pool .'/volumes/custom ' , $ opts , $ httpConfig );
40+ return $ this ->post ($ this ->getEndpoint () . $ pool . '/volumes/custom ' , $ opts , $ httpConfig );
41+ }
42+
43+ public function createCustomVolumeFromFile (string $ pool , string $ name , $ fileContents , string $ type = "iso " , bool $ wait = false )
44+ {
45+ $ headers = [
46+ "Content-Type " => "application/octet-stream " ,
47+ "X-LXD-name " => $ name ,
48+ "X-LXD-type " => $ type
49+ ];
50+ $ queryParams = ["project " => $ this ->client ->getProject ()];
51+
52+ $ response = $ this ->post ($ this ->getEndpoint () . $ pool . '/volumes/custom ' , $ fileContents , $ queryParams , $ headers );
53+
54+ if ($ wait ) {
55+ $ response = $ this ->client ->operations ->wait ($ response ['id ' ]);
56+ }
57+
58+ return $ response ;
4159 }
4260
4361 public function remove (string $ pool , string $ name )
4462 {
4563 $ httpConfig = [
46- "project " => $ this ->client ->getProject ()
64+ "project " => $ this ->client ->getProject ()
4765 ];
4866
49- return $ this ->delete ($ this ->getEndpoint (). $ pool . '/volumes/ ' . $ name , [], $ httpConfig );
67+ return $ this ->delete ($ this ->getEndpoint () . $ pool . '/volumes/ ' . $ name , [], $ httpConfig );
5068 }
5169}
0 commit comments