how to get all IP in VNIC [Oracle Cloud Using API] - oracle

i have a instance related with VNIC in this VNIC I have 33 IP Adress but when i use GetVnic commande GET /20160918/vnics/{vnicId} it's return only one Adress IP ,
how i can to return all the ips ?

Please take a look at this script as an example on how you can do this.

Related

Google Compute API: new instance with external IP

I'm trying to dynamically create Compute instances on Google Cloud via PHP using API.
Using csmartinez Cloud API sample, I managed to create my instance and can see it running on Google Console.
I need to assign an external IP address to this newly created instance. Based on the API and Google PHP library, I then added:
$ipName = "foo";
$addr = new Google_Service_Compute_Address();
$addr->setName($ipName);
$response = $service->addresses->insert($project, $ipZone, $addr);
Since this call has a "pending" status at first, I added a sleep(5) so I can then get the newly created static IP:
$response = $service->addresses->get($project, $ipZone, $ipName);
$ip = $response->address;
which runs well and gives me the correct IP address. I then continue and try to create my instance while assigning the new IP:
$networkConfig = new Google_Service_Compute_AccessConfig();
$networkConfig->setNatIP($ip);
$networkConfig->setType("ONE_TO_ONE_NAT");
$networkConfig->setName("External NAT");
$googleNetworkInterfaceObj->setAccessConfigs($networkConfig);
The static IP is created, the instance is created, but IP is not assigned to the instance.
To remove my doubt about the pending status, I also tried to assign an already created static IP to my instance, thus using:
$networkConfig->setNatIP("xxx.xxx.xxx.xxx");
With no more success... What am I missing here ?
I think this line:
$googleNetworkInterfaceObj->setAccessConfigs($networkConfig);
should be:
$googleNetworkInterfaceObj->setAccessConfigs(array($networkConfig));
If this doesn't work, there might be another error somewhere else.
this would be the whole procedure, which assigns a network:
$instance = new Google_Instance();
$instance->setKind("compute#instance");
$accessConfig = new Google_AccessConfig();
$accessConfig->setName("External NAT");
$accessConfig->setType("ONE_TO_ONE_NAT");
$network = new Google_NetworkInterface();
$network->setNetwork($this->getObjectUrl($networkName, 'networks', $environment->getPlatformConfigValue(self::PROJECT_ID)));
$network->setAccessConfigs(array($accessConfig));
$instance->setNetworkInterfaces(array($network));
$addr->setName() is barely cosmetic; try $addr->setAddress($ipAddress).
guess the Google_NetworkInterface would need the $addr assigned.
sorry, currently have no spare IP and do not want to pay only to provide code.

Setting address of whois service for ruby whois gem for IP addresses

A Connection to whois.arin.net is not open to us. Our network administrators say we should use 192.0.47.59 for our whois service.
In some cases I will have a DNS name, in other cases I will have an IP address. I want to get the whois information in either case. My network administrators have allowed access to a specific IP address for the whois service, and I have to use that IP address. The define method allows me to set the IP address of the whois service if I give it the TLD, but I have no way to get it work for IP addresses.
This is related to Setting address of whois service for ruby whois gem, but since I got a partial solution, I know how to call the service, so for my question specific to IP addresses I thought I would start over.
I need to set the address of our whois service. So for a DNS name:
> Whois.whois('wandajackson.com')
Whois::ConnectionError: Errno::EHOSTUNREACH: No route to host - connect(2) for "whois.verisign-grs.com" port 43
from (irb):4
> Whois::Server.define(:tld, 'com', '192.0.47.59')
=> ["com", "192.0.47.59", {}]
irb(main):006:0> Whois.whois('wandajackson.com')
# => #<Whois::Record>
However, I cannot get it to work for IP addresses.
> Whois::Server.define(:ipv4, '74.0.0.0/8', '192.0.47.59')
=> ["74.0.0.0/8", "192.0.47.59", {}]
> Whois.whois('74.220.215.203')
Whois::ConnectionError: Errno::EHOSTUNREACH: No route to host - connect(2) for "whois.arin.net" port 43
from (irb):7
> Whois::Server.define(:ipv6, '2607::/8', '192.0.47.59')
=> ["2607::/8", "192.0.47.59", {}]
> Whois.whois('2607:f8b0:4004:800::200e')
Whois::ConnectionError: Errno::EHOSTUNREACH: No route to host - connect(2) for "whois.arin.net" port 43
from (irb):9
I'm sorry to say but that is a bug with missing 74.0.0.0/8 assigment & if you create your own it is probably not correctly searched for in the defined list thus => The assigment according to IP does not currently work.
Why?
You can check the list and find out which ranges are assigned to ARIN:
Whois::Server.definitions(:ipv4).each { |records| p "IP range #{records[0]}" if records[1] = 'whois.arin.net'}
First without any changes you check your IP address:
Whois::Server.find_for_ip("74.220.215.203")
=> #<Whois::Server::Adapters::Arin:0x00000000030244c0 #type=:ipv4, #allocation="0.0.0.0/1", #host="whois.arin.net", #options={}>
As you can see the record is not found at the authorities so it goes to a fallback 0.0.0.0/1 which is set for whois.arin.net.
I tried to set fatory (gets somehow ignored) and define:
Whois::Server.factory :ipv4, "74.0.0.0/8", "whois.iana.org", :option => Whois::Server::Adapters::Standard
define worked:
Whois::Server.define :ipv4, "74.0.0.0/8", "whois.iana.org"
... , {}], ["222.120.0.0/15", "whois.nic.or.kr", {}], ["222.122.0.0/16",
"whois.nic.or.kr", {}], ["222.232.0.0/13", "whois.nic.or.kr", {}],
["220.0.0.0/6", "whois.apnic.net", {}], ["74.0.0.0/8",
"whois.iana.org", {}]]
As you can see there is assigment of
["74.0.0.0/8",
> "whois.iana.org", {}]]
so you should be able to query IANA now? It appears you are not:
Whois::Server.find_for_ip("74.220.215.203")
=> #<Whois::Server::Adapters::Arin:0x000000000434c250 #type=:ipv4, #allocation="0.0.0.0/1", #host="whois.arin.net", #options={}>
As you can see the #allocation is still getting "0.0.0.0/1" and not 74.0.0.0/8. Why? That I don't know yet. Probably some bug either on searching or finding the correct Object.
Everything is lost? Not really, there is rather simple workaround but you have to understand the implications.
Workaround
If you define your fallback address via:
Whois::Server.define :ipv4, "0.0.0.0/1", "whois.iana.org"
Everything starts to work. Now all the fallback queries will be done via IANA, which should not be a problem in your case as you can't reach ARIN anyways.
Now if you query via IP adddress you get correct results:
Whois::Server.find_for_ip("74.220.215.203")
=> #<Whois::Server::Adapters::Standard:0x000000000351c298 #type=:ipv4, #allocation="0.0.0.0/1", #host="whois.iana.org", #options={}>
Whois.whois("74.220.215.203")
=> "% IANA WHOIS server\n% for more information on IANA, visit http://www.iana.org\n% This query returned 1 object\n\nrefer: whois.arin.net\n\ninetnum:
74.0.0.0 - 74.255.255.255\norganisation: ARIN\nstatus: ALLOCATED\n\nwhois: whois.arin.net\n\nchanged: 2005-06\nsource: IANA\n\n"

JClouds: How Do You Ask For an AWS-EC2 Public IP Address

When using Apache JClouds, how do you get launch a compute instance with a public IP? This is different from an elastic IP. Using the official AWS API you can do something like:
//create network information
InstanceNetworkInterfaceSpecification networkWithPublicIp = new InstanceNetworkInterfaceSpecification()
.withSubnetId(subnetId)
.withAssociatePublicIpAddress(true)
.withGroups( securityGroupIds )
.withDeviceIndex(0);
Once the node is launched, it will have a randomly assigned public IP (not elastic). Is there a way to do this with Jclouds and AWSEC2TemplateOptions?
There is an example in the doc at http://jclouds.apache.org/guides/aws/
// ex. to get an ip and associate it with a node
String ip = ec2Client.getElasticIPAddressServices().allocateAddressInRegion(node.getLocation().getId());
ec2Client.getElasticIPAddressServices().associateAddressInRegion(node.getLocation().getId(),ip, node.getProviderId());

How can I get mobile node IP address in OPNET 14.5?

I tried the following code in OPNET Modeler 14.5
Objid addr_info_attr_objid;
char address_string[128];
addr_info_attr_objid = op_id_self();
op_ima_obj_attr_get(addr_info_attr_objid, "Address", address_string);
to get the node IP Address but it gives this error message:
<<<Recoverable Error>>>
Attribute name(Address) is unrecognizzed for object(542)
You have to find the proper IP interface First.
Based on your code, it is not right way to get IP address of one-interface node, such as Server/Client model.
Here is sample code
op_ima_obj_attr_get(ip_moudle_objid, "IP Router Parameters [0].Interface Information [3].Address", &address_str);

how to get an aws instance given I have the instance's ip

Given I have an aws instance IP, how can I get the EC2 instance collection object via the ruby aws-sdk's filter option. For example
#ec2.instances.filter(valid_filter_name, ec2_instance_ip)
I've tried 'public_ip_address' and 'public_ip' as the filter name but those didn't work. I'm using this API doc http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/FilteredCollection.html#filter-instance_method, but it's does not mentioned what the valid parameters are.
It turns out the correct parameter to use (by trial & error) is 'ip-address'. Here's an example:
#ec2.instances.filter('ip-address', ec2_instance_ip)

Resources