27
25
from nova import log as logging
28
26
from nova.virt.vmwareapi import vim_util
30
30
flags.DEFINE_integer('console_vmrc_port',
32
32
"port for VMware VMRC connections")
71
69
def generate_password(self, vim_session, pool, instance_name):
73
Returns VMRC Connection credentials.
70
"""Returns VMRC Connection credentials.
75
72
Return string is of the form '<VM PATH>:<ESX Username>@<ESX Password>'.
77
75
username, password = pool['username'], pool['password']
78
vms = vim_session._call_method(vim_util, "get_objects",
79
"VirtualMachine", ["name", "config.files.vmPathName"])
76
vms = vim_session._call_method(vim_util, 'get_objects',
77
'VirtualMachine', ['name', 'config.files.vmPathName'])
80
78
vm_ds_path_name = None
84
82
ds_path_name = None
85
83
for prop in vm.propSet:
86
if prop.name == "name":
84
if prop.name == 'name':
88
elif prop.name == "config.files.vmPathName":
86
elif prop.name == 'config.files.vmPathName':
89
87
ds_path_name = prop.val
90
88
if vm_name == instance_name:
92
90
vm_ds_path_name = ds_path_name
95
raise exception.NotFound(_("instance - %s not present") %
97
json_data = json.dumps({"vm_id": vm_ds_path_name,
99
"password": password})
93
raise exception.InstanceNotFound(instance_id=instance_name)
94
json_data = json.dumps({'vm_id': vm_ds_path_name,
96
'password': password})
100
97
return base64.b64encode(json_data)
115
112
return 'vmrc+session'
117
114
def generate_password(self, vim_session, pool, instance_name):
119
Returns a VMRC Session.
115
"""Returns a VMRC Session.
121
117
Return string is of the form '<VM MOID>:<VMRC Ticket>'.
123
vms = vim_session._call_method(vim_util, "get_objects",
124
"VirtualMachine", ["name"])
120
vms = vim_session._call_method(vim_util, 'get_objects',
121
'VirtualMachine', ['name'])
127
124
if vm.propSet[0].val == instance_name:
129
126
if vm_ref is None:
130
raise exception.NotFound(_("instance - %s not present") %
127
raise exception.InstanceNotFound(instance_id=instance_name)
132
128
virtual_machine_ticket = \
133
129
vim_session._call_method(
134
130
vim_session._get_vim(),
135
"AcquireCloneTicket",
131
'AcquireCloneTicket',
136
132
vim_session._get_vim().get_service_content().sessionManager)
137
json_data = json.dumps({"vm_id": str(vm_ref.value),
138
"username": virtual_machine_ticket,
139
"password": virtual_machine_ticket})
133
json_data = json.dumps({'vm_id': str(vm_ref.value),
134
'username': virtual_machine_ticket,
135
'password': virtual_machine_ticket})
140
136
return base64.b64encode(json_data)
142
138
def is_otp(self):