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.shoy...@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.tu...@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" <merlinl...@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.tu...@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 <merlinl...@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



Reply via email to