Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Fixes EUCA-12546
Browse files Browse the repository at this point in the history
Change the way the hostname and ip are collected for purposes of ebs volume detachment.
  • Loading branch information
Jeremy Breiding committed Jul 8, 2016
1 parent 0f8907a commit 77793a7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions storage/euca_volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ int loop_through_volumes(const char *xml_path, eucaVolume volumes[EUCA_MAX_VOLUM
MKVOLPATH("devName");
XGET_STR_FREE(volxpath, v->device);
MKVOLPATH("libvirt");
if (strcmp(v->state, "attaching") && get_xpath_xml(xml_path, volxpath, v->libvirt_XML, sizeof(v->libvirt_XML)) != EUCA_OK) {
if ((strcmp(v->state, VOL_STATE_ATTACHING) == 0 || strcmp(v->state, VOL_STATE_ATTACHING_FAILED) == 0) && get_xpath_xml(xml_path, volxpath, v->libvirt_XML, sizeof(v->libvirt_XML)) != EUCA_OK) {
fprintf(stderr, "failed to read '%s' from '%s'\n", volxpath, xml_path);
for (int z = 0; res_array[z] != NULL; z++)
EUCA_FREE(res_array[z]);
Expand Down Expand Up @@ -467,7 +467,14 @@ char *find_instance_path(const char* instance_paths, const char *instance_id){
}


char *find_ip_addr(const char* hostname){
char *find_ip_addr(void){
char hostname[HOSTNAME_SIZE];
if (gethostname(hostname, sizeof(hostname)) != 0) {
fprintf(stderr, "failed to find hostname\n");
return NULL;
}
fprintf(stderr, "Searching for IP by hostname %s\n", hostname);

struct addrinfo hints, *servinfo, *p;
struct sockaddr_in *h;
memset(&hints, 0, sizeof hints);
Expand Down Expand Up @@ -616,7 +623,7 @@ int main(int argc, char **argv)

loop_through_volumes(instance_xml, volumes);

ip = find_ip_addr(NULL);
ip = find_ip_addr();
iqn = find_local_iqn();

printf("Found local iqn=%s and local ip=%s\n", iqn, ip);
Expand Down

0 comments on commit 77793a7

Please sign in to comment.