Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing guest Restore point requests to native path #1873

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0011cd4
removed sudo
arisettisanjana May 15, 2023
d89fbfd
Revert "removed sudo"
arisettisanjana May 15, 2023
085b60d
Merge branch 'Azure:master' into master
arisettisanjana May 15, 2023
6e02140
Merge branch 'master' of https://github.com/arisettisanjana/azure-lin…
arisettisanjana May 16, 2023
df94315
Merge branch 'Azure:master' into master
arisettisanjana May 29, 2023
7f5c965
Merge branch 'master' of https://github.com/arisettisanjana/azure-lin…
arisettisanjana May 29, 2023
937870d
Merge branch 'Azure:master' into master
arisettisanjana Jun 5, 2023
2381fe8
Merge branch 'master' of https://github.com/arisettisanjana/azure-lin…
arisettisanjana Jun 5, 2023
4a2a67d
Merge branch 'Azure:master' into master
arisettisanjana Jul 17, 2023
a351b1e
Merge branch 'master' of https://github.com/arisettisanjana/azure-lin…
arisettisanjana Jul 17, 2023
82dd260
Merge branch 'Azure:master' into master
arisettisanjana Sep 4, 2023
56053e9
Merge branch 'Azure:master' into master
arisettisanjana Sep 7, 2023
469cbfd
Merge branch 'Azure:master' into master
arisettisanjana Sep 19, 2023
fd13f36
Merge branch 'Azure:master' into master
arisettisanjana Sep 20, 2023
1a863f6
Merge branch 'Azure:master' into master
arisettisanjana Sep 22, 2023
93446a9
Merge branch 'Azure:master' into master
arisettisanjana Nov 16, 2023
3bf57c4
Merge branch 'Azure:master' into master
arisettisanjana Nov 17, 2023
821278c
Merge branch 'Azure:master' into master
arisettisanjana Dec 7, 2023
d8f2d2a
guest based changes
arisettisanjana Feb 1, 2024
b544bb3
corrected if
arisettisanjana Feb 1, 2024
ea5cb47
modified the logic
arisettisanjana Feb 8, 2024
76f6baf
configured using flag
arisettisanjana Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions VMBackup/main/HttpUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from common import CommonVariables
from subprocess import *
from Utils.WAAgentUtil import waagent
from parameterparser import ParameterParser
import Utils.HandlerUtil
import sys

Expand Down Expand Up @@ -113,7 +114,7 @@ def Call(self, method, sasuri_obj, data, headers, fallback_to_curl = False):
else:
return CommonVariables.error_http_failure

def HttpCallGetResponse(self, method, sasuri_obj, data, headers , responseBodyRequired = False, isHostCall = False):
def HttpCallGetResponse(self, method, sasuri_obj, data, headers, responseBodyRequired = False, isHostCall = False):
result = CommonVariables.error_http_failure
resp = None
responeBody = ""
Expand All @@ -127,7 +128,13 @@ def HttpCallGetResponse(self, method, sasuri_obj, data, headers , responseBodyRe
if(isHostCall):
connection = httplibs.HTTPConnection(sasuri_obj.hostname, timeout = 40) # making call with port 80 to make it http call
else:
connection = httplibs.HTTPSConnection(sasuri_obj.hostname, timeout = 10)
port_info = ParameterParser.port()
if(port_info != None):
# TTL is enabled, routing to a 8443 port
connection = httplibs.HTTPSConnection(sasuri_obj.hostname, port = port_info, timeout = 10)
else:
self.logger.log("Routing to a default port")
connection = httplibs.HTTPSConnection(sasuri_obj.hostname, timeout = 10)
self.logger.log("Details of sas uri object hostname: " + str(sasuri_obj.hostname) + " path: " + str(sasuri_obj.path))
connection.request(method=method, url=(sasuri_obj.path + '?' + sasuri_obj.query), body=data, headers = headers)
resp = connection.getresponse()
Expand Down
23 changes: 22 additions & 1 deletion VMBackup/main/parameterparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from pickle import NONE
from common import CommonVariables
import base64
import json
import sys

class ParameterParser(object):
port = None
def __init__(self, protected_settings, public_settings, backup_logger):
"""
TODO: we should validate the parameter first
Expand Down Expand Up @@ -125,4 +127,23 @@ def __init__(self, protected_settings, public_settings, backup_logger):
except Exception as e:
errorMsg = "Exception occurred while populating settings, Exception: %s" % (str(e))
backup_logger.log(errorMsg, True)
backup_logger.log("settings to be sent " + str(self.wellKnownSettingFlags), True)
backup_logger.log("settings to be sent " + str(self.wellKnownSettingFlags), True)


createdByKey = "createdby"
createdByValue = "CRP"
if(self.backup_metadata != None):
try:
backup_logger.log("metadata received " + str(self.backup_metadata), True)
for data in self.backup_metadata:
if CommonVariables.key in data and CommonVariables.value in data:
data_key = data[CommonVariables.key].lower()
if(data_key == createdByKey):
data_value = data[CommonVariables.value].upper()
if(data_value == createdByValue):
backup_logger.log("it is a managed vm and request is being routed to Xstore's native path")
ParameterParser.port = 8443
break
except Exception as e:
errorMsg = "Exception occurred while populating metadata, Exception: %s" % (str(e))
backup_logger.log(errorMsg, True)