la premiere version de la classe netork
This commit is contained in:
parent
5665d317db
commit
154d49d108
1 changed files with 103 additions and 1 deletions
|
@ -1 +1,103 @@
|
|||
|
||||
<?php
|
||||
|
||||
class network{
|
||||
|
||||
protected $app;
|
||||
|
||||
protected $libClass;
|
||||
|
||||
protected $networking;
|
||||
|
||||
protected $actions = array();
|
||||
|
||||
|
||||
/**
|
||||
* Image constructor
|
||||
*
|
||||
* @param App $app the main app object
|
||||
*
|
||||
* @throws [Type] [<description>]
|
||||
*
|
||||
* @return Image
|
||||
*/
|
||||
public function __construct($app, $openstack){
|
||||
$this->app = $app;
|
||||
$this->libClass = $app->getLibClass("networkingV2");
|
||||
$this->networking = $openstack->networkingV2(["region"=>"RegionOne"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function create_network(array $options)
|
||||
{
|
||||
|
||||
$network = $networking->createNetworks($options);
|
||||
|
||||
|
||||
return $network;
|
||||
}
|
||||
|
||||
public function create_subnet(array $options)
|
||||
{
|
||||
|
||||
$subnet = $networking->createSubnet($options);
|
||||
|
||||
|
||||
return $subnet;
|
||||
}
|
||||
|
||||
public function list_network_ids()
|
||||
{
|
||||
|
||||
$ln = $networking->listNetworks();
|
||||
|
||||
$list_ids = array();
|
||||
|
||||
|
||||
foreach($ln as $n)
|
||||
{
|
||||
|
||||
$list_ids[] = $n->id;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $list_ids;
|
||||
}
|
||||
|
||||
public function list_network_names()
|
||||
{
|
||||
|
||||
$ln = $networking->listNetworks();
|
||||
|
||||
$list_names = array();
|
||||
|
||||
|
||||
foreach($ln as $n)
|
||||
{
|
||||
|
||||
$list_names[] = $n->name;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $list_names;
|
||||
}
|
||||
|
||||
public function list_cidr()
|
||||
{
|
||||
|
||||
$ls = $networking->listSubnets();
|
||||
$list_cidr = array();
|
||||
foreach ($ls as $subnet)
|
||||
{
|
||||
|
||||
$list_cidr[] = $subnet->cidr;
|
||||
}
|
||||
|
||||
return $list_names;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue