forked from p15670423/monkey
after first test vs real ESX
tested VLAN enumeration - still need to handle the bad performance
This commit is contained in:
parent
b1d3bbcc0e
commit
5a8954d055
|
@ -121,14 +121,14 @@ function updateJobs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadVcenterConfig() {
|
function loadVcenterConfig() {
|
||||||
$.getJSON('/connector?type=vcenter', function(json) {
|
$.getJSON('/connector?type=VCenterConnector', function(json) {
|
||||||
vcenterCfg.setValue(json);
|
vcenterCfg.setValue(json);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateVcenterConfig() {
|
function updateVcenterConfig() {
|
||||||
var vc_config = vcenterCfg.getValue()
|
var vc_config = vcenterCfg.getValue()
|
||||||
vc_config["type"] = "vcenter";
|
vc_config["type"] = "VCenterConnector";
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
headers : {
|
headers : {
|
||||||
|
|
|
@ -20,21 +20,45 @@ class VCenterConnector(NetControllerConnector):
|
||||||
"resource_pool": ""
|
"resource_pool": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self._job_properties = {
|
self._cache = {
|
||||||
|
"vlans" : []
|
||||||
}
|
}
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
self._service_instance = SmartConnect(host=self._properties["address"],
|
import ssl
|
||||||
port=self._properties["port"],
|
try:
|
||||||
user=self._properties["username"],
|
self._service_instance = SmartConnect(host=self._properties["address"],
|
||||||
pwd=self._properties["password"])
|
port=self._properties["port"],
|
||||||
|
user=self._properties["username"],
|
||||||
|
pwd=self._properties["password"])
|
||||||
|
except ssl.SSLError:
|
||||||
|
# some organizations use self-signed certificates...
|
||||||
|
gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
||||||
|
self._service_instance = SmartConnect(host=self._properties["address"],
|
||||||
|
port=self._properties["port"],
|
||||||
|
user=self._properties["username"],
|
||||||
|
pwd=self._properties["password"],
|
||||||
|
sslContext=gcontext)
|
||||||
|
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
return not self._service_instance == None
|
if (self._service_instance == None):
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
self._service_instance.serverClock
|
||||||
|
except vim.fault.NotAuthenticated, e:
|
||||||
|
return False
|
||||||
|
|
||||||
def get_vlans_list(self):
|
def get_vlans_list(self):
|
||||||
return []
|
if not self.is_connected():
|
||||||
|
self.connect()
|
||||||
|
if self._cache and self._cache.has_key("vlans") and self._cache["vlans"]:
|
||||||
|
return self._cache["vlans"]
|
||||||
|
vcontent = self._service_instance.RetrieveContent() # get updated vsphare state
|
||||||
|
vimtype = [vim.Network]
|
||||||
|
objview = vcontent.viewManager.CreateContainerView(vcontent.rootFolder, vimtype, True)
|
||||||
|
self._cache["vlans"] = [x.name for x in objview.view]
|
||||||
|
objview.Destroy()
|
||||||
|
return self._cache["vlans"]
|
||||||
|
|
||||||
def get_entities_on_vlan(self, vlanid):
|
def get_entities_on_vlan(self, vlanid):
|
||||||
return []
|
return []
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Job(restful.Resource):
|
||||||
class Connector(restful.Resource):
|
class Connector(restful.Resource):
|
||||||
def get(self, **kw):
|
def get(self, **kw):
|
||||||
type = request.args.get('type')
|
type = request.args.get('type')
|
||||||
if (type == 'vcenter'):
|
if (type == 'VCenterConnector'):
|
||||||
vcenter = VCenterConnector()
|
vcenter = VCenterConnector()
|
||||||
properties = mongo.db.connector.find_one({"type": 'VCenterConnector'})
|
properties = mongo.db.connector.find_one({"type": 'VCenterConnector'})
|
||||||
if properties:
|
if properties:
|
||||||
|
@ -82,7 +82,7 @@ class Connector(restful.Resource):
|
||||||
|
|
||||||
def post(self, **kw):
|
def post(self, **kw):
|
||||||
settings_json = json.loads(request.data)
|
settings_json = json.loads(request.data)
|
||||||
if (settings_json.get("type") == 'vcenter'):
|
if (settings_json.get("type") == 'VCenterConnector'):
|
||||||
|
|
||||||
# preserve password
|
# preserve password
|
||||||
properties = mongo.db.connector.find_one({"type": 'VCenterConnector'})
|
properties = mongo.db.connector.find_one({"type": 'VCenterConnector'})
|
||||||
|
@ -179,8 +179,8 @@ def update_connectors():
|
||||||
if not active_connectors[connector_name].is_connected():
|
if not active_connectors[connector_name].is_connected():
|
||||||
refresh_connector_config(connector_name)
|
refresh_connector_config(connector_name)
|
||||||
try:
|
try:
|
||||||
active_connectors[connector_name].connect()
|
|
||||||
app.logger.info("Trying to activate connector: %s" % connector_name)
|
app.logger.info("Trying to activate connector: %s" % connector_name)
|
||||||
|
active_connectors[connector_name].connect()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
active_connectors.pop(connector_name)
|
active_connectors.pop(connector_name)
|
||||||
app.logger.info("Error activating connector: %s, reason: %s" % (connector_name, e))
|
app.logger.info("Error activating connector: %s, reason: %s" % (connector_name, e))
|
||||||
|
|
Loading…
Reference in New Issue