jclouds-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <n...@apache.org>
Subject RE: assign a port on vm create?
Date Fri, 05 Dec 2014 18:08:22 GMT
If the option is available in the NovaTemplateOptions you don't need to
manually create the options object.

It is just a matter of order. Just call the specific NovaTemplateOptions
methods after the "as" call. Calling methods from the superclass
(TemplateOptions) will return that superclass, where concrete methods are
not available.
El 05/12/2014 18:22, "Zack Shoylev" <zack.shoylev@rackspace.com> escribió:

>  So this is the problem part as you have pointed out:
>
>  TemplateOptions to = *templateOptions*.as(NovaTemplateOptions.*class*)
>                            .generateKeyPair(*true*)
>                            .userData(*userData*.getBytes())
>                            .autoAssignFloatingIp(*true*)
>                            .networks(*virgaNetID*) //specified the *virga* net
> here to get *ip* 190... range
>                            .floatingIpPoolNames("public")
>                            .securityGroupNames("default") //force inherit
> of default *http*/icmpRULES
>                            //*TODO*
>                            //HOW to add *http*/*icmp* on the
> fly??????????????????????????????????
>                            .runAsRoot(*runAsRoot*
>                            ;
>
>  Instead of "TemplateOptions to" use "NovaTemplateOptions to "
> You can instantiate those using the NovaTemplateOptions.Builder, in a way
> similar to this example:
>
> https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/CreateServerWithKeyPair.java#L160
>
>  The builder has a novaNetworks method that can be used to set a Set of
> Network.
> The Network's builder will allow you to set portUuid (provide the port id
> for the port you created above).
>
>  The problem above is that TemplateOptions, unlike NovaTemplateOptions,
> do not provide access to the Network type that would allow you to set port
> ids, which is something specific to Nova.
>
>  Let me know if this makes sense...
>
>  -Zack
>
>  ------------------------------
> *From:* 'dan rusak' [merlinlabs@rseincorp.com]
> *Sent:* Friday, December 05, 2014 8:30 AM
> *To:* user@jclouds.apache.org
> *Subject:* RE: assign a port on vm create?
>
>   Zack,
>
> First, thanks for trying to help ..
>
> and yes, it is the ‘provide a port uuid’ on boot I am having trouble with
> from JClouds.
>
> Your listed steps are exactly  what I did prior to this,( including
> grazing thru javadocs).
>
> I see that this can be done from Openstack/neutron command line but the
> jclouds Nova api
>
> options (
> org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions )
>
> doesn’t seem to allow specifying the port uuid ..
>
> I include code here  .. What am I missing?
>
> .
>
> .
>
> .
>
>               Properties properties = NovaApiMetadata.*defaultProperties*
> ();
>
>               properties.setProperty(*TIMEOUT_SCRIPT_COMPLETE*, 6000 *
> 1000 + ""); //100 minutes
>
>               *logit*("<"+*thisClass*+":> " + "         get context: " );
>
>               *context* = ContextBuilder.*newBuilder*("openstack-nova")
>
>                            .endpoint("http://"+*controllerIP*+
> ":5000/v2.0/")
>
>                            .credentials("demo:demo", "demo")
>
>                            .overrides(properties) //set timeout here
>
>                            .modules(ImmutableSet.*of*(*new*
> SshjSshClientModule(),*new* SLF4JLoggingModule()))
>
>                            .buildView(ComputeServiceContext.*class*);
>
>               *logit*("<"+*thisClass*+":> " + "        context: " +
> *context*.toString());
>
>               *compute* = *context*.getComputeService();
>
>               *templateOptions* = *compute*.templateOptions();
>
> .
>
> .
>
> .
>
> //            In OpenStack *Neutron*, many times one prefers to rely on
> DHCP to have instances (VMs) have IP addresses assigned, mostly for
> simplicity.
>
> //            But there are cases where one would like to reserve a few
> IPs statically to be used by certain VMs.
>
> //            Well, it is possible to achieve this by manually creating
> ports inside the tenant network and attach them to an instance.
>
>
>
>
>
>
>
>               *portapi* = *neutronApi*.getPortApi("RegionOne");
>
>
>
>
>
>               List<Port> ports = *portapi*.list().concat().toList();
>
>               Port port = *null*;
>
>               *for* (*int* ii = 0; ii< ports.size(); ii++) {
>
>                      port = ports.get(ii);
>
> //                   System.out.println("<"+thisClass+":> " + "  PORT
> =          >>>>>" + port.getId());
>
>                      *if* (port.getName().contains("infra"))
>
>                            *portapi*.delete(port.getId());//cleanup old
> ports
>
>               }
>
>
>
>               *portapi* = *neutronApi*.getPortApi("RegionOne");
>
>
>
>
>
>               List<Port> ports = *portapi*.list().concat().toList();
>
>               Port port = *null*;
>
>               *for* (*int* ii = 0; ii< ports.size(); ii++) {
>
>                      port = ports.get(ii);
>
> //                   System.out.println("<"+thisClass+":> " + "  PORT
> =          >>>>>" + port.getId());
>
>                      *if* (port.getName().contains("infra"))
>
>                            *portapi*.delete(port.getId());//cleanup old
> ports
>
>               }
>
>
>
> //            *TODO*
>
> //            I can create a network with fixip but how to get create to
> use it??
>
>               IP fip = IP.*builder*().subnetId(*virgaSubNetID*).ipAddress(
> "191.0.1.112").build();//
>
>               *fixedIps*.add(fip);
>
>               CreateOptions *co* = Port.*createOptions*(*virgaNetID*)
>
>                            .name("infra2")
>
>                            .fixedIps(ImmutableSet.*copyOf*(*fixedIps*))
>
>                            .adminStateUp(*true*)
>
>                            .build();
>
>               *try* {
>
>                      *fixedPort*[0] = *portapi*.create(co);
>
>               } *catch* (Exception e) {
>
>                      // *TODO* Auto-generated catch block
>
>                      e.printStackTrace();
>
>               }
>
> .
>
> .
>
>
>
>               TemplateOptions to = *templateOptions*
> .as(NovaTemplateOptions.*class*)
>
>                            .generateKeyPair(*true*)
>
>                            .userData(*userData*.getBytes())
>
>                            .autoAssignFloatingIp(*true*)
>
>                            .networks(*virgaNetID*) //specified the *virga*
> net here to get *ip* 190... range
>
>                            .floatingIpPoolNames("public")
>
>                            .securityGroupNames("default") //force inherit
> of default *http*/icmpRULES
>
>                            //*TODO*
>
>                            //HOW to add *http*/*icmp* on the
> fly??????????????????????????????????
>
>                            .runAsRoot(*runAsRoot*
>
>                            ;
>
>               Template template = *compute*.templateBuilder().imageId(
>
>                            "RegionOne/" + *id*)
>
>                            .osFamily(OsFamily.*UNRECOGNIZED*).minRam(2000)
> //2000
>
>                            .options(to)
>
>                            .build();
>
> .
>
> .
>
> .
>
>               *try* {
>
>                      *nodeStackSets*[sdx] = *compute*.createNodesInGroup(
> *basegroup*, *maxNumberOfInstances*, template);
>
>               } *catch* (RunNodesException e) {
>
>                      // *TODO* Auto-generated catch block
>
>                      e.printStackTrace();
>
>               }
>
>
>
> *From:* Zack Shoylev [mailto:zack.shoylev@RACKSPACE.COM]
> *Sent:* Wednesday, December 03, 2014 5:14 PM
> *To:* user@jclouds.apache.org
> *Subject:* RE: assign a port on vm create?
>
>
>
> Here is my suggestion.
> Create a neutron network.
> Create a subnet (you will be allocating fixed IPs from that subnet's CIDR
> range).
> Create 8 ports on that subnet.
> These ports should specify fixed ips.
> These fixed ips should provide the subnet id and a fixed ip that is within
> the subnet range.
>
> Then:
> For each VM that you boot, you can provide a port uuid (when you boot with
> the nova API)
>
> http://jclouds.apache.org/reference/javadoc/1.8.x/org/jclouds/openstack/nova/v2_0/domain/Network.Builder.html#portUuid(java.lang.String)
> (It seems this is the part that you might be having trouble with).
>
> Let me know if this works or if you are having issues getting it to work.
>
> -Zack
>  ------------------------------
>
> *From:* Andrea Turli [andrea.turli@gmail.com]
> *Sent:* Sunday, November 30, 2014 12:08 PM
> *To:* user@jclouds.apache.org
> *Subject:* RE: assign a port on vm create?
>
> Thx Dan for the details.
>
> I think it is a specific question for Neutron support and I can't help you
> immediately on it. Could you please file an issue on jira reporting pretty
> much the same description so that we as community don't forget it again?
>
> thanks,
> Andrea
>
> Il 30/nov/2014 00:57 "dan rusak" <merlinlabs@rseincorp.com> ha scritto:
>
> Oh .. of course ..
> thought that might be  a generic question.
>
> I use JClouds 1.8.0 (I notice that neutron is broken in 1.8.1 or would
> have upgraded).
> I am using Openstack icehouse on a  local endpoint collocated with my
> VM installations with Chef-solo installed on my centos 6.5 image.
> I need to instantiate and provision 8 VMs which need to perform nfs mounts
> against each other during their provisioning and issue commands over ssh
> between them
> when all are up and operational.
> I have looked into everything I can find scraps of in the ether to provide
> static
> ips  so this can happen but they all seem to dead end for one reason or
> another, usually
> resulting in silence in fact when someone else has the same general
> question.
>  Anyway wrapping an ip in a port using the neutron api looked promising
> but need to get the
> VMs to use the port to see if that would even work.
>
> thx
> -dan
>
>
>
> -----Original Message-----
> From: Andrea Turli [mailto:andrea.turli@gmail.com]
> Sent: Saturday, November 29, 2014 9:31 AM
> To: user@jclouds.apache.org
> Subject: Re: assign a port on vm create?
>
> Hi Dan,
>
> could you please clarify which jclouds version are you using?
> which provider/api are you consuming?
> Is it a public openstack (I guess) endpoint or an on-premise installation?
> If the latter what services can you use?
>
> I think those are useful preliminary questions to get the context of your
> use case.
>
> Thanks,
> Andrea
>
> On Sat, Nov 29, 2014 at 4:53 PM, dan rusak <merlinlabs@rseincorp.com>
> wrote:
> > I need to assign static ips on VM creates. It appears that the only
> > way MAY be to use neutron to
> >
> > create a port and assign an ip there and assign the port to the VM.
> >
> > However when it came to assigning the port I could not find an
> > interface to accomplish that.
> >
> > Hopefully I am just missing seeing it.
> >
> > Doesn’t Jclouds support this? If it can be done from command line it
> > should be available
> >
> > programmatically?
> >
> >
> >
> > -d
>
>

Mime
View raw message