Code:
private TemplateBuilder prepareTemplate(VmSettings vmSettings) throws
ServiceException, IOException {

TemplateBuilder templateBuilder = compute.templateBuilder();
templateBuilder.imageId(CLOUD_REGION + "/" + vmSettings.getAmiId());
templateBuilder.locationId(CLOUD_REGION);
templateBuilder.hardwareId(CLOUD_INSTANCE_TYPE);

EC2TemplateOptions o =
EC2TemplateOptions.Builder.keyPair("crossbuild")                
.overrideLoginCredentials(getLoginForCommandExecution(vmSettings)).securityGroups("jclouds#crossbuild");
templateBuilder.options(o);

return templateBuilder;

}


Props:
 <property name="CLOUD_REGION" value="eu-central-1"/>
 <property name="CLOUD_INSTANCE_TYPE" value="t2.micro"/>

On 18. 03. 2016 16:50, Ignasi Barrera wrote:
> Regarding the group name in the nodes, could you share the code you
> use to build the template, including the template options?
> 
> On 17 March 2016 at 01:52, Ignasi Barrera <n...@apache.org> wrote:
>> Good to see that part is working!
>>
>> FWIW, jclouds adds a prefix to some resources, for convenience. This can be
>> configured, though, by setting the
>> ComputeServiceProperties.RESOURCENAME_PREFIX property [1] when creating the
>> context. You can change the default "jclouds" value or set it to an empty
>> string if you don't want jclouds to prefix the resources it creates.
>>
>> I.
>>
>> [1]
>> http://jclouds.apache.org/reference/javadoc/1.9.x/constant-values.html#org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_PREFIX
>>
>> El 16/3/2016 18:22, "cen" <imba...@gmail.com> escribió:
>>>
>>> Yeah sure. This is my final code to create the security group:
>>>
>>> AWSEC2SecurityGroupExtension client =
>>> (AWSEC2SecurityGroupExtension)compute.getSecurityGroupExtension().get();
>>>
>>> SecurityGroup sg = client.createSecurityGroup("crossbuild", CLOUD_REGION);
>>> Builder b = IpPermission.builder();
>>> b.fromPort(0);
>>> b.toPort(65535);
>>> b.groupId(sg.getProviderId());
>>> b.ipProtocol(IpProtocol.TCP);
>>> b.cidrBlock(CROSSBUILD_SECURITY_GROUP); //sth like 0.0.0.0/0
>>> client.addIpPermission(b.build(), sg);
>>>
>>>
>>> And now the catch, when setting the group name, the name is not actually
>>> what you just wanted uit to be because Jclouds adds prefix "jclouds#" to
>>> it. So when using security group in template builder, make sure you add
>>> that prefix:
>>>
>>> EC2TemplateOptions o = EC2TemplateOptions.Builder.
>>>
>>> .overrideLoginCredentials(getLoginForCommandExecution(vmSettings)).securityGroups("jclouds#crossbuild");
>>>
>>> On 16. 03. 2016 18:18, Andrew Phillips wrote:
>>>>> After changing the group name in template to "jclouds#crossbuild" it
>>>>> started working.
>>>>
>>>> Ah, glad to hear! Could you share your final code and perhaps a short
>>>> description of "this is what I was trying to do, this approach didn't
>>>> work, this different approach did"? I suspect that may turn into pretty
>>>> useful reference material for others trying to do the same thing in
>>>> future ;-)
>>>>
>>>> Regards
>>>>
>>>> ap

Reply via email to