Skip to content
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

Add Sahara data processing support #157

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions samples/data_processing/cluster/create_cluster.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$options = [
'pluginName' => '{pluginName}',
'hadoopVersion' => '{hadoopVersion}',
'clusterTemplateId' => '{clusterTemplateId}',
'defaultImageId' => '{defaultImageId}',
//user keypair id is optional
'userKeypairId' => '{userKeypairId}',
'name' => '{name}',
'neutronManagementNetwork' => '{neutronManagementNetworkId}',
];

$cluster = $sahara->createCluster($options);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type hint to $cluster
e.g. /**@var OpenStack\DataProcessing\v1\Models\Cluster $cluster */

41 changes: 41 additions & 0 deletions samples/data_processing/cluster/create_multiple_clusters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$options = [
'pluginName' => '{pluginName}',
'hadoopVersion' => '{hadoopVersion}',
'clusterTemplateId' => '{clusterTemplateId}',
'defaultImageId' => '{defaultImageId}',
//user keypair id is optional
'userKeypairId' => '{userKeypairId}',
'name' => '{name}',
'neutronManagementNetwork' => '{neutronManagementNetworkId}',
'count' => '{count}',
//optional
'clusterConfigs' => ['foo' => 'bar'],
];

$clusters = $sahara->createCluster($options);
foreach ($clusters as $cluster) {
print_r($cluster);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type hint

}
25 changes: 25 additions & 0 deletions samples/data_processing/cluster/delete_cluster.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$cluster = $sahara->getCluster(['id' => '{clusterId}']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type hint

$cluster->delete();
26 changes: 26 additions & 0 deletions samples/data_processing/cluster/get_cluster.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$cluster = $sahara->getCluster(['id' => '{clusterId}']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type hint

$cluster->retrieve();
print_r($cluster);
32 changes: 32 additions & 0 deletions samples/data_processing/cluster/list_clusters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$options = [
'limit' => '{limit}',
'marker' => '{marker}',
'sortKey' => '{sortKey}'
];

$clusters = $sahara->listClusters($options);
foreach ($clusters as $cluster) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type hint to $client

}
37 changes: 37 additions & 0 deletions samples/data_processing/cluster/scale_cluster.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$options = [
'id' => '{clusterId}',
'addNodeGroups' => [[
'count' => '{count}',
'name' => '{name}',
'nodeGroupTemplateId' => '{nodeGroupTemplateId}',
]],
'resizeNodeGroups' => [[
'count' => '{count}',
'name' => '{name}',
]],
];

$cluster = $sahara->scaleCluster($options);
28 changes: 28 additions & 0 deletions samples/data_processing/cluster/update_cluster.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$cluster = $sahara->getCluster(['id' => '{clusterId}']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type hint

$cluster->name = '{newName}';
$cluster->isPublic = '{trueOrFalse}';
$cluster->isProtected = '{trueOrFalse}';
$cluster->update();
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);
$options = [
'pluginName' => '{pluginName}',
'hadoopVersion' => '{hadoopVersion}',
'nodeGroups' => [[
'name' => '{nodeGroupName}',
'count' => '{count}',
'nodeGroupTemplateId' => '{nodeGroupTemplateId}',
],
[
'name' => '{nodeGroupName}',
'count' => '{count}',
'nodeGroupTemplateId' => '{nodeGroupTemplateId}',
],
[
'name' => '{NodeGroupname}',
'count' => '{count}',
'nodeGroupTemplateId' => '{nodeGroupTemplateId}',
],
],
'name' => '{ClusterTemplateName}',
];

$clusterTemplate = $sahara->createClusterTemplate($options);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type hint

print_r($clusterTemplate);
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$cluster = $sahara->getClusterTemplate(['id' => '{clusterTemplateId}']);
$cluster->delete();
26 changes: 26 additions & 0 deletions samples/data_processing/cluster_template/get_cluster_template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$clusterTemplate = $sahara->getClusterTemplate(['id' => '{clusterTemplateId}']);
$clusterTemplate->retrieve();
print_r($clusterTemplate);
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$options = [
'limit' => '{limit}',
'sortBy' => '{sortBy}',
];

$clusterTemplates = $sahara->listClusterTemplates($options);
foreach ($clusterTemplates as $clusterTemplate) {
print_r($clusterTemplate);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

require 'vendor/autoload.php';

use OpenStack\OpenStack;

$openstack = new OpenStack([
'authUrl' => '{authUrl}',
'user' => [
'name' => '{userName}',
'password' => '{password}',
'domain' => ['name' => '{userDomain}'],
],
'scope' => [
'project' => [
'name' => '{projectName}',
'domain' => ['name' => '{projectDomain}'],
],
],
]);

$sahara = $openstack->dataProcessingV1(['region' => '{region}']);

$clusterTemplate = $sahara->getClusterTemplate(['id' => '{clusterTemplateId}']);
$clusterTemplate->name = '{newName}';
$clusterTemplate->isPublic = '{trueOrFalse}';
$clusterTemplate->pluginName = '{newPluginName}';
$clusterTemplate->hadoopVersion = '{newHadoopVersion}';
$clusterTemplate->update();
print_r($clusterTemplate);
Loading