From: "Tejesh M" <tejeshmk(a)gmail.com>
To: "Moti Asayag" <masayag(a)redhat.com>
Cc: "users(a)oVirt.org" <users(a)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]
On Mon, Feb 24, 2014 at 5:23 PM, Moti Asayag <masayag(a)redhat.com> wrote:
>
>
> ----- Original Message -----
> > From: "Tejesh M" <tejeshmk(a)gmail.com>
> > To: "Moti Asayag" <masayag(a)redhat.com>
> > Cc: "users(a)oVirt.org" <users(a)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-o...
>
> It should achieve what you're aiming for.
>
> >
> > On Mon, Feb 24, 2014 at 4:11 PM, Moti Asayag <masayag(a)redhat.com> wrote:
> >
> > > ----- Original Message -----
> > > > From: "Tejesh M" <tejeshmk(a)gmail.com>
> > > > To: "Moti Asayag" <masayag(a)redhat.com>
> > > > Cc: "users(a)oVirt.org" <users(a)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-o...
> > >
> > > >
> > > > 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(a)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(a)redhat.com>
> > > wrote:
> > > > >
> > > > >> h
> > > > >>
> > > > >> ----- Original Message -----
> > > > >> > From: "Tejesh M" <tejeshmk(a)gmail.com>
> > > > >> > To: "users(a)oVirt.org"
<users(a)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(a)ovirt.org
> > > > >> >
http://lists.ovirt.org/mailman/listinfo/users
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks & Regards
> > > > > Tejesh
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Thanks & Regards
> > > > Tejesh
> > > >
> > >
> >
> >
> >
> > --
> > Thanks & Regards
> > Tejesh
> >
>
--
Thanks & Regards
Tejesh