About GetRackspaceName() in Scriptlets

Hi.

In a Rackspace script, I can do this:

// Called whenever a rackspace is activated
On Activate
Print( "Rackspace script - Activation of: " + GetRackspaceName() )
end

In a scriptlet, however, I cannot do similar because GetRackspaceName() won’t compile. It is reported as an unknown identifier.

Since the

On Activate

end

block does itself work in scriptlet code, shouldn’t we be able to access the name of the Rackspace doing the activation if we want to?

At this point, my use case is for logging, and is not critical - but I mention it here in case this behavior is an oversight.

Thanks.

You could put the rackspacename in an environment variable in the rackspace script
and in a scriptlet you can read that environment variable

SetEnvVariable(<name : String>, <value : String>)

GetEnvVariable(<name : String>)
1 Like

Good idea, thanks Paul!

(but, see below for further info)

It’s not an oversite – in principle, plugins don’t know anything about the host and that has been deliberately true for scriptlets (which are plugins) as well. We have been slowing giving scriptlets more “access” to host stuff but it hasn’t been a high priority

1 Like

So, it seems that the scriptlets in a rackspace are Activated for the first time prior to the execution of the Rackspace Script.

Thus, if the scriptlet, on activation, reports on the value of an environmental variable set via Rackspace Script, it will report the previously open rackspace rather than the current (new) one.

Yes, it has to be that way….just like any other plugin in a rackspace, scriptlets have to be ready when a rackspace is activated.

It was probably a mistake to allow On Activate for scriptlets.

1 Like