eliminate obsolete code
diff --git a/xos/hpc_observer/hpclib.py b/xos/hpc_observer/hpclib.py
index 0c1a19a..181cc23 100644
--- a/xos/hpc_observer/hpclib.py
+++ b/xos/hpc_observer/hpclib.py
@@ -65,100 +65,29 @@
y = y + c
return y[:20]
- def extract_slice_info(self, service):
- """ Produce a dict that describes the slices for the CMI
-
- slice_coblitz = <name of coblitz slice>
- service_coblitz = <name of coblitz service>
- hostname_coblitz = <name of first coblitz slice>
- hostnames_coblitz = <name_of_first_cob_slice>,<name_of_second_cob_slice>,...
-
- slice_cmi = <name of cmi slice>
- ...
- """
-
- slicenames = {}
- slicehosts = {}
- try:
- slices = service.slices.all()
- except:
- # deal with misnamed attribute in some installations
- slices = service.service.all()
- for slice in slices:
- name = slice.name
- if not ("_" in name):
- continue
-
- if ("coblitz" in name) or ("hpc" in name):
- slicenames["coblitz"] = name
- slicehosts["coblitz"] = [sliver.node.name for sliver in slice.slivers.all()]
- elif "cmi" in name:
- slicenames["cmi"] = name
- slicehosts["cmi"] = [sliver.node.name for sliver in slice.slivers.all()]
- elif "dnsredir" in name:
- slicenames["dnsredir"] = name
- slicehosts["dnsredir"] = [sliver.node.name for sliver in slice.slivers.all()]
- elif "dnsdemux" in name:
- slicenames["dnsdemux"] = name
- slicehosts["dnsdemux"] = [sliver.node.name for sliver in slice.slivers.all()]
-
- base_hrn = None
- if "coblitz" in slicenames:
- base_hrn = slicenames["coblitz"].split("_")[0]
-
- mapping = {}
- mapping["base_hrn"] = base_hrn
- for (k,v) in slicenames.items():
- mapping["slice_" + k] = v
- mapping["service_" + k] = v.split("_",1)[1]
- for (k,v) in slicehosts.items():
- mapping["hostname_" + k] = v[0]
- mapping["hostnames_" + k] = ",".join(v)
-
- return mapping
-
def get_cmi_hostname(self, hpc_service=None):
if (hpc_service is None):
- hpc_service = HpcService.objects.get()
+ hpc_service = HpcService.objects.all()
+ if not hpc_service:
+ raise Exception("No HPC Services")
+ hpc_service = hpc_service[0]
- slice_info = self.extract_slice_info(hpc_service)
- return slice_info["hostname_cmi"]
+ if hpc_service.cmi_hostname:
+ return hpc_service.cmi_hostname
- def write_slices_file(self, hpc_service=None, rr_service=None):
- if (hpc_service is None):
- hpc_service = HpcService.objects.get()
+ try:
+ slices = hpc_service.slices.all()
+ except:
+ # deal with buggy data model
+ slices = hpc_service.service.all()
- if (rr_service is None):
- rr_service = RequestRouterService.objects.get()
+ for slice in slices:
+ if slice.name.endswith("cmi"):
+ for sliver in slice.slivers.all():
+ if sliver.node:
+ return sliver.node.name
- mapping = self.extract_slice_info(hpc_service)
- rr_mapping = self.extract_slice_info(rr_service)
-
- mapping.update(rr_mapping)
-
- fn = "/tmp/slices"
-
- f = open(fn, "w")
- f.write("""
-ENABLE_PLC=True
-ENABLE_PS=False
-BASE_HRN="%(base_hrn)s"
-RELEVANT_SERVICE_NAMES=['%(service_coblitz)s', '%(service_dnsredir)s', '%(service_dnsdemux)s']
-COBLITZ_SLICE_NAME="%(slice_coblitz)s"
-COBLITZ_SLICE_ID=1
-COBLITZ_PS_SLICE_NAME="%(slice_coblitz)s"
-DNSREDIR_SLICE_NAME="%(slice_dnsredir)s"
-DNSREDIR_SLICE_ID=2
-DNSREDIR_PS_SLICE_NAME="%(slice_dnsredir)s"
-DNSDEMUX_SLICE_NAME="%(slice_dnsdemux)s"
-DNSDEMUX_SLICE_ID=3
-DNSDEMUX_PS_SLICE_NAME="%(slice_dnsdemux)s"
-CMI_URL="http://%(hostname_cmi)s"
-CMI_HTTP_PORT="8004"
-CMI_HTTPS_PORT="8003"
-PUPPET_MASTER_HOSTNAME="%(hostname_cmi)s"
-PUPPET_MASTER_PORT="8140"
-""" % mapping)
+ raise Exception("Failed to find a CMI sliver")
@property
def client(self):
@@ -167,11 +96,12 @@
return self._client
if __name__ == '__main__':
- print "testing write_slices_file"
- lib = HpcLibrary()
- lib.write_slices_file()
+ import django
+ django.setup()
- print "testing API connection"
+ lib = HpcLibrary()
+
+ print "testing API connection to", lib.get_cmi_hostname()
lib.client.cob.GetNewObjects()
lib.client.onev.ListAll("CDN")