You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-11-03 17:13:17 +03:00
MCOL-547 - change to check for multiple ip address matches
This commit is contained in:
@@ -53,10 +53,11 @@
|
|||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <ifaddrs.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h> /* for strncpy */
|
#include <string.h> /* for strncpy */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
@@ -438,32 +439,40 @@ int main(int argc, char *argv[])
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
oam.getSystemConfig("pm1", moduleconfig);
|
oam.getSystemConfig("pm1", moduleconfig);
|
||||||
|
if (moduleconfig.hostConfigList.size() > 0 )
|
||||||
|
{
|
||||||
HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin();
|
HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin();
|
||||||
string PM1ipAdd = (*pt1).IPAddr;
|
string PM1ipAdd = (*pt1).IPAddr;
|
||||||
|
cout << PM1ipAdd << endl;
|
||||||
|
|
||||||
if ( PM1ipAdd != "127.0.0.1")
|
if ( PM1ipAdd != "127.0.0.1" && PM1ipAdd != "0.0.0.0")
|
||||||
{
|
{
|
||||||
// now get the local ip address
|
struct ifaddrs *ifap, *ifa;
|
||||||
int fd;
|
struct sockaddr_in *sa;
|
||||||
struct ifreq ifr;
|
char *addr;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
getifaddrs (&ifap);
|
||||||
|
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
|
||||||
|
if (ifa->ifa_addr->sa_family==AF_INET) {
|
||||||
|
sa = (struct sockaddr_in *) ifa->ifa_addr;
|
||||||
|
addr = inet_ntoa(sa->sin_addr);
|
||||||
|
printf("Interface: %s\tAddress: %s\n", ifa->ifa_name, addr);
|
||||||
|
|
||||||
/* I want to get an IPv4 IP address */
|
if ( PM1ipAdd == addr )
|
||||||
ifr.ifr_addr.sa_family = AF_INET;
|
{
|
||||||
|
//match
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* I want IP address attached to "eth0" */
|
if (found)
|
||||||
strncpy(ifr.ifr_name, "eth0", IFNAMSIZ-1);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ioctl(fd, SIOCGIFADDR, &ifr);
|
freeifaddrs(ifap);
|
||||||
|
|
||||||
close(fd);
|
if (!found)
|
||||||
|
|
||||||
string localIPAddr = inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr);
|
|
||||||
|
|
||||||
if ( PM1ipAdd != localIPAddr )
|
|
||||||
// configure pm1 and local ip address don't match, error out
|
|
||||||
// can only install from pm1
|
|
||||||
{
|
{
|
||||||
cout << endl;
|
cout << endl;
|
||||||
cout << "ERROR: postConfigure install can only be done on the PM1" << endl;
|
cout << "ERROR: postConfigure install can only be done on the PM1" << endl;
|
||||||
@@ -473,10 +482,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// run my.cnf upgrade script
|
// run my.cnf upgrade script
|
||||||
if ( reuseConfig == "y" )
|
if ( reuseConfig == "y" )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user