Skip to content

Commit 6759db9

Browse files
committed
Merge pull request #288 from ekasitk/sahara
Add Sahara Plugin APIs
2 parents 7b5ef5b + 6764618 commit 6759db9

File tree

9 files changed

+494
-1
lines changed

9 files changed

+494
-1
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.openstack4j.api.sahara;
2+
3+
import java.util.List;
4+
5+
import org.openstack4j.common.RestService;
6+
import org.openstack4j.model.common.Payload;
7+
import org.openstack4j.model.sahara.ClusterTemplate;
8+
import org.openstack4j.model.sahara.Plugin;
9+
10+
/**
11+
* Sahara Data Processing Operations
12+
*
13+
14+
*/
15+
public interface SaharaPluginService extends RestService {
16+
17+
/**
18+
* List all plugins
19+
*
20+
* @return list of plugins registered in Sahara or empty
21+
*/
22+
List<? extends Plugin> list();
23+
24+
/**
25+
* Get a plugin by name
26+
* @param name the plugin name
27+
* @return the plugin or null if not found
28+
*/
29+
Plugin get(String name);
30+
31+
/**
32+
* Get a specific plugin with all details by name and version
33+
* @param name the plugin name
34+
* @param version the plugin version
35+
* @return the plugin or null if not found
36+
*/
37+
Plugin get(String name, String version);
38+
39+
/**
40+
* Convert plugin specific config file into cluster template
41+
*
42+
* @param name the plugin name
43+
* @param version the plugin version
44+
* @param templateName the cluster template name
45+
* @param payload the config file for the specific plugin
46+
* @return the cluster template
47+
*/
48+
ClusterTemplate convertConfig(String name, String version, String templateName, Payload<?> payload);
49+
50+
}

core/src/main/java/org/openstack4j/api/sahara/SaharaService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,11 @@ public interface SaharaService extends RestService {
3636
* @return the image service
3737
*/
3838
SaharaImageService images();
39+
40+
/**
41+
* Plugin Service API
42+
*
43+
* @return the plugin service
44+
*/
45+
SaharaPluginService plugins();
3946
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package org.openstack4j.model.sahara;
2+
3+
import java.util.List;
4+
import java.util.Map;
5+
6+
import org.openstack4j.model.ModelEntity;
7+
8+
/**
9+
* A Sahara Config Information
10+
*
11+
12+
*/
13+
public interface ConfigInfo extends ModelEntity {
14+
15+
/**
16+
* @return the default value
17+
*/
18+
String getDefaultValue();
19+
20+
/**
21+
* @return the name
22+
*/
23+
String getName();
24+
25+
/**
26+
* @return the priority
27+
*/
28+
Integer getPriority();
29+
30+
/**
31+
* @return the type (string, int, bool, enum)
32+
*/
33+
String getType();
34+
35+
/**
36+
* @return the applicable target
37+
*/
38+
String getApplicableTarget();
39+
40+
/**
41+
* @return true if this config is optional
42+
*/
43+
Boolean isOptional();
44+
45+
/**
46+
* @return the scope
47+
*/
48+
String getScope();
49+
50+
/**
51+
* @return the description
52+
*/
53+
String getDescription();
54+
55+
/**
56+
* @return the list of valid config values (if type is enum)
57+
*/
58+
List<String> getConfigValues();
59+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.openstack4j.model.sahara;
2+
3+
import java.util.List;
4+
import java.util.Map;
5+
6+
import org.openstack4j.model.ModelEntity;
7+
8+
/**
9+
* A Sahara Plugin
10+
*
11+
12+
*/
13+
public interface Plugin extends ModelEntity {
14+
15+
/**
16+
* @return the plugin description
17+
*/
18+
String getDescription();
19+
20+
/**
21+
* @return the available plugin versions
22+
*/
23+
List<String> getVersions();
24+
25+
/**
26+
* @return the name of the plugin
27+
*/
28+
String getName();
29+
30+
/**
31+
* @return the title of the plugin
32+
*/
33+
String getTitle();
34+
35+
/**
36+
* @return the list of processes in a specific service (node_processes in Sahara plugin terminology)
37+
*/
38+
Map<String,List<String>> getServiceProcesses();
39+
40+
41+
/**
42+
* @return the list of required image tags
43+
*/
44+
List<String> getRequiredImageTags();
45+
46+
/**
47+
* @return the list of config information (definitions and default values)
48+
*/
49+
List<? extends ConfigInfo> getConfigInfos();
50+
51+
}

core/src/main/java/org/openstack4j/openstack/provider/DefaultAPIProvider.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
import org.openstack4j.api.networking.ext.VipService;
5050
import org.openstack4j.api.sahara.ClusterService;
5151
import org.openstack4j.api.sahara.ClusterTemplateService;
52-
import org.openstack4j.api.sahara.SaharaImageService;
5352
import org.openstack4j.api.sahara.NodeGroupTemplateService;
53+
import org.openstack4j.api.sahara.SaharaPluginService;
54+
import org.openstack4j.api.sahara.SaharaImageService;
5455
import org.openstack4j.api.sahara.SaharaService;
5556
import org.openstack4j.api.storage.BlockStorageService;
5657
import org.openstack4j.api.storage.BlockVolumeService;
@@ -110,6 +111,7 @@
110111
import org.openstack4j.openstack.sahara.internal.ClusterTemplateServiceImpl;
111112
import org.openstack4j.openstack.sahara.internal.NodeGroupTemplateServiceImpl;
112113
import org.openstack4j.openstack.sahara.internal.SaharaImageServiceImpl;
114+
import org.openstack4j.openstack.sahara.internal.SaharaPluginServiceImpl;
113115
import org.openstack4j.openstack.sahara.internal.SaharaServiceImpl;
114116
import org.openstack4j.openstack.storage.block.internal.BlockStorageServiceImpl;
115117
import org.openstack4j.openstack.storage.block.internal.BlockVolumeServiceImpl;
@@ -194,6 +196,7 @@ public void initialize() {
194196
bind(LbPoolService.class,LbPoolServiceImpl.class);
195197
bind(LoadBalancerService.class, LoadBalancerServiceImpl.class);
196198
bind(BlockVolumeTransferService.class, BlockVolumeTransferServiceImpl.class);
199+
bind(SaharaPluginService.class,SaharaPluginServiceImpl.class);
197200
bind(SaharaImageService.class,SaharaImageServiceImpl.class);
198201
bind(SaharaService.class,SaharaServiceImpl.class);
199202
bind(ClusterService.class,ClusterServiceImpl.class);
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package org.openstack4j.openstack.sahara.domain;
2+
3+
import java.util.List;
4+
5+
import org.openstack4j.model.sahara.ConfigInfo;
6+
import com.google.common.base.Objects;
7+
8+
import com.fasterxml.jackson.annotation.JsonFormat;
9+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
10+
import com.fasterxml.jackson.annotation.JsonProperty;
11+
import com.fasterxml.jackson.annotation.JsonRootName;
12+
13+
/**
14+
* For mapping JSON response to/from java objects
15+
*
16+
17+
*/
18+
19+
@JsonIgnoreProperties(ignoreUnknown=true)
20+
public class SaharaConfigInfo implements ConfigInfo {
21+
22+
private static final long serialVersionUID = 1L;
23+
24+
@JsonProperty("default_value")
25+
private String defaultValue;
26+
private String name;
27+
private Integer priority;
28+
@JsonProperty("config_type")
29+
private String type;
30+
@JsonProperty("applicable_target")
31+
private String applicableTarget;
32+
@JsonProperty("is_optional")
33+
private Boolean isOptional;
34+
private String scope;
35+
private String description;
36+
@JsonProperty("config_values")
37+
private List<String> configValues;
38+
39+
/**
40+
* {@inheritDoc}
41+
*/
42+
@Override
43+
public String getDefaultValue() {
44+
return description;
45+
}
46+
47+
/**
48+
* {@inheritDoc}
49+
*/
50+
@Override
51+
public String getName() {
52+
return name;
53+
}
54+
55+
/**
56+
* {@inheritDoc}
57+
*/
58+
@Override
59+
public Integer getPriority() {
60+
return priority;
61+
}
62+
63+
/**
64+
* {@inheritDoc}
65+
*/
66+
@Override
67+
public String getType() {
68+
return type;
69+
}
70+
71+
/**
72+
* {@inheritDoc}
73+
*/
74+
@Override
75+
public String getApplicableTarget() {
76+
return applicableTarget;
77+
}
78+
79+
/**
80+
* {@inheritDoc}
81+
*/
82+
@Override
83+
public Boolean isOptional() {
84+
return isOptional;
85+
}
86+
87+
/**
88+
* {@inheritDoc}
89+
*/
90+
@Override
91+
public String getScope() {
92+
return scope;
93+
}
94+
95+
/**
96+
* {@inheritDoc}
97+
*/
98+
@Override
99+
public String getDescription() {
100+
return description;
101+
}
102+
103+
/**
104+
* {@inheritDoc}
105+
*/
106+
@Override
107+
public List<String> getConfigValues() {
108+
return configValues;
109+
}
110+
111+
@Override
112+
public String toString() {
113+
return Objects.toStringHelper(this).omitNullValues()
114+
.add("name", name)
115+
.add("description", description)
116+
.add("priority", priority)
117+
.add("config_type",type)
118+
.add("default_value", defaultValue)
119+
.add("config_values",configValues)
120+
.add("is_optional",isOptional)
121+
.add("scope",scope)
122+
.add("applicable_target",applicableTarget)
123+
.toString();
124+
}
125+
126+
}

0 commit comments

Comments
 (0)