Skip to content

Commit c4b79e8

Browse files
committed
Agent: delete unused host.get_http_ticket api
Change-Id: Ibec06d11bc90c37ceeac27e1d5e31d5fe5c700bd
1 parent 26db929 commit c4b79e8

File tree

9 files changed

+1
-150
lines changed

9 files changed

+1
-150
lines changed

python/src/host/host/host_handler.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@
7272
from gen.host.ttypes import GetVmNetworkResultCode
7373
from gen.host.ttypes import HostConfig
7474
from gen.host.ttypes import HostMode
75-
from gen.host.ttypes import HttpTicketResponse
76-
from gen.host.ttypes import HttpTicketResultCode
7775
from gen.host.ttypes import MksTicketResponse
7876
from gen.host.ttypes import MksTicketResultCode
7977
from gen.host.ttypes import PowerVmOp
@@ -1511,28 +1509,6 @@ def get_service_ticket(self, request):
15111509
ServiceTicketResultCode.BAD_REQUEST,
15121510
"Operation not supported")
15131511

1514-
@log_request
1515-
@error_handler(HttpTicketResponse, HttpTicketResultCode)
1516-
def get_http_ticket(self, request):
1517-
""" Get HTTP CGI ticket from host.
1518-
1519-
The ticket returned is only for performing the requested HTTP
1520-
operation on the specified URL.
1521-
1522-
:param request: HttpTicketRequest
1523-
:return: HttpTicketResponse
1524-
"""
1525-
try:
1526-
ticket = self.hypervisor.acquire_cgi_ticket(request.url,
1527-
request.op)
1528-
return HttpTicketResponse(HttpTicketResultCode.OK,
1529-
ticket=ticket)
1530-
except:
1531-
return self._error_response(
1532-
HttpTicketResultCode.SYSTEM_ERROR,
1533-
str(sys.exc_info()[1]),
1534-
HttpTicketResponse())
1535-
15361512
@log_request
15371513
@error_handler(MksTicketResponse, MksTicketResultCode)
15381514
def get_mks_ticket(self, request):

python/src/host/host/hypervisor/esx/http_disk_transfer.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
from common.photon_thrift.direct_client import DirectClient
2525
from common.lock import lock_non_blocking
2626
from gen.host import Host
27-
from gen.host.ttypes import HttpTicketRequest
28-
from gen.host.ttypes import HttpTicketResultCode
29-
from gen.host.ttypes import HttpOp
3027
from gen.host.ttypes import PrepareReceiveImageRequest
3128
from gen.host.ttypes import PrepareReceiveImageResultCode
3229
from gen.host.ttypes import ReceiveImageRequest
@@ -127,15 +124,6 @@ def _get_response_data(self, src, read_lease):
127124
(CHUNK_SIZE * counter // (1024 * 1024), progress))
128125
data = src.read(CHUNK_SIZE)
129126

130-
def _get_cgi_ticket(self, host, port, url, http_op=HttpOp.GET):
131-
client = DirectClient("Host", Host.Client, host, port)
132-
client.connect()
133-
request = HttpTicketRequest(op=http_op, url="%s" % url)
134-
response = client.get_http_ticket(request)
135-
if response.result != HttpTicketResultCode.OK:
136-
raise ValueError("No ticket")
137-
return response.ticket
138-
139127
def upload_stream(self, source_file_obj, file_size, url, write_lease, ticket):
140128
protocol, host, selector = self._split_url(url)
141129
self._logger.debug("Upload file of size: %d\nTo URL:\n%s://%s%s\n" %

python/src/host/host/hypervisor/esx/hypervisor.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ def check_image(self, image_id, datastore_id):
7272
def acquire_vim_ticket(self):
7373
return self.vim_client.acquire_clone_ticket()
7474

75-
def acquire_cgi_ticket(self, url, op):
76-
return self.vim_client.acquire_cgi_ticket(url, op)
77-
7875
def add_update_listener(self, listener):
7976
self.vim_client.add_update_listener(listener)
8077

python/src/host/host/hypervisor/esx/vim_client.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from host.hypervisor.vm_manager import VmNotFoundException
4444
from host.hypervisor.esx import logging_wrappers
4545
from gen.agent.ttypes import VmCache, PowerState, TaskState
46-
from gen.host.ttypes import HttpOp
4746

4847
# constants from bora/vim/hostd/private/hostdCommon.h
4948
HA_DATACENTER_ID = "ha-datacenter"
@@ -424,25 +423,6 @@ def acquire_clone_ticket(self):
424423
"""
425424
return self.session_manager.AcquireCloneTicket()
426425

427-
@hostd_error_handler
428-
def acquire_cgi_ticket(self, url, op):
429-
"""
430-
acquire a cgi ticket to perform a HTTP operation on a URL
431-
:return: str, ticket
432-
"""
433-
http_method = vim.SessionManager.HttpServiceRequestSpec.Method
434-
_op_map = {
435-
HttpOp.GET: http_method.httpGet,
436-
HttpOp.PUT: http_method.httpPut,
437-
HttpOp.POST: http_method.httpPost
438-
}
439-
440-
httpsvc_spec = vim.SessionManager.HttpServiceRequestSpec()
441-
httpsvc_spec.url = url
442-
httpsvc_spec.method = _op_map[op]
443-
ticket = self.session_manager.AcquireGenericServiceTicket(httpsvc_spec)
444-
return ticket.id
445-
446426
@hostd_error_handler
447427
def inventory_path(self, *path):
448428
"""

python/src/host/host/hypervisor/fake/hypervisor.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ def acquire_vim_ticket(self):
7272
return 'cst-526d7e8f-b126-1686-9b49-bde6f34f0be8--tp-71-18-5C-87' + \
7373
'-F9-DB-C1-B9-D7-92-7A-19-99-1E-45-56-73-D6-CC-99'
7474

75-
def acquire_cgi_ticket(self, url, op):
76-
return '52524918-2252-f24d-3a2b-2609c0fe795e'
77-
7875
def add_update_listener(self, listener):
7976
# Only triggers VM update listener
8077
self.vm_manager.add_update_listener(listener)

python/src/host/host/hypervisor/hypervisor.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ def cpu_overcommit(self):
143143
def set_cpu_overcommit(self, value):
144144
self.placement_manager.cpu_overcommit = value
145145

146-
def acquire_cgi_ticket(self, url, op):
147-
return self.hypervisor.acquire_cgi_ticket(url, op)
148-
149146
def transfer_image(self, source_image_id, source_datastore,
150147
destination_image_id, destination_datastore,
151148
host, port):

python/src/host/host/tests/integration/test_http_transfer.py

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,19 @@
1010
# License for then specific language governing permissions and limitations
1111
# under the License.
1212

13-
import filecmp
1413
import logging
1514
import os
1615
import re
1716
import tempfile
1817
import unittest
1918

2019
from hamcrest import * # noqa
21-
from mock import patch, MagicMock
20+
from mock import patch
2221
from nose.plugins.skip import SkipTest
2322
from testconfig import config
2423

25-
from gen.host.ttypes import HttpOp
2624
from host.hypervisor.esx.vim_client import VimClient
2725
from host.hypervisor.esx.http_disk_transfer import HttpNfcTransferer
28-
from host.hypervisor.esx.http_disk_transfer import TransferException
2926

3027

3128
class TestHttpTransfer(unittest.TestCase):
@@ -78,47 +75,6 @@ def _datastore_path_url(self, datastore, relpath):
7875
self.host, relpath, quoted_dc_name, datastore)
7976
return url
8077

81-
def test_download_missing_file(self):
82-
url = self._datastore_path_url(self.image_datastore,
83-
"_missing_file_.bin")
84-
ticket = self.http_transferer._get_cgi_ticket(
85-
self.host, self.agent_port, url, http_op=HttpOp.GET)
86-
with tempfile.NamedTemporaryFile(delete=True) as local_file:
87-
self.assertRaises(TransferException,
88-
self.http_transferer.download_file, url,
89-
local_file.name, MagicMock(), ticket=ticket)
90-
91-
def test_upload_file_bad_destination(self):
92-
url = self._datastore_path_url("_missing__datastore_",
93-
"random.bin")
94-
ticket = self.http_transferer._get_cgi_ticket(
95-
self.host, self.agent_port, url, http_op=HttpOp.PUT)
96-
self.assertRaises(
97-
TransferException, self.http_transferer.upload_file,
98-
self.random_file, url, MagicMock(), ticket=ticket)
99-
100-
def test_raw_file_transfer_roundtrip(self):
101-
relpath = "_test_http_xfer_random.bin"
102-
url = self._datastore_path_url(self.image_datastore, relpath)
103-
ticket = self.http_transferer._get_cgi_ticket(
104-
self.host, self.agent_port, url, http_op=HttpOp.PUT)
105-
self.http_transferer.upload_file(self.random_file, url, MagicMock(), ticket=ticket)
106-
107-
self.remote_files_to_delete.append(
108-
self._remote_ds_path(self.image_datastore, relpath))
109-
110-
ticket = self.http_transferer._get_cgi_ticket(
111-
self.host, self.agent_port, url, http_op=HttpOp.GET)
112-
with tempfile.NamedTemporaryFile(delete=True) as downloaded_file:
113-
self.http_transferer.download_file(url, downloaded_file.name,
114-
MagicMock(), ticket=ticket)
115-
# check that file uploaded and immediately downloaded back is
116-
# identical to the source file used.
117-
assert_that(
118-
filecmp.cmp(self.random_file, downloaded_file.name,
119-
shallow=False),
120-
is_(True))
121-
12278
@patch('os.path.exists', return_value=True)
12379
def test_get_streamoptimized_image_stream(self, _exists):
12480
image_id = "ttylinux"

python/src/host/host/tests/integration/test_vim_client.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
import random
1515
import time
1616
import unittest
17-
import uuid
1817

1918
from hamcrest import * # noqa
2019
from mock import MagicMock
2120
from nose.plugins.skip import SkipTest
2221
from testconfig import config
2322

2423
from gen.agent.ttypes import PowerState
25-
from gen.host.ttypes import HttpOp
2624
from host.hypervisor.esx.vim_client import VimClient
2725
from host.hypervisor.esx.vm_config import EsxVmConfig
2826
from host.hypervisor.vm_manager import VmNotFoundException
@@ -268,16 +266,6 @@ def test_clone_ticket(self):
268266
vim_client2 = VimClient(host=self.host, ticket=ticket)
269267
vim_client2.host_system
270268

271-
def test_http_ticket(self):
272-
datastore = self.vim_client.get_datastore().name
273-
filename = "%s.bin" % str(uuid.uuid4())
274-
quoted_dc_name = 'ha%252ddatacenter'
275-
url = 'https://%s/folder/%s?dcPath=%s&dsName=%s' % (
276-
self.host, filename, quoted_dc_name, datastore)
277-
278-
ticket = self.vim_client.acquire_cgi_ticket(url, HttpOp.PUT)
279-
assert_that(ticket, is_not(equal_to(None)))
280-
281269
def test_host_stats(self):
282270
""" Skip host stats test.
283271
This test does not agree with the contract exposed from

thrift/host.thrift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -853,33 +853,6 @@ struct MksTicketResponse {
853853
3: optional resource.MksTicket ticket
854854
}
855855

856-
enum HttpOp {
857-
GET = 0
858-
PUT = 1
859-
POST = 2
860-
}
861-
862-
struct HttpTicketRequest {
863-
// URL to host resource to access via HTTP CGI
864-
1: required string url
865-
866-
// The operation to perform on the URL
867-
2: required HttpOp op
868-
869-
99: optional tracing.TracingInfo tracing_info
870-
}
871-
872-
enum HttpTicketResultCode {
873-
OK = 0
874-
SYSTEM_ERROR = 1
875-
}
876-
877-
struct HttpTicketResponse {
878-
1: required HttpTicketResultCode result
879-
2: optional string error
880-
3: optional string ticket
881-
}
882-
883856
struct GetDatastoresRequest {
884857
99: optional tracing.TracingInfo tracing_info
885858
}
@@ -958,7 +931,6 @@ service Host {
958931

959932
ServiceTicketResponse get_service_ticket(1: ServiceTicketRequest request)
960933
MksTicketResponse get_mks_ticket(1: MksTicketRequest request)
961-
HttpTicketResponse get_http_ticket(1: HttpTicketRequest request)
962934

963935
scheduler.PlaceResponse place(1: scheduler.PlaceRequest request)
964936

0 commit comments

Comments
 (0)