Hi Richard,
Thanks for the reply. I looked at the advanced networking project and as you 
mentioned, found it pretty daunting but will look again. My initial takeaway 
about Brooklyn is that all of the entities seem to involve running instances. I 
don't see any docs/examples showing more static infrastructure like an AWS VPC 
or subnet or security group etc. Am I correct? I started creating some code 
inheriting from BasicEntity (as opposed to SoftwareProcess since there's 
nothing to SSH into for a VPC), but I don't quite understand the lifecycle of 
how a BasicEntity derived object gets initialized.

Where would I put my code to create the VPC and later destroy it?
Would I still use "sensors" for example to return the VPC id provided by AWS?

My code thus far is attached.

awsVPC.java
==========
/**
 * An {@link brooklyn.entity.Entity} that represents an ElasticSearch node
 */
@Catalog(name="AWS VPC", description="AWS VPC")

@ImplementedBy(awsVPCImpl.class)
public interface awsVPC extends BasicEntity {

    @SetFromFlag("version")
    ConfigKey<String> SUGGESTED_VERSION = 
ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "4.0.1");

    @SetFromFlag("CidrBlock")
    ConfigKey<String> CIDR_BLOCK = ConfigKeys.newStringConfigKey("CIDR_BLOCK", 
"The CIDR block you want the VPC to cover. For example: '10.0.0.0/16'", 
"10.0.0.0/16");

    @SetFromFlag("EnableDnsSupport")
    ConfigKey<Boolean> ENABLE_DNS_SUPPORT = 
ConfigKeys.newBooleanConfigKey("ENABLE_DNS_SUPPORT", "Specifies whether DNS 
resolution is supported for the VPC", true);

    @SetFromFlag("EnableDnsHostnames")
    ConfigKey<Boolean> ENABLE_DNS_HOSTNAMES = 
ConfigKeys.newBooleanConfigKey("ENABLE_DNS_HOSTNAMES", "Specifies whether the 
instances launched in the VPC get DNS hostnames.", false);

    @SetFromFlag("InstanceTenancy")
    ConfigKey<String> INSTANCE_TENANCY = 
ConfigKeys.newStringConfigKey("INSTANCE_TENANCY", "The allowed tenancy of 
instances launched into the VPC, default or dedicated", "default");
}

awsVPCImpl.java
=============
package com.siemens.cip.services.awsVPC;

import static com.google.common.base.Preconditions.checkNotNull;
import brooklyn.entity.basic.BasicEntityImpl;

import brooklyn.entity.basic.SoftwareProcessImpl;
import brooklyn.event.feed.http.HttpFeed;
import brooklyn.event.feed.http.HttpPollConfig;
import brooklyn.event.feed.http.HttpValueFunctions;
import brooklyn.location.access.BrooklynAccessUtils;

import com.google.common.base.Functions;
import com.google.common.net.HostAndPort;

public class awsVPCImpl extends BasicEntityImpl implements awsVPC {


    private HttpFeed httpFeed;

    public awsVPCImpl() {
        super();
    }

    @SuppressWarnings("rawtypes")

    @Override
    public void init() {
        super.init();
    }

    @Override
    protected void connectSensors() {
//      Integer rawPort = getAttribute(HTTP_PORT);
//        checkNotNull(rawPort, "HTTP_PORT sensors not set for %s; is an 
acceptable port available?", this);
//        HostAndPort hp = 
BrooklynAccessUtils.getBrooklynAccessibleAddress(this, rawPort);
//
//        super.connectSensors();
//        httpFeed = HttpFeed.builder()
//                      .entity(this)
//                      .period(200)
//                      .baseUri(String.format("http://%s:%s";, 
hp.getHostText(), hp.getPort()))
//                      .poll(new HttpPollConfig<Boolean>(SERVICE_UP)
//                                      
.onSuccess(HttpValueFunctions.responseCodeEquals(200))
//                                      
.onFailureOrException(Functions.constant(false)))
//                                      .build();
        //super.connectSensors();
        //connectServiceUpIsRunning();

    }


    @Override
    protected void disconnectSensors() {
//      super.disconnectSensors();
//        if (httpFeed != null) httpFeed.stop();
         //super.disconnectSensors();
         //disconnectServiceUpIsRunning();

    }


}

Thanks
Scott

-----Original Message-----
From: Richard Downer [mailto:[email protected]]
Sent: Wednesday, July 22, 2015 9:20 AM
To: [email protected]
Subject: Re: Help getting started with AWS VPC

Hi Scott,

Welcome to Brooklyn :-)

I suggest you take a look at the "advanced networking" project:
https://github.com/brooklyncentral/advanced-networking

It's a set of entities that support network concepts for a few clouds. It's not 
strictly part of Brooklyn, instead it's part of the wider community.

AWS is not yet supported by advanced-networking, so your contribution could be 
very useful! You could start by looking at how advanced-networking has done 
this for CloudStack, and use similar techniques for your AWS VPC implementation.

Be warned that the networking is pretty complex code. If you are new to 
Brooklyn and to Java I'd suggest starting with simpler entities first?

Richard.



On Tue, 21 Jul 2015 at 17:35 Kellish, Scott (CT US) <[email protected]>
wrote:

> Hi,
> New to Brooklyn (and java for that matter). Have Brooklyn installed
> and built one of the example entities.
>
> I would like to create a java entity to model an AWS VPC but not
> really sure how to start. Which class should I inherit from etc. Can
> someone point me in the right direction.
>
> Scott
>
> This message and any attachments are solely for the use of intended
> recipients. The information contained herein may include trade
> secrets, protected health or personal information, privileged or
> otherwise confidential information. Unauthorized review, forwarding,
> printing, copying, distributing, or using such information is strictly
> prohibited and may be unlawful. If you are not an intended recipient,
> you are hereby notified that you received this email in error, and
> that any review, dissemination, distribution or copying of this email
> and any attachment is strictly prohibited. If you have received this
> email in error, please contact the sender and delete the message and
> any attachment from your system. Thank you for your cooperation
>

This message and any attachments are solely for the use of intended recipients. 
The information contained herein may include trade secrets, protected health or 
personal information, privileged or otherwise confidential information. 
Unauthorized review, forwarding, printing, copying, distributing, or using such 
information is strictly prohibited and may be unlawful. If you are not an 
intended recipient, you are hereby notified that you received this email in 
error, and that any review, dissemination, distribution or copying of this 
email and any attachment is strictly prohibited. If you have received this 
email in error, please contact the sender and delete the message and any 
attachment from your system. Thank you for your cooperation

Reply via email to