[Users] Creating Logical Network issue - API

Moti Asayag masayag at redhat.com
Mon Mar 3 14:44:42 UTC 2014



----- Original Message -----
> From: "Tejesh M" <tejeshmk at gmail.com>
> To: "Moti Asayag" <masayag at redhat.com>
> Cc: "users at oVirt.org" <users at ovirt.org>
> Sent: Monday, March 3, 2014 4:36:32 PM
> Subject: Re: [Users] Creating Logical Network issue - API
> 
> Ok got it..
> I just observed that my setup network is not getting saved, after attaching
> my logical network to host nic.
> 

Let me refer you to yet another post [1]:

You should add the following at the end of your setup-networks action:

api.getHosts().get("your-host").commitnetconfig(new Action());

[1] https://motiasayag.wordpress.com/2013/04/08/it-is-not-over-till-moti-sings/


> 
> On Mon, Mar 3, 2014 at 7:34 PM, Moti Asayag <masayag at redhat.com> wrote:
> 
> >
> >
> > ----- Original Message -----
> > > From: "Tejesh M" <tejeshmk at gmail.com>
> > > To: "Moti Asayag" <masayag at redhat.com>
> > > Cc: "users at oVirt.org" <users at ovirt.org>
> > > Sent: Monday, March 3, 2014 3:46:14 PM
> > > Subject: Re: [Users] Creating Logical Network issue - API
> > >
> > > Thanks, I'm able to create logical network & attached the same to host.
> > >
> > > Now I tried to change the network for a VM nic from rhevm to VLAN1189,
> > but
> > > it is not working. any suggestion?
> > >
> > >
> > >
> > api.getVMs().get(vmName).getNics().get("nic1").setNetwork(api.getNetworks().get("VLAN1189"));
> > >           api.getVMs().get(vmName).getNics().get("nic1").update();
> > >
> >
> > This snippet is wrong: You attempt to modify a newly fetched
> > vnic than the one that was just modified in the first line.
> >
> > I'd try:
> >  VMNIC vnic = api.getVMs().get(vmName).getNics().get("nic1");
> >  vnic.setNetwork(api.getNetworks().get("VLAN1189"));
> >  vnic.update();
> >
> > If this doesn't work - keep reading :-)
> >
> > There has been a recent bug in this regards [1].
> >
> > You can by pass it by nullifying the vnic-profile value until getting the
> > next stable version (or using the 3.4 rc build).
> >
> > You can read more about the vnic profile and see python examples here [2]
> >
> > [1] https://bugzilla.redhat.com/show_bug.cgi?id=1047887
> > Bug 1047887 - Update vnic_profile fails for VM vnic
> >
> > [2] https://motiasayag.wordpress.com/2014/02/02/vnic-profiles/
> >
> > >
> > >
> > >
> > > On Mon, Feb 24, 2014 at 5:23 PM, Moti Asayag <masayag at redhat.com> wrote:
> > >
> > > >
> > > >
> > > > ----- Original Message -----
> > > > > From: "Tejesh M" <tejeshmk at gmail.com>
> > > > > To: "Moti Asayag" <masayag at redhat.com>
> > > > > Cc: "users at oVirt.org" <users at ovirt.org>
> > > > > Sent: Monday, February 24, 2014 1:18:53 PM
> > > > > Subject: Re: [Users] Creating Logical Network issue - API
> > > > >
> > > > > The example updates the existing Network (i.e. if the Logical
> > Network is
> > > > > already mapped to eth1). But what i'm looking for is how to map
> > Logical
> > > > > Network "ApiNetWork" to "eth1", please refer screenshot.
> > > > >
> > > >
> > > > Please check the last example named "AddNetworkToNic" from
> > > >
> > > >
> > https://motiasayag.wordpress.com/2014/02/24/network-configuration-using-ovirt-engine-java-sdk/
> > > >
> > > > It should achieve what you're aiming for.
> > > >
> > > > >
> > > > > On Mon, Feb 24, 2014 at 4:11 PM, Moti Asayag <masayag at redhat.com>
> > wrote:
> > > > >
> > > > > > ----- Original Message -----
> > > > > > > From: "Tejesh M" <tejeshmk at gmail.com>
> > > > > > > To: "Moti Asayag" <masayag at redhat.com>
> > > > > > > Cc: "users at oVirt.org" <users at ovirt.org>
> > > > > > > Sent: Monday, February 24, 2014 11:59:42 AM
> > > > > > > Subject: Re: [Users] Creating Logical Network issue - API
> > > > > > >
> > > > > > > While setting Logical Network, it fails with below error:
> > > > > > > code  : 400
> > > > > > > reason: Bad Request
> > > > > > > detail: Previous network name is required.
> > > > > >
> > > > > > See an example in the following post:
> > > > > >
> > > > > >
> > > > > >
> > > >
> > https://motiasayag.wordpress.com/2014/02/24/network-configuration-using-ovirt-engine-java-sdk/
> > > > > >
> > > > > > >
> > > > > > > Code:
> > > > > > >           String nw_name="ApiNetWork";
> > > > > > >           org.ovirt.engine.sdk.decorators.Host hst =
> > > > > > > api.getHosts().get("rhevhost");
> > > > > > >
> > > > > > >
> > > >
> > hst.getHostNics().get("eth1").setNetwork(api.getNetworks().get(nw_name));
> > > > > > >
> > //hst.getHostNics().get("eth1").setCheckConnectivity(true);
> > > > > > >
> > > > //hst.getHostNics().get("eth1").setOverrideConfiguration(true);
> > > > > > >           hst.getHostNics().get("eth1").update();
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Mon, Feb 24, 2014 at 2:30 PM, Tejesh M <tejeshmk at gmail.com>
> > > > wrote:
> > > > > > >
> > > > > > > > Can you tel me how do i assign Logical Network(s) to one of the
> > > > > > Physical
> > > > > > > > Nic on the Host.
> > > > > > > >
> > > > > > > >
> > > > > > > > On Fri, Feb 21, 2014 at 1:37 PM, Moti Asayag <
> > masayag at redhat.com>
> > > > > > wrote:
> > > > > > > >
> > > > > > > >> h
> > > > > > > >>
> > > > > > > >> ----- Original Message -----
> > > > > > > >> > From: "Tejesh M" <tejeshmk at gmail.com>
> > > > > > > >> > To: "users at oVirt.org" <users at ovirt.org>
> > > > > > > >> > Sent: Thursday, February 20, 2014 11:48:56 AM
> > > > > > > >> > Subject: [Users] Creating Logical Network issue - API
> > > > > > > >> >
> > > > > > > >> > Hi ,
> > > > > > > >> >
> > > > > > > >> > I'm trying to create Logical Network and assign it to
> > cluster &
> > > > > > want to
> > > > > > > >> bond
> > > > > > > >> > this to one of the Network Interface on Host. so that i can
> > > > isolate
> > > > > > my
> > > > > > > >> VM
> > > > > > > >> > from other networks.
> > > > > > > >> >
> > > > > > > >> > The issue is even if i set Cluster while creating Logical
> > > > Network,
> > > > > > it
> > > > > > > >> is not
> > > > > > > >> > setting the cluster. In Web Admin it is in unset state.
> > > > > > > >> >
> > > > > > > >> > Also, let me know how do i bind this Logical network on Host
> > > > > > Interface.
> > > > > > > >> >
> > > > > > > >> > Java code:
> > > > > > > >> >
> > > > > > > >> > Network nw1=new Network();
> > > > > > > >> > VLAN vlan = new VLAN();
> > > > > > > >> > vlan.setId(2000);
> > > > > > > >> > nw1.setVlan(vlan);
> > > > > > > >> > IP ip = new IP();
> > > > > > > >> > ip.setAddress("192.168.1.151");
> > > > > > > >> > ip.setGateway("192.168.1.1");
> > > > > > > >> > ip.setNetmask("255.255.255.0");
> > > > > > > >>
> > > > > > > >> Note that the stated IP above will not be used to set the
> > address
> > > > on
> > > > > > the
> > > > > > > >> host itself.
> > > > > > > >> In order to do so you should use either the 'setup networks'
> > api
> > > > on
> > > > > > > >> host's nics level.
> > > > > > > >> (Alternately, you can send POST request to
> > /hosts/{host:id}/nics
> > > > which
> > > > > > > >> utilize the
> > > > > > > >> former api (it is a bit simpler than using the setup networks
> > > > api).
> > > > > > > >>
> > > > > > > >> Should look like:
> > > > > > > >>     Host host = api.getHosts().get("host_name");
> > > > > > > >>     Action action = new Action();
> > > > > > > >>     action.setCheckConnectivity(true); //required for
> > rollback in
> > > > > > case of
> > > > > > > >> configuration failure
> > > > > > > >>     action.setHostNics(...); // should contain the target
> > > > > > configuration
> > > > > > > >>     host.getHostNics().setupnetworks(action);
> > > > > > > >>
> > > > > > > >> where the action should contain the entire desired network
> > > > > > configuration.
> > > > > > > >>
> > > > > > > >> You can find various python-sdk example for setup networks on
> > my
> > > > blog
> > > > > > [1]
> > > > > > > >> I'll post few examples using the java sdk earlier next week.
> > > > > > > >>
> > > > > > > >> [1] https://motiasayag.wordpress.com/
> > > > > > > >>
> > > > > > > >> > nw1.setIp(ip);
> > > > > > > >> > nw1.setName("apiNetwork");
> > > > > > > >> >
> > > > > > > >> > nw1.setDataCenter(api.getDataCenters().get("testDC"));
> > > > > > > >> > nw1.setCluster(api.getClusters().get("testCluster"));
> > > > > > > >> >
> > > > > > > >> > org.ovirt.engine.sdk.decorators.Network nw2 =
> > > > > > > >> api.getNetworks().add(nw1);
> > > > > > > >> >
> > > > > > > >> > --
> > > > > > > >> > Thanks & Regards
> > > > > > > >> > Tejesh
> > > > > > > >> >
> > > > > > > >> > _______________________________________________
> > > > > > > >> > Users mailing list
> > > > > > > >> > Users at ovirt.org
> > > > > > > >> > http://lists.ovirt.org/mailman/listinfo/users
> > > > > > > >> >
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Thanks & Regards
> > > > > > > > Tejesh
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Thanks & Regards
> > > > > > > Tejesh
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks & Regards
> > > > > Tejesh
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks & Regards
> > > Tejesh
> > >
> >
> 
> 
> 
> --
> Thanks & Regards
> Tejesh
> 



More information about the Users mailing list