-
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathJCloudsCloud.java
More file actions
658 lines (560 loc) · 25.2 KB
/
JCloudsCloud.java
File metadata and controls
658 lines (560 loc) · 25.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
package jenkins.plugins.openstack.compute;
import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
import com.cloudbees.plugins.credentials.domains.DomainRequirement;
import hudson.Extension;
import hudson.Util;
import hudson.model.Computer;
import hudson.model.Descriptor;
import hudson.model.Failure;
import hudson.model.Item;
import hudson.model.Label;
import hudson.model.Node;
import hudson.security.ACL;
import hudson.security.ACLContext;
import hudson.slaves.Cloud;
import hudson.slaves.NodeProvisioner;
import hudson.slaves.NodeProvisioner.PlannedNode;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import hudson.util.Secret;
import jenkins.model.Jenkins;
import jenkins.plugins.openstack.compute.auth.OpenstackCredential;
import jenkins.plugins.openstack.compute.auth.OpenstackCredentials;
import jenkins.plugins.openstack.compute.auth.OpenstackCredentialv2;
import jenkins.plugins.openstack.compute.auth.OpenstackCredentialv3;
import jenkins.plugins.openstack.compute.internal.Openstack;
import jenkins.plugins.openstack.compute.slaveopts.LauncherFactory;
import jenkins.util.Timer;
import org.acegisecurity.Authentication;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.cloudstats.CloudStatistics;
import org.jenkinsci.plugins.cloudstats.ProvisioningActivity;
import org.jenkinsci.plugins.cloudstats.TrackedPlannedNode;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.interceptor.RequirePOST;
import org.openstack4j.api.exceptions.AuthenticationException;
import org.openstack4j.model.compute.Server;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import static java.lang.Boolean.TRUE;
/**
* The JClouds version of the Jenkins Cloud.
*
* @author Vijay Kiran
*/
public class JCloudsCloud extends Cloud implements SlaveOptions.Holder {
private static final Logger LOGGER = Logger.getLogger(JCloudsCloud.class.getName());
private final @Nonnull String endPointUrl;
private final boolean ignoreSsl;
private final @CheckForNull String zone; // OpenStack4j requires null when there is no zone configured
// Make sure only diff of defaults is saved so when plugin defaults will change users are not stuck with outdated config
private /*final*/ @Nonnull SlaveOptions slaveOptions;
private final @Nonnull List<JCloudsSlaveTemplate> templates;
private /*final*/ @Nonnull String credentialId; // Name differs from property name not to break the persistence
// Backward compatibility
private transient @Deprecated Integer instanceCap;
private transient @Deprecated Integer retentionTime;
private transient @Deprecated Integer startTimeout;
private transient @Deprecated Boolean floatingIps;
private transient @Deprecated String identity;
private transient @Deprecated Secret credential;
public static @Nonnull List<JCloudsCloud> getClouds() {
List<JCloudsCloud> clouds = new ArrayList<>();
for (Cloud c : Jenkins.get().clouds) {
if (c instanceof JCloudsCloud) {
clouds.add((JCloudsCloud) c);
}
}
return clouds;
}
/**
* @throws IllegalArgumentException If the OpenStack cloud with given name does not exist.
*/
public static @Nonnull JCloudsCloud getByName(@Nonnull String name) throws IllegalArgumentException {
Cloud cloud = Jenkins.get().clouds.getByName(name);
if (cloud instanceof JCloudsCloud) return (JCloudsCloud) cloud;
throw new IllegalArgumentException("'" + name + "' is not an OpenStack cloud but " + cloud);
}
@DataBoundConstructor @Restricted(DoNotUse.class)
public JCloudsCloud(
final @Nonnull String name,
final @Nonnull String endPointUrl,
final boolean ignoreSsl,
final @CheckForNull String zone,
final @CheckForNull SlaveOptions slaveOptions,
final @CheckForNull List<JCloudsSlaveTemplate> templates,
final @Nonnull String credentialsId
) {
super(Util.fixNull(name).trim());
this.endPointUrl = Util.fixNull(endPointUrl).trim();
this.ignoreSsl = TRUE.equals(ignoreSsl);
this.zone = Util.fixEmptyAndTrim(zone);
this.credentialId = credentialsId;
this.slaveOptions = slaveOptions == null ? SlaveOptions.empty() : slaveOptions.eraseDefaults(DescriptorImpl.DEFAULTS);
this.templates = templates == null ? Collections.emptyList() : Collections.unmodifiableList(templates);
injectReferenceIntoTemplates();
}
@SuppressWarnings({"unused", "deprecation", "ConstantConditions"})
private Object readResolve() {
if (retentionTime != null || startTimeout != null || floatingIps != null || instanceCap != null ) {
SlaveOptions carry = SlaveOptions.builder()
.instanceCap(instanceCap)
.retentionTime(retentionTime)
.startTimeout(startTimeout)
.floatingIpPool(floatingIps ? "public" : null)
.build()
;
slaveOptions = DescriptorImpl.DEFAULTS.override(carry);
retentionTime = null;
startTimeout = null;
floatingIps = null;
instanceCap = null;
}
// Migrate to v2.24
LauncherFactory lf = null;
if ("JNLP".equals(slaveOptions.slaveType)) {
lf = LauncherFactory.JNLP.JNLP;
} else if (!"JNLP".equals(slaveOptions.slaveType) && slaveOptions.credentialsId != null) {
// user configured credentials and clearly rely on SSH launcher that used to be the default so bring it back
lf = new LauncherFactory.SSH(slaveOptions.credentialsId);
}
if (lf != null) {
slaveOptions = slaveOptions.getBuilder().launcherFactory(lf).build();
}
injectReferenceIntoTemplates();
if (identity != null) {
String[] id = identity.split(":");
OpenstackCredential migratedOpenstackCredential = null;
if (id.length == 2) {
//If id.length == 2, it is assumed that is being used API V2
String tenant = id[0];
String username = id[1];
migratedOpenstackCredential = new OpenstackCredentialv2(CredentialsScope.SYSTEM,null,null,tenant,username,credential);
} else if (id.length == 3) {
// convert the former identity string PROJECT_NAME:USER_NAME:DOMAIN_NAME
// to the new OpenstackV3 credential
String project = id[0];
String username = id[1];
String domain = id[2];
migratedOpenstackCredential = new OpenstackCredentialv3(CredentialsScope.SYSTEM,null,null,username,domain,project,domain,credential);
}
if (migratedOpenstackCredential != null) {
credentialId = migratedOpenstackCredential.getId();
try {
OpenstackCredentials.add(migratedOpenstackCredential);
OpenstackCredentials.save();
identity = null;
credential = null;
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Unable to migrate " + name + " cloud credential to the new version", e);
}
} else {
LOGGER.log(Level.SEVERE, "Unable to migrate " + name + " cloud credential to the new version");
}
}
return this;
}
private void injectReferenceIntoTemplates() {
for(JCloudsSlaveTemplate t: templates) {
t.setOwner(this);
}
}
public @Nonnull SlaveOptions getEffectiveSlaveOptions() {
return DescriptorImpl.DEFAULTS.override(slaveOptions);
}
public @Nonnull SlaveOptions getRawSlaveOptions() {
return slaveOptions;
}
public @Nonnull List<JCloudsSlaveTemplate> getTemplates() {
return templates;
}
public @Nonnull String getEndPointUrl() {
return endPointUrl;
}
public @CheckForNull String getZone() {
return zone;
}
/**
* Get a queue of templates to be used to provision slaves of label.
*
* The queue contains the same template in as many instances as is the number of machines that can be safely
* provisioned without violating instanceCap constrain.
*/
private @Nonnull Queue<JCloudsSlaveTemplate> getAvailableTemplateProvider(@CheckForNull Label label, int excessWorkload) {
final int globalMax = getEffectiveSlaveOptions().getInstanceCap();
final Queue<JCloudsSlaveTemplate> queue = new ConcurrentLinkedDeque<>();
List<JCloudsComputer> cloudComputers = JCloudsComputer.getAll().stream().filter(
it -> name.equals(it.getId().getCloudName())
).collect(Collectors.toList());
int nodeCount = cloudComputers.size();
if (nodeCount >= globalMax) {
return queue; // more slaves then declared - no need to query openstack
}
// Check the number of current servers
int serverCount = 0;
List<Server> runningNodes = new ArrayList<Server>();
try {
// get the running nodes
runningNodes = getOpenstack().getRunningNodes();
serverCount = runningNodes.size();
if (serverCount >= globalMax) {
return queue; // more servers than needed - no need to proceed any further
}
} catch (JCloudsCloud.LoginFailure ex) {
LOGGER.log(Level.WARNING, "Login failure: " + ex.getMessage());
return queue;
}
int globalCapacity = globalMax - Math.max(nodeCount, serverCount);
assert globalCapacity > 0;
for (JCloudsSlaveTemplate t : templates) {
if (t.canProvision(label)) {
SlaveOptions opts = t.getEffectiveSlaveOptions();
final int templateMax = opts.getInstanceCap();
long templateNodeCount = Math.max(
cloudComputers.stream().filter(it -> t.getName().equals(it.getId().getTemplateName())).count(),
runningNodes.stream().filter(t::hasProvisioned).count()
);
if (templateNodeCount >= templateMax) continue; // Exceeded
long templateCapacity = templateMax - templateNodeCount;
assert templateCapacity > 0;
for (int i = 0; i < templateCapacity; i++) {
int size = queue.size();
if (size >= globalCapacity || size >= excessWorkload) return queue;
queue.add(t);
}
}
}
return queue;
}
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
Queue<JCloudsSlaveTemplate> templateProvider = getAvailableTemplateProvider(label, excessWorkload);
List<PlannedNode> plannedNodeList = new ArrayList<>();
while (excessWorkload > 0 && !Jenkins.get().isQuietingDown() && !Jenkins.get().isTerminating()) {
final JCloudsSlaveTemplate template = templateProvider.poll();
if (template == null) {
// two cases
// cloud authentication issue or Instance cap exceeded
try {
// try to authenticate
getOpenstack();
// if okay, then the problem is related to the instance cap
LOGGER.info("Instance cap exceeded for cloud " + name + " while provisioning for label " + label);
break;
} catch (JCloudsCloud.LoginFailure ex) {
// no need to log here because it has already been logged in the getAvailableTemplates method.
break;
}
}
LOGGER.fine("Provisioning slave for " + label + " from template " + template.getName());
int numExecutors = template.getEffectiveSlaveOptions().getNumExecutors();
ProvisioningActivity.Id id = new ProvisioningActivity.Id(this.name, template.getName());
Future<Node> task = Computer.threadPoolForRemoting.submit(new NodeCallable(this, template, id));
plannedNodeList.add(new TrackedPlannedNode(id, numExecutors, task));
excessWorkload -= numExecutors;
}
return plannedNodeList;
}
private static final class NodeCallable implements Callable<Node> {
private final JCloudsCloud cloud;
private final JCloudsSlaveTemplate template;
private final ProvisioningActivity.Id id;
NodeCallable(JCloudsCloud cloud, JCloudsSlaveTemplate template, ProvisioningActivity.Id id) {
this.cloud = cloud;
this.template = template;
this.id = id;
}
@Override
public Node call() {
JCloudsSlave jcloudsSlave = template.provisionSlave(cloud, id);
LOGGER.fine(String.format("Slave %s launched successfully", jcloudsSlave.getDisplayName()));
return jcloudsSlave;
}
}
@Restricted(NoExternalUse.class)
public /*for mocking*/ @CheckForNull String slaveIsWaitingFor(@Nonnull JCloudsSlave slave) throws ProvisioningFailedException {
return slave.getSlaveOptions().getLauncherFactory().isWaitingFor(slave);
}
@Override
public boolean canProvision(final Label label) {
for (JCloudsSlaveTemplate t : templates)
if (t.canProvision(label))
return true;
return false;
}
public @CheckForNull JCloudsSlaveTemplate getTemplate(String name) {
for (JCloudsSlaveTemplate t : templates)
if (t.getName().equals(name))
return t;
return null;
}
/**
* Provisions a new node manually (by clicking a button in the computer list).
*
* @param req {@link StaplerRequest}
* @param rsp {@link StaplerResponse}
* @param name Name of the template to provision
*/
@Restricted(NoExternalUse.class)
@RequirePOST
public void doProvision(StaplerRequest req, StaplerResponse rsp, @QueryParameter String name) throws IOException {
// Temporary workaround for https://issues.jenkins-ci.org/browse/JENKINS-37616
// Using Item.CONFIGURE as users authorized to do so can provision via job execution.
// Once the plugins starts to depend on core new enough, we can use Cloud.PROVISION again.
if (!hasPermission(Item.CONFIGURE) && !hasPermission(Cloud.PROVISION)) {
checkPermission(Cloud.PROVISION);
}
if (rsp.getContentType() == null) { // test hack for JenkinsRule#executeOnServer
rsp.setContentType("text/xml");
}
if (name == null) {
sendPlaintextError("The slave template name query parameter is missing", rsp);
return;
}
JCloudsSlaveTemplate t = getTemplate(name);
if (t == null) {
sendPlaintextError("No such slave template with name : " + name, rsp);
return;
}
List<Server> nodes = getOpenstack().getRunningNodes();
final int global = nodes.size();
int globalCap = getEffectiveSlaveOptions().getInstanceCap();
if (global >= globalCap) {
String msg = String.format("Instance cap of %s is now reached: %d", this.name, globalCap);
sendPlaintextError(msg, rsp);
return;
}
int template = 0;
for (Server node : nodes) {
if (t.hasProvisioned(node)) {
template++;
}
}
int templateCap = t.getEffectiveSlaveOptions().getInstanceCap();
if (template >= templateCap) {
String msg = String.format("Instance cap for this template (%s/%s) is now reached: %d", this.name, name, templateCap);
sendPlaintextError(msg, rsp);
return;
}
try {
provisionAsynchronouslyNotToBlockTheRequestThread(t);
rsp.getWriter().println("<ok>Provisioning started</ok>");
} catch (Throwable ex) {
sendPlaintextError(ex.getMessage(), rsp);
}
}
private void provisionAsynchronouslyNotToBlockTheRequestThread(JCloudsSlaveTemplate t) throws Throwable {
Authentication auth = Jenkins.getAuthentication();
Callable<Void> performProvisioning = () -> {
// Impersonate current identity inside the worker thread not to lose the owner info
try (ACLContext ignored = ACL.as(auth)) {
try {
provisionSlaveExplicitly(t);
return null;
} catch (Throwable ex) {
LOGGER.log(Level.WARNING, "Provisioning failed", ex);
throw ex;
}
}
};
ScheduledFuture<?> schedule = Timer.get().schedule(performProvisioning, 0, TimeUnit.SECONDS);
// Wait for fast failures and present them to user on best effort basis
try {
schedule.get(3, TimeUnit.SECONDS);
} catch (ExecutionException e) {
// Fast failure
throw e.getCause();
} catch (TimeoutException e) {
// Expected - success or slow failure
}
}
// This is served by AJAX so we are stripping the html
private static void sendPlaintextError(String message, StaplerResponse rsp) throws IOException {
rsp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
PrintWriter response = rsp.getWriter();
response.println("<error>" + message + "</error>");
}
/**
* Provision slave out of {@link NodeProvisioner} context.
*/
@Restricted(NoExternalUse.class)
/*package*/ @Nonnull JCloudsSlave provisionSlaveExplicitly(@Nonnull JCloudsSlaveTemplate template) throws IOException, Openstack.ActionFailed{
CloudStatistics.ProvisioningListener provisioningListener = CloudStatistics.ProvisioningListener.get();
ProvisioningActivity.Id id = new ProvisioningActivity.Id(name, template.getName());
JCloudsSlave node;
try {
provisioningListener.onStarted(id);
node = template.provisionSlave(this, id);
provisioningListener.onComplete(id, node);
} catch (Throwable ex) {
provisioningListener.onFailure(id, ex);
throw ex;
}
Jenkins.get().addNode(node);
return node;
}
/**
* Get connected OpenStack client wrapper.
*
* @throws LoginFailure In case the details are incomplete or rejected by OpenStack.
*/
@Restricted(NoExternalUse.class)
public @Nonnull Openstack getOpenstack() throws LoginFailure {
try {
OpenstackCredential credential = OpenstackCredentials.getCredential(getCredentialsId());
if (credential == null) {
throw new LoginFailure("No credentials found for cloud " + name + " (id=" + getCredentialsId() + ")");
}
return Openstack.Factory.get(endPointUrl, ignoreSsl, credential, zone);
} catch (AuthenticationException ex) {
throw new LoginFailure(name, ex);
} catch (FormValidation ex) {
throw new LoginFailure(name, ex);
}
}
public String getCredentialsId() {
return credentialId;
}
@Restricted(DoNotUse.class) // Jelly
public boolean getIgnoreSsl() {
return ignoreSsl;
}
@Override
public String toString() {
return String.format("OpenStack cloud %s for %s", name, endPointUrl);
}
@Extension
@Symbol("openstack")
public static class DescriptorImpl extends Descriptor<Cloud> {
// Plugin default slave attributes - the root of all overriding
private static final SlaveOptions DEFAULTS = SlaveOptions.builder()
.instanceCap(10)
.instancesMin(0)
.retentionTime(30)
.startTimeout(600000)
.numExecutors(1)
.fsRoot("/jenkins")
.securityGroups("default")
.configDrive(false)
.build()
;
@Override
public @Nonnull String getDisplayName() {
return "Cloud (OpenStack)";
}
public static SlaveOptions getDefaultOptions() {
return DEFAULTS;
}
@Restricted(DoNotUse.class)
@RequirePOST
public FormValidation doCheckName(@QueryParameter String value) {
try {
Jenkins.checkGoodName(value);
return FormValidation.ok();
} catch (Failure ex) {
return FormValidation.error(ex.getMessage());
}
}
@Restricted(DoNotUse.class)
@RequirePOST
public FormValidation doTestConnection(
@QueryParameter boolean ignoreSsl,
@QueryParameter String credentialsId,
@QueryParameter String endPointUrl,
@QueryParameter String zone
) {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
try {
OpenstackCredential openstackCredential = OpenstackCredentials.getCredential(credentialsId);
if (openstackCredential == null) throw FormValidation.error("No credential found for " + credentialsId);
Openstack openstack = Openstack.Factory.get(endPointUrl, ignoreSsl, openstackCredential, zone);
Throwable ex = openstack.sanityCheck();
if (ex != null) {
return FormValidation.warning(ex, "Connection not validated, plugin might not operate correctly: " + ex.getMessage());
}
return FormValidation.okWithMarkup("Connection succeeded!<br/><small>" + Util.escape(openstack.getInfo()) + "</small>");
} catch (FormValidation ex) {
return ex;
} catch (Exception ex) {
return FormValidation.error(ex, "Cannot connect to specified cloud, please check the identity and credentials: " + ex.getMessage());
}
}
@Restricted(DoNotUse.class)
@RequirePOST
public FormValidation doCheckEndPointUrl(@QueryParameter String value) {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
if (Util.fixEmpty(value) == null) return FormValidation.validateRequired(value);
try {
new URL(value);
} catch (MalformedURLException ex) {
return FormValidation.error(ex, "The endpoint must be URL");
}
return FormValidation.ok();
}
@Restricted(DoNotUse.class)
@RequirePOST
public ListBoxModel doFillCredentialsIdItems() {
Jenkins jenkins = Jenkins.get();
jenkins.checkPermission(Jenkins.ADMINISTER);
return new StandardListBoxModel()
.includeMatchingAs(ACL.SYSTEM, jenkins, StandardCredentials.class,
Collections.<DomainRequirement>emptyList(),
CredentialsMatchers.instanceOf(OpenstackCredential.class))
.includeEmptyValue();
}
}
/**
* The request to provision was not fulfilled.
*/
public static final class ProvisioningFailedException extends RuntimeException {
private static final long serialVersionUID = -8524954909721965323L;
public ProvisioningFailedException(String msg, Throwable cause) {
super(msg, cause);
}
public ProvisioningFailedException(String msg) {
super(msg);
}
}
/*package*/
public static final class LoginFailure extends RuntimeException {
private static final long serialVersionUID = 4085466675398031930L;
private LoginFailure(String name, FormValidation ex) {
super("Openstack authentication invalid fro cloud " + name + ": " + ex.getMessage(), ex);
}
private LoginFailure(String name, AuthenticationException ex) {
super("Failure to authenticate for cloud " + name + ": " + ex.toString());
}
public LoginFailure(String msg) {
super(msg);
}
}
}