XOS sFlow service and tenant synchronizer fixes
diff --git a/xos/configurations/cord/ceilometer.yaml b/xos/configurations/cord/ceilometer.yaml
index 215a1cc..35922cf 100644
--- a/xos/configurations/cord/ceilometer.yaml
+++ b/xos/configurations/cord/ceilometer.yaml
@@ -50,7 +50,7 @@
             sflow_port:
               type: integer
               required: false
-              default: 6643
+              default: 6343
               description: sFlow listening port
             sflow_api_port:
               type: integer
@@ -86,7 +86,7 @@
       properties:
           view_url: /admin/ceilometer/sflowservice/$id$/
           kind: sflow
-          sflow_port: 6643
+          sflow_port: 6343
           sflow_api_port: 33333
 
     Private:
diff --git a/xos/services/ceilometer/models.py b/xos/services/ceilometer/models.py
index 6c749f3..91d9716 100644
--- a/xos/services/ceilometer/models.py
+++ b/xos/services/ceilometer/models.py
@@ -10,6 +10,7 @@
 from xos.exceptions import *
 from core.models import SlicePrivilege, SitePrivilege
 from sets import Set
+from urlparse import urlparse
 
 CEILOMETER_KIND = "ceilometer"
 
@@ -251,13 +252,13 @@
 
     @property
     def listening_endpoint(self):
-        return self.get_attribute("listening_endpoint", self.default_attributes["listening_endpoint"])
+        return self.get_attribute("listening_endpoint", None)
 
     @listening_endpoint.setter
     def listening_endpoint(self, value):
         if urlparse(value).scheme != 'udp':
             raise XOSProgrammingError("SFlowTenant: Only UDP listening endpoint URLs are accepted...valid syntax is: udp://ip:port")
-        self.listening_endpoint = value
+        self.set_attribute("listening_endpoint", value)
 
     def save(self, *args, **kwargs):
         if not self.creator:
diff --git a/xos/synchronizers/monitoring_channel/steps/sync_sflowservice.py b/xos/synchronizers/monitoring_channel/steps/sync_sflowservice.py
index 0471955..5e5cd83 100644
--- a/xos/synchronizers/monitoring_channel/steps/sync_sflowservice.py
+++ b/xos/synchronizers/monitoring_channel/steps/sync_sflowservice.py
@@ -53,7 +53,8 @@
     def get_extra_attributes(self, o):
         fields={}
         fields["instance_hostname"] = self.get_instance(o).instance_name.replace("_","-")
-        fields["listening_endpoint"] = o.listening_endpoint
+        fields["sflow_port"] = o.sflow_port
+        fields["sflow_api_port"] = o.sflow_api_port
         fields["nat_ip"] = self.get_instance(o).get_ssh_ip()
         fields["sflow_container"] = "sflowpubsub"
         return fields
diff --git a/xos/synchronizers/monitoring_channel/steps/sync_sflowservice.yaml b/xos/synchronizers/monitoring_channel/steps/sync_sflowservice.yaml
index 470fc34..b0b3f50 100644
--- a/xos/synchronizers/monitoring_channel/steps/sync_sflowservice.yaml
+++ b/xos/synchronizers/monitoring_channel/steps/sync_sflowservice.yaml
@@ -4,6 +4,9 @@
   connection: ssh
   user: ubuntu
   sudo: yes
+  vars:
+     sflow_port: {{ sflow_port }}
+     sflow_api_port: {{ sflow_api_port }}
 
   tasks:
 
@@ -48,6 +51,9 @@
       # was: reloaded
       state: running
       image: srikanthvavila/sflowpubsub
+      expose:
+      - {{ sflow_api_port }}
+      - {{ sflow_port }}
       ports:
       - "{{ sflow_port }}:{{ sflow_port }}/udp"
       - "{{ sflow_api_port }}:{{ sflow_api_port }}"
@@ -65,5 +71,4 @@
       port={{ '{{' }} item {{ '}}' }}
       state=present
     with_items:
-    - {{ sflow_port }}
     - {{ sflow_api_port }}
diff --git a/xos/synchronizers/monitoring_channel/steps/sync_sflowtenant.py b/xos/synchronizers/monitoring_channel/steps/sync_sflowtenant.py
index 3e14b1e..a15fa54 100644
--- a/xos/synchronizers/monitoring_channel/steps/sync_sflowtenant.py
+++ b/xos/synchronizers/monitoring_channel/steps/sync_sflowtenant.py
@@ -13,7 +13,7 @@
 from synchronizers.base.ansible import run_template_ssh
 from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
 from core.models import Service, Slice, ControllerSlice, ControllerUser
-from services.ceilometer.models import SFlowTenant
+from services.ceilometer.models import SFlowService, SFlowTenant
 from xos.logger import Logger, logging
 
 # hpclibrary will be in steps/..
@@ -47,12 +47,25 @@
 
         return sflows[0]
 
+    def get_instance(self, o):
+        # We assume the SFlow service owns a slice, so pick one of the instances
+        # inside that slice to sync to.
+
+        serv = self.get_sflow_service(o)
+
+        if serv.slices.exists():
+            slice = serv.slices.all()[0]
+            if slice.instances.exists():
+                return slice.instances.all()[0]
+
+        return None
+
     def get_extra_attributes(self, o):
         instance = self.get_instance(o)
 
         fields={}
-        fields["sflow_api_base_url"] = get_sflow_service(self, o).sflow_api_url
-        fields["sflow_api_port"] = get_sflow_service(self, o).sflow_api_port
+        fields["sflow_api_base_url"] = self.get_sflow_service(o).sflow_api_url
+        fields["sflow_api_port"] = self.get_sflow_service(o).sflow_api_port
         fields["listening_endpoint"] = o.listening_endpoint
         fields["sflow_container"] = "sflowpubsub"