Skip to content

Pull down latest upstream master and re-fork #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
aaa36ba
add suspend/resume methods
Aug 30, 2017
dd815f7
add tests
Aug 30, 2017
42cb570
add sample files for integration tests
Aug 30, 2017
929fead
Stubbing out net IP availability integration
clwells Aug 31, 2017
36941ca
Stubbing out volume ops
clwells Sep 3, 2017
d5784f6
Adding in the shelving functions
clwells Sep 5, 2017
eee161d
Merge pull request #14 from casmit/suspend-resume-server
clwells Sep 5, 2017
f0f37ee
Merge remote-tracking branch 'origin/master' into net-ip-availability
clwells Sep 5, 2017
cd9748c
Merge remote-tracking branch 'origin/volume-extend' into net-ip-avail…
clwells Sep 5, 2017
601bdac
Adding in vol functions for extend
clwells Sep 5, 2017
b2d95e1
console log integration
clwells Sep 6, 2017
7eb5d79
Finishing up net-ip-availabilities
clwells Sep 6, 2017
21462e4
Removing marker
clwells Sep 6, 2017
0a294da
Adding lock/unlock
clwells Sep 7, 2017
3253876
Adding in reset status
clwells Sep 7, 2017
1005aa9
Adding in Storage ENUMs
clwells Sep 7, 2017
a9fad9e
Adding in instance actions
clwells Sep 9, 2017
4811397
Fixing CS
clwells Sep 9, 2017
454a6b4
Merge remote-tracking branch 'upstream/master' into net-ip-availability
clwells Sep 28, 2017
05a50d7
Merge remote-tracking branch 'upstream/master'
clwells Oct 6, 2017
c87880a
Merge remote-tracking branch 'upstream/master'
clwells Dec 17, 2017
ab8ae02
adding in host aggregates
clwells Dec 17, 2017
96d2f5d
Merge pull request #15 from laszlof/add-server-resetstate
clwells Feb 21, 2018
510bc33
Remove duplicate methods
laszlof Feb 21, 2018
8c12310
Merge pull request #16 from laszlof/fix-it
clwells Feb 21, 2018
f0948b3
Removed return type for two methods in AbstractResource
mrwogu Dec 19, 2017
689cb05
Merge remote-tracking branch 'upstream/master' into merge-latest
laszlof Mar 12, 2019
2ca24e7
Merge remote-tracking branch 'nexcess/master' into merge-latest
laszlof Mar 12, 2019
7ba159a
fix
laszlof Mar 12, 2019
0c32cb9
Merge pull request #18 from laszlof/merge-latest
clwells Mar 13, 2019
1a1fa47
Merge pull request #17 from laszlof/remove-return-type-hint
clwells Mar 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions samples/compute/v2/servers/resume_server.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
'authUrl' => '{authUrl}',
'region' => '{region}',
'user' => [
'id' => '{userId}',
'password' => '{password}'
],
'scope' => ['project' => ['id' => '{projectId}']]
]);

$compute = $openstack->computeV2(['region' => '{region}']);

$server = $compute->getServer([
'id' => '{serverId}',
]);

$server->resume();
21 changes: 21 additions & 0 deletions samples/compute/v2/servers/suspend_server.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
'authUrl' => '{authUrl}',
'region' => '{region}',
'user' => [
'id' => '{userId}',
'password' => '{password}'
],
'scope' => ['project' => ['id' => '{projectId}']]
]);

$compute = $openstack->computeV2(['region' => '{region}']);

$server = $compute->getServer([
'id' => '{serverId}',
]);

$server->suspend();
33 changes: 33 additions & 0 deletions src/BlockStorage/Enum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php declare(strict_types=1);

namespace OpenStack\BlockStorage\v2;

/**
* Represents common constants.
*
* @package OpenStack\BlockStorage\v2
*/
abstract class Enum
{
const STATUS_AVAILABLE = 'available';
const STATUS_CREATING = 'creating';
const STATUS_RESERVED = 'reserved';
const STATUS_ATTACHING = 'attaching';
const STATUS_DETACHING = 'detaching';
const STATUS_IN_USE = 'in-use';
const STATUS_MAINTENANCE = 'maintenance';
const STATUS_DELETING = 'deleting';
const STATUS_AWAITING_TRANSFER = 'awaiting-transfer';
const STATUS_ERROR = 'error';
const STATUS_ERROR_DELETING = 'error_deleting';
const STATUS_BACKING_UP = 'backing-up';
const STATUS_ERROR_BACKING_UP = 'error_backing-up';
const STATUS_ERROR_RESTORING = 'error_restoring';
const STATUS_DOWNLOADING = 'downloading';
const STATUS_UPLOADING = 'uploading';
const STATUS_RETYPINGi = 'retyping';
const STATUS_EXTENDING = 'extending';

const ATTACH_STATUS_ATTACHED = 'attached';
const ATTACH_STATUS_DETACHED = 'detached';
}
26 changes: 26 additions & 0 deletions src/BlockStorage/v2/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,30 @@ public function postResetStatus(): array
],
];
}

public function extendVolume(): array
{
return [
'method' => 'POST',
'path' => 'volumes/{id}/action',
'jsonKey' => 'os-extend',
'params' => [
'id' => $this->params->idPath(),
'new_size' => $this->params->size(),
],
];
}

public function resetVolumeStatus(): array
{
return [
'method' => 'POST',
'path' => 'volumes/{id}/action',
'jsonKey' => 'os-reset_status',
'params' => [
'id' => $this->params->idPath(),
'status' => $this->params->status()
],
];
}
}
9 changes: 9 additions & 0 deletions src/BlockStorage/v2/Models/Volume.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ public function parseMetadata(ResponseInterface $response): array
return isset($json['metadata']) ? $json['metadata'] : [];
}

public function extend(int $size_in_gb)
{
$response = $this->execute($this->api->extendVolume(), [
'id' => $this->id,
'new_size' => $size_in_gb
]);
$this->populateFromResponse($response);
}

/**
* Update the bootable status for a volume, mark it as a bootable volume.
*
Expand Down
19 changes: 19 additions & 0 deletions src/BlockStorage/v2/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,25 @@ public function quotaSetVolumesIscsi(): array
return $this->quotaSetLimit('volumes_iscsi', 'The number of allowed volumes iscsi');
}

public function nullAction(): array
{
return [
'type' => self::NULL_TYPE,
'location' => self::JSON,
'required' => true
];
}

public function status(): array
{
return [
'type' => self::STRING_TYPE,
'location' => self::JSON,
'required' => true,
'description' => 'The new status of the volume',
];
}

public function projectId(): array
{
return [
Expand Down
143 changes: 143 additions & 0 deletions src/Compute/v2/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,90 @@ public function stopServer(): array
];
}

public function resumeServer() : array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
'id' => $this->params->urlId('server'),
'resume' => $this->params->nullAction()
],
];
}

public function suspendServer() : array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
'id' => $this->params->urlId('server'),
'suspend' => $this->params->nullAction()
],
];
}

public function shelveServer() : array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
'id' => $this->params->urlId('server'),
'shelve' => $this->params->nullAction(),
],
];
}

public function shelveOffloadServer() : array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
'id' => $this->params->urlId('server'),
'shelveOffload' => $this->params->nullAction()
],
];
}

public function unshelveServer() : array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
'id' => $this->params->urlId('server'),
'unshelve' => $this->params->nullAction()
],
];
}

public function lockServer() : array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
'id' => $this->params->urlId('server'),
'lock' => $this->params->nullAction()
],
];
}

public function unlockServer() : array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
'id' => $this->params->urlId('server'),
'unlock' => $this->params->nullAction()
],
];
}

public function rebuildServer(): array
{
return [
Expand Down Expand Up @@ -505,6 +589,19 @@ public function getRDPConsole(): array
];
}

public function getConsoleLog(): array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'jsonKey' => 'os-getConsoleOutput',
'params' => [
'id' => $this->params->urlId('server'),
'length' => $this->params->consoleLogLength()
]
];
}

public function getAddresses(): array
{
return [
Expand Down Expand Up @@ -889,4 +986,50 @@ public function putQuotaSet(): array
],
];
}

public function getInstanceActions(): array
{
return [
'method' => 'GET',
'path' => 'servers/{id}/os-instance-actions',
'params' => [
'id' => $this->params->urlId('server')
]
];
}

public function getInstanceAction(): array
{
return [
'method' => 'GET',
'path' => 'servers/{id}/os-instance-actions/{requestId}',
'params' => [
'id' => $this->params->urlId('server'),
'requestId' => $this->params->urlId('request')
]
];
}

public function getAggregates(): array
{
return [
'method' => 'GET',
'path' => 'os-aggregates',
'jsonKey' => 'aggregates',
'params' => [
'limit' => $this->params->limit(),
'marker' => $this->params->marker()
],
];
}

public function getAggregate(): array
{
return [
'method' => 'GET',
'path' => 'os-aggregates/{id}',
'params' => ['id' => $this->params->urlId('id')]
];
}

}
64 changes: 64 additions & 0 deletions src/Compute/v2/Models/Aggregate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php declare(strict_types=1);

namespace OpenStack\Compute\v2\Models;

use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Resource\OperatorResource;

/**
* @property \OpenStack\Compute\v2\Api $api
*/
class Aggregate extends OperatorResource implements
Retrievable,
Listable
{
/** @var int */
public $id;

/** @var string */
public $availabiltyZone;

/** @var string */
public $createdAt;

/** @var string */
public $deletedAt;

/** @var boolean */
public $deleted;

/** @var array */
public $hosts;

/** @var array */
public $metadata;

/** @var string */
public $name;

/** @var string */
public $updatedAt;

/** @var string */
public $uuid;

protected $resourceKey = 'aggregate';
protected $resourcesKey = 'aggregates';

protected $aliases = [
'availability_zone' => 'availabilityZone',
'created_at' => 'createdAt',
'deleted_at' => 'deletedAt',
'updated_at' => 'updatedAt'
];

/**
* {@inheritDoc}
*/
public function retrieve()
{
$response = $this->execute($this->api->getAggregate(), ['id' => (string) $this->id]);
$this->populateFromResponse($response);
}
}
Loading