Softlayer: determine scsi disk Softlayer-ID using the dev mapper device id - centos7

In a setup of a multiple iscsi disks attached to a Linux host (LVM pools setup), I want to be able to take a snapshot of a specific disk, using Softlayer API.
How can I know the id or the LUN name of the iscsi device from the Linux device name.
For example - get "SLXXXXXXXXX-XX" from "/dev/mapper/YYYYYYYYYYYYYYp1".
I tried resolving the Iscsi target Ip, but it's possible that different disks have same target ip, so I have to figure out a different solution

Using these REST requests you can retrieve the ISCSI id, and LUN id of the device and its parent for those BMS and Virtual Guests that have any.
https://[username]:[apiKey]#api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests.json?objectMask=mask[allowedNetworkStorage[lunId,parentVolume[lunId]]]&objectFilter={"virtualGuests":{"allowedNetworkStorage":{"nasType":{"operation":"ISCSI"}}}}
Method: GET
https://[username]:[apiKey]#api.softlayer.com/rest/v3/SoftLayer_Account/getHardware.json?objectMask=mask[allowedNetworkStorage[lunId,parentVolume[lunId]]]&objectFilter={"hardware":{"allowedNetworkStorage":{"nasType":{"operation":"ISCSI"}}}}
Method: GET
This link might help you for further implementation:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Storage_Iscsi
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage_Iscsi

Related

How does a website detect devices on your local network

I have a HD Home Run device, and when I go to http://my.hdhomerun.com/ I am able to see the HD Home Run device I have listed on my network listed along with the local IP address of the unit. How is this possible? My goal is to implement something similar in a product that I am developing.
I did some digging and found that it is able to generate the data from a json file at http://ipv4-api.hdhomerun.com/discover, but was not able to trace how this json file was generated.
When a device connects to another node or machine it automatically sends machine details to help with compatibility.

Restricting number of devices on rails

I'm working on a rails project and I would ideally like to restrict each user to only be able to access my application with 2 devices (in order to limit username & password sharing). I am currently using Devise for user authentication. I've researched this through SO and the Devise documentation, but haven't found any solutions yet. Surely I can't be the first person with this need. Anyone have any ideas on how this could be accomplished?
You can do this with storing your device unique id in database.
Create a separate table where you can store your logged in device id and check when authentication.
For a hardware dependent identification key, we can also use a MAC address.
A Media Access Control address (MAC address) is a unique identifier
assigned to network interfaces for communications on the physical
network segment. MAC addresses are most often assigned by the
manufacturer of a network interface card (NIC) and are stored in its
hardware, the card's read-only memory, or some other firmware
mechanism. [wikipedia]
Here is a gem for finding mac address:
https://github.com/ahoward/macaddr

How to programatically add an IP printer present in a network to a windows machine using VC++ and Windows API's

On a windows system, Is it possible to programatically Add/Edit/Delete an IP Printer present in the network to any machine present in the same network ???
I can see on MSDN about Printer Spooler API's AddPrinter(), DeletePrinter(), SetPrinterData() and other functions to do the same.
So, say if IP of the IP Printer is 192.168.1.252 then how to Add it on a machine 192.168.1.30 present in the same network ?
The driver of the printer is not installed on 192.168.1.30 and I know only the IP and the Port the IP Printer is installed on.
I did google a lot but did not get a solution.

How to connect to a Wifi that requests for a network security key using Windows Native Wifi Functions?

I'm developing a way to connect to a Wifi using VS2010 and currently stuck on how to make it connect with a network security key. I am able to enumerate all the Wifi hotspot in my area and get their SSID, MAC addresses, etc using Windows Native Wifi Functions (WlanOpenHandle, WlanEnumInterfaces, WlanQueryInterface, WlanGetNetworkBssList). I've already read about WlanConnect() on MSDN but I'm still clueless. Can you give me some hints that would make the code connect to a Wifi that asks for a network security key?
Assuming you have at least one saved Wifi connection run the command
netsh wlan export profile
This will export all your Wifi profiles as XML files in the current directory.
When you call WlanConnect you can supply a literal XML profile string in the WLAN_CONNECTION_PARAMETERS structure if wLanConnectionMode is set to wlan_connection_mode_temporary_profile.
If you can use the XML from one of your exported profiles to connect successfully to a secured network, then presumably you should be able to alter the XML and use the same technique to connect to new networks.
I've never tried this, and I've no idea what encoding is used for the key stored in the XML, but it seems like a possible way of solving your problem.
You will need an example profile to start with, as arx had suggested.
When exporting a profile, add the key=clear arg. This will export the profile with the key in it. You can than see the setup that you would need to adjust.
Example : netsh wlan export profile name=”<profileName>” folder=”<SaveLocation>” key=clear
The resulting xml will contain a section with:
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>YourPaswordTextHERE</keyMaterial>
</sharedKey>
</security>
</MSM>
So once you have your profile string, update the keyMaterial element with your programmatically obtained password. Once this is done you should be able to call wlanConnect.

Detecting IP addresses of network cards and ethernet devices with Windows API

I am using the Microsoft code here to learn how to detect IP addresses of cards and devices:
http://msdn.microsoft.com/en-us/library/aa365949%28v=VS.85%29.aspx
I notice some strange behavior.
I have a system with two ethernet cards; one is connected to the internet and one is connected to an ethernet device. When I run the sample code, it will always give an IP address for the card that has the internet connection, but the other card will come up as 127.0.0.1 with a subnet mask of 255.0.0.0 unless I have the ethernet device plugged in and powered. But the card should have a default IP address whether its actually connected to anything, right? How can I modify this code to detect that?
There's a third IP address detected that appears to be just empty data. I tried this on another computer with a single network connection and it also detected a second, non-existent connection. Each time, this connection has an IP address of 127.0.0.1 and a subnet mask of 255.0.0.0. What does this represent?
Given the demo code, would this be easy to edit to be able to detect IP addresses of devices on the network that any card is connected to? I really just want to detect the IP address that a single ethernet device is set to. The device is directly connected to the card. The reason I want to do this is because the device and card obviously don't play nice when their subnets are different and I want to detect when this is the case.
Thanks!
R
That address of 127.0.0.1 is not the address of the other card. It is the address of the loopback adapter - a virtual IP address that can only send and receive data with itself. The other NIC (that isn't plugged into a network) is simply not in the address table.
You may just want to call GetAdapterAddresses and filter out all adapters with an IFType of IF_TYPE_SOFTWARE_LOOPBACK.
If you want to see use existing tools that provide the same thing, type either of the following from a command prompt:
route print
(This will dump the routing table)
ipconfig /all
(this will show you the state of ALL adapters including the loopback)
Dunno exactly, you should at least specify your configuration, is it DHCP or static IP, or something else?
It's the loopback interface
Some broadcasting may be required. ARP is the link-layer protocol, so it can be used without the IP address to broadcast a link to find the devices and then to detect their address. Don't know about windows precisely, but on Unix an arping command is present for this.