[GitHub] [cloudstack] svenvogel commented on a change in pull request #4070: Update cloud-set-guest-password.in

2020-05-19 Thread GitBox


svenvogel commented on a change in pull request #4070:
URL: https://github.com/apache/cloudstack/pull/4070#discussion_r427342669



##
File path: setup/bindir/cloud-set-guest-password.in
##
@@ -26,25 +26,58 @@
 # Modify this line to specify the user (default is root)
 user=root
 
-# Add your DHCP lease folders here
-DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+# Add network provider variables here (default means that interface for 
network manager is eth0)
+NETPLAN=/etc/netplan
+IFUPDOWN=/etc/network/interfaces
+NETMAN=/etc/sysconfig/network-scripts
+
+# Add dhcp variables
 PASSWORD_SERVER_PORT=8080
 password_received=0
-file_count=0
 error_count=0
+file_count=0
 
-for DHCP_FILE in $DHCP_FOLDERS; do
-   if [ -f $DHCP_FILE ]; then
-   file_count=$((file_count+1))
-   PASSWORD_SERVER_IP=$(grep dhcp-server-identifier $DHCP_FILE | 
tail -1 | awk '{print $NF}' | tr -d '\;')
+# OS is using netplan
+if [ -d "$NETPLAN" ]; then
+logger -t "cloud" "Operating System is using netplan"
 
-   if [ -n "$PASSWORD_SERVER_IP" ]; then
-   logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in $DHCP_FILE"
-break
-   fi
-   fi
-done
+PASSWORD_SERVER_IP=$(netplan ip leases eth0 | grep SERVER_ADDRESS | 
awk '{split($0,a,"="); print a[2]}')
+
+if [ -n "$PASSWORD_SERVER_IP" ]; then
+ logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in netplan config"
+fi
+fi
+
+# OS is using ifupdown
+if [ -f "$IFUPDOWN" ]; then
+logger -t "cloud" "Operating System is using ifupdown"
+
+DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+
+for DHCP_FILE in $DHCP_FOLDERS; do
+if [ -f $DHCP_FILE ]; then
+file_count=$((file_count+1))
+PASSWORD_SERVER_IP=$(grep dhcp-server-identifier 
$DHCP_FILE | tail -1 | awk '{print $NF}' | tr -d '\;')
+
+if [ -n "$PASSWORD_SERVER_IP" ]; then
+logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in $DHCP_FILE"
+break
+fi
+fi
+done
+fi
+
+# OS is using network interfaces
+if [ -d "$NETMAN" ]; then
+logger -t "cloud" "Operating System is using network manager"
+
+PASSWORD_SERVER_IP=$(nmcli -f IP4.GATEWAY device show eth0 | sed 's/ 
//g' | awk '{split($0,a,":"); print a[2]}')

Review comment:
   yes sounds good. did you test it? command is working fine. we are only 
use this for netplan and networkmanager otherwise we go the old way, so we dont 
break any existing functionality.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [cloudstack] svenvogel commented on a change in pull request #4070: Update cloud-set-guest-password.in

2020-05-19 Thread GitBox


svenvogel commented on a change in pull request #4070:
URL: https://github.com/apache/cloudstack/pull/4070#discussion_r427342669



##
File path: setup/bindir/cloud-set-guest-password.in
##
@@ -26,25 +26,58 @@
 # Modify this line to specify the user (default is root)
 user=root
 
-# Add your DHCP lease folders here
-DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+# Add network provider variables here (default means that interface for 
network manager is eth0)
+NETPLAN=/etc/netplan
+IFUPDOWN=/etc/network/interfaces
+NETMAN=/etc/sysconfig/network-scripts
+
+# Add dhcp variables
 PASSWORD_SERVER_PORT=8080
 password_received=0
-file_count=0
 error_count=0
+file_count=0
 
-for DHCP_FILE in $DHCP_FOLDERS; do
-   if [ -f $DHCP_FILE ]; then
-   file_count=$((file_count+1))
-   PASSWORD_SERVER_IP=$(grep dhcp-server-identifier $DHCP_FILE | 
tail -1 | awk '{print $NF}' | tr -d '\;')
+# OS is using netplan
+if [ -d "$NETPLAN" ]; then
+logger -t "cloud" "Operating System is using netplan"
 
-   if [ -n "$PASSWORD_SERVER_IP" ]; then
-   logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in $DHCP_FILE"
-break
-   fi
-   fi
-done
+PASSWORD_SERVER_IP=$(netplan ip leases eth0 | grep SERVER_ADDRESS | 
awk '{split($0,a,"="); print a[2]}')
+
+if [ -n "$PASSWORD_SERVER_IP" ]; then
+ logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in netplan config"
+fi
+fi
+
+# OS is using ifupdown
+if [ -f "$IFUPDOWN" ]; then
+logger -t "cloud" "Operating System is using ifupdown"
+
+DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+
+for DHCP_FILE in $DHCP_FOLDERS; do
+if [ -f $DHCP_FILE ]; then
+file_count=$((file_count+1))
+PASSWORD_SERVER_IP=$(grep dhcp-server-identifier 
$DHCP_FILE | tail -1 | awk '{print $NF}' | tr -d '\;')
+
+if [ -n "$PASSWORD_SERVER_IP" ]; then
+logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in $DHCP_FILE"
+break
+fi
+fi
+done
+fi
+
+# OS is using network interfaces
+if [ -d "$NETMAN" ]; then
+logger -t "cloud" "Operating System is using network manager"
+
+PASSWORD_SERVER_IP=$(nmcli -f IP4.GATEWAY device show eth0 | sed 's/ 
//g' | awk '{split($0,a,":"); print a[2]}')

Review comment:
   yes sounds good. did you test it?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [cloudstack] svenvogel commented on a change in pull request #4070: Update cloud-set-guest-password.in

2020-05-19 Thread GitBox


svenvogel commented on a change in pull request #4070:
URL: https://github.com/apache/cloudstack/pull/4070#discussion_r427165827



##
File path: setup/bindir/cloud-set-guest-password.in
##
@@ -26,25 +26,58 @@
 # Modify this line to specify the user (default is root)
 user=root
 
-# Add your DHCP lease folders here
-DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+# Add network provider variables here (default means that interface for 
network manager is eth0)
+NETPLAN=/etc/netplan
+IFUPDOWN=/etc/network/interfaces
+NETMAN=/etc/sysconfig/network-scripts
+
+# Add dhcp variables
 PASSWORD_SERVER_PORT=8080
 password_received=0
-file_count=0
 error_count=0
+file_count=0
 
-for DHCP_FILE in $DHCP_FOLDERS; do
-   if [ -f $DHCP_FILE ]; then
-   file_count=$((file_count+1))
-   PASSWORD_SERVER_IP=$(grep dhcp-server-identifier $DHCP_FILE | 
tail -1 | awk '{print $NF}' | tr -d '\;')
+# OS is using netplan
+if [ -d "$NETPLAN" ]; then
+logger -t "cloud" "Operating System is using netplan"
 
-   if [ -n "$PASSWORD_SERVER_IP" ]; then
-   logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in $DHCP_FILE"
-break
-   fi
-   fi
-done
+PASSWORD_SERVER_IP=$(netplan ip leases eth0 | grep SERVER_ADDRESS | 
awk '{split($0,a,"="); print a[2]}')
+
+if [ -n "$PASSWORD_SERVER_IP" ]; then
+ logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in netplan config"
+fi
+fi
+
+# OS is using ifupdown
+if [ -f "$IFUPDOWN" ]; then
+logger -t "cloud" "Operating System is using ifupdown"
+
+DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+
+for DHCP_FILE in $DHCP_FOLDERS; do
+if [ -f $DHCP_FILE ]; then
+file_count=$((file_count+1))
+PASSWORD_SERVER_IP=$(grep dhcp-server-identifier 
$DHCP_FILE | tail -1 | awk '{print $NF}' | tr -d '\;')
+
+if [ -n "$PASSWORD_SERVER_IP" ]; then
+logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in $DHCP_FILE"
+break
+fi
+fi
+done
+fi
+
+# OS is using network interfaces
+if [ -d "$NETMAN" ]; then
+logger -t "cloud" "Operating System is using network manager"
+
+PASSWORD_SERVER_IP=$(nmcli -f IP4.GATEWAY device show eth0 | sed 's/ 
//g' | awk '{split($0,a,":"); print a[2]}')

Review comment:
   let me test but i think this sound not bad ... we pick the default is an 
good idea :)





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [cloudstack] svenvogel commented on a change in pull request #4070: Update cloud-set-guest-password.in

2020-05-15 Thread GitBox


svenvogel commented on a change in pull request #4070:
URL: https://github.com/apache/cloudstack/pull/4070#discussion_r425837374



##
File path: setup/bindir/cloud-set-guest-password.in
##
@@ -26,25 +26,58 @@
 # Modify this line to specify the user (default is root)
 user=root
 
-# Add your DHCP lease folders here
-DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+# Add network provider variables here (default means that interface for 
network manager is eth0)
+NETPLAN=/etc/netplan
+IFUPDOWN=/etc/network/interfaces
+NETMAN=/etc/sysconfig/network-scripts
+
+# Add dhcp variables
 PASSWORD_SERVER_PORT=8080
 password_received=0
-file_count=0
 error_count=0
+file_count=0
 
-for DHCP_FILE in $DHCP_FOLDERS; do
-   if [ -f $DHCP_FILE ]; then
-   file_count=$((file_count+1))
-   PASSWORD_SERVER_IP=$(grep dhcp-server-identifier $DHCP_FILE | 
tail -1 | awk '{print $NF}' | tr -d '\;')
+# OS is using netplan
+if [ -d "$NETPLAN" ]; then
+logger -t "cloud" "Operating System is using netplan"
 
-   if [ -n "$PASSWORD_SERVER_IP" ]; then
-   logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in $DHCP_FILE"
-break
-   fi
-   fi
-done
+PASSWORD_SERVER_IP=$(netplan ip leases eth0 | grep SERVER_ADDRESS | 
awk '{split($0,a,"="); print a[2]}')
+
+if [ -n "$PASSWORD_SERVER_IP" ]; then
+ logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in netplan config"
+fi
+fi
+
+# OS is using ifupdown
+if [ -f "$IFUPDOWN" ]; then
+logger -t "cloud" "Operating System is using ifupdown"
+
+DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+
+for DHCP_FILE in $DHCP_FOLDERS; do
+if [ -f $DHCP_FILE ]; then
+file_count=$((file_count+1))
+PASSWORD_SERVER_IP=$(grep dhcp-server-identifier 
$DHCP_FILE | tail -1 | awk '{print $NF}' | tr -d '\;')
+
+if [ -n "$PASSWORD_SERVER_IP" ]; then
+logger -t "cloud" "Found password server IP 
$PASSWORD_SERVER_IP in $DHCP_FILE"
+break
+fi
+fi
+done
+fi
+
+# OS is using network interfaces
+if [ -d "$NETMAN" ]; then
+logger -t "cloud" "Operating System is using network manager"
+
+PASSWORD_SERVER_IP=$(nmcli -f IP4.GATEWAY device show eth0 | sed 's/ 
//g' | awk '{split($0,a,":"); print a[2]}')

Review comment:
   maybe a stupid solution like, if we have more than one interface and use 
only show and grep/regex for an ip
   
   ```shell
   nmcli -f IP4.GATEWAY device show | ...regex...





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [cloudstack] svenvogel commented on a change in pull request #4070: Update cloud-set-guest-password.in

2020-05-15 Thread GitBox


svenvogel commented on a change in pull request #4070:
URL: https://github.com/apache/cloudstack/pull/4070#discussion_r425831392



##
File path: setup/bindir/cloud-set-guest-password.in
##
@@ -26,25 +26,58 @@
 # Modify this line to specify the user (default is root)
 user=root
 
-# Add your DHCP lease folders here
-DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+# Add network provider variables here (default means that interface for 
network manager is eth0)
+NETPLAN=/etc/netplan
+IFUPDOWN=/etc/network/interfaces
+NETMAN=/etc/sysconfig/network-scripts/ifcfg-eth0

Review comment:
   maybe grep from "ip command" or "nmcli" command the interface for your 
script. i think we should not change the user. so we want to change the root 
password.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [cloudstack] svenvogel commented on a change in pull request #4070: Update cloud-set-guest-password.in

2020-05-15 Thread GitBox


svenvogel commented on a change in pull request #4070:
URL: https://github.com/apache/cloudstack/pull/4070#discussion_r425820747



##
File path: setup/bindir/cloud-set-guest-password.in
##
@@ -26,25 +26,58 @@
 # Modify this line to specify the user (default is root)
 user=root
 
-# Add your DHCP lease folders here
-DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+# Add network provider variables here (default means that interface for 
network manager is eth0)
+NETPLAN=/etc/netplan
+IFUPDOWN=/etc/network/interfaces
+NETMAN=/etc/sysconfig/network-scripts/ifcfg-eth0

Review comment:
   @dimsijul 
   
   > Hi Sven,
   > 
   > I see what you mean. Yes, I'll do the change to base the detection on the 
folder. I think the same kind of issue would apply to the netplan command 
though, if the interface is not declared as eth0 in the netplan config...
   
   sounds good.
   
   
   
   > Also, I think that maybe we should do the same as the account to target in 
:
   > 
   > Modify this line to specify the user (default is root)
   > user=root
   > 
   > with maybe :
   > 
   > Modify this line to specify the network interface (default is eth0)
   > netinterface=eth0
   > 
   > and use that variable in netplan and nmcli commands.
   > 
   > What do you think ?
   
   ~~maybe i thread lost... what do you mean with modify user=root and 
netinterface=eth0... maybe you can ... you mean to specify the first 
interface?~~
   
   i see what you mean. yes we should use a variable for the interface but 
maybe its better to grep the interface. we dont send the interface to the 
machine so we need to find it out.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [cloudstack] svenvogel commented on a change in pull request #4070: Update cloud-set-guest-password.in

2020-05-15 Thread GitBox


svenvogel commented on a change in pull request #4070:
URL: https://github.com/apache/cloudstack/pull/4070#discussion_r425820747



##
File path: setup/bindir/cloud-set-guest-password.in
##
@@ -26,25 +26,58 @@
 # Modify this line to specify the user (default is root)
 user=root
 
-# Add your DHCP lease folders here
-DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*"
+# Add network provider variables here (default means that interface for 
network manager is eth0)
+NETPLAN=/etc/netplan
+IFUPDOWN=/etc/network/interfaces
+NETMAN=/etc/sysconfig/network-scripts/ifcfg-eth0

Review comment:
   @dimsijul 
   
   > Hi Sven,
   > 
   > I see what you mean. Yes, I'll do the change to base the detection on the 
folder. I think the same kind of issue would apply to the netplan command 
though, if the interface is not declared as eth0 in the netplan config...
   
   sounds good.
   
   
   
   > Also, I think that maybe we should do the same as the account to target in 
:
   > 
   > Modify this line to specify the user (default is root)
   > user=root
   > 
   > with maybe :
   > 
   > Modify this line to specify the network interface (default is eth0)
   > netinterface=eth0
   > 
   > and use that variable in netplan and nmcli commands.
   > 
   > What do you think ?
   
   maybe i thread lost... what do you mean with modify user=root and 
netinterface=eth0... maybe you can ... you mean to specify the first interface?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org