Ejemplo n.º 1
0
 def update(self):
     db_api.loadbalancer_update(self.conf, self.lb['id'], self.lb)
     for st in self.sf._sticky:
         db_api.sticky_update(self.conf, st['id'], st)
     for rs in self.rs:
         db_api.server_update(self.conf, rs['id'], rs)
     for pr in self.probes:
         db_api.probe_update(self.conf, pr['id'], pr)
     for vip in self.vips:
         db_api.virtualserver_update(self.conf, vip['id'], vip)
Ejemplo n.º 2
0
 def test_sticky_update(self):
     values = get_fake_sticky('1')
     sticky_ref = db_api.sticky_create(self.conf, values)
     update = {'name': 'test',
               'extra': {'cookieName': 'testHTTPCookie',
                         'enableInsert': True,
                         'browserExpire': False,
                         'offset': False,
                         'length': 1000,
                         'secondaryName': 'cookie'}}
     sticky_ref = db_api.sticky_update(self.conf, sticky_ref['id'], update)
     sticky = dict(sticky_ref.iteritems())
     values.update(update)
     self.assertIsNotNone(sticky['id'])
     values['id'] = sticky['id']
     self.assertEqual(sticky, values)
 def test_sticky_update(self):
     values = get_fake_sticky("1")
     sticky_ref = db_api.sticky_create(self.conf, values)
     update = {
         "name": "test",
         "extra": {
             "cookieName": "testHTTPCookie",
             "enableInsert": True,
             "browserExpire": False,
             "offset": False,
             "length": 1000,
             "secondaryName": "cookie",
         },
     }
     sticky_ref = db_api.sticky_update(self.conf, sticky_ref["id"], update)
     sticky = dict(sticky_ref.iteritems())
     values.update(update)
     self.assertIsNotNone(sticky["id"])
     values["id"] = sticky["id"]
     self.assertEqual(sticky, values)
Ejemplo n.º 4
0
def delete_sticky(ctx, sticky):
    ctx.device.delete_stickiness(sticky)
    sticky['deployed'] = 'False'
    db_api.sticky_update(ctx.conf, sticky['id'], sticky)
Ejemplo n.º 5
0
def create_sticky(ctx, sticky):
    ctx.device.create_stickiness(sticky)
    sticky['deployed'] = 'True'
    db_api.sticky_update(ctx.conf, sticky['id'], sticky)
Ejemplo n.º 6
0
def delete_sticky(ctx, sticky):
    ctx.device.delete_stickiness(sticky)
    sticky["deployed"] = "False"
    db_api.sticky_update(ctx.conf, sticky["id"], sticky)
Ejemplo n.º 7
0
def create_sticky(ctx, sticky):
    ctx.device.create_stickiness(sticky)
    sticky["deployed"] = "True"
    db_api.sticky_update(ctx.conf, sticky["id"], sticky)
Ejemplo n.º 8
0
    def savetoDB(self):
        try:
            lb_ref = db_api.loadbalancer_update(self.conf, self.lb['id'],
                                                self.lb)
        except exception.LoadBalancerNotFound:
            lb_ref = db_api.loadbalancer_create(self.conf, self.lb)

        self.sf['lb_id'] = lb_ref['id']
        try:
            sf_ref = db_api.serverfarm_update(self.conf, self.sf['id'],
                                              self.sf)
        except exception.ServerFarmNotFound:
            sf_ref = db_api.serverfarm_create(self.conf, self.sf)

        self.sf._predictor['sf_id'] = sf_ref['id']
        try:
            db_api.predictor_update(self.conf, self.sf._predictor['id'],
                                    self.sf._predictor)
        except exception.PredictorNotFound:
            db_api.predictor_create(self.conf, self.sf._predictor)

        stickies = self.sf._sticky
        vips = []

        self.sf = sf_ref
        self.sf._rservers = []
        self.sf._probes = []
        self.sf._sticky = []

        for rs in self.rs:
            rs['sf_id'] = sf_ref['id']
            try:
                rs_ref = db_api.server_update(self.conf, rs['id'], rs)
            except exception.ServerNotFound:
                rs_ref = db_api.server_create(self.conf, rs)
            self.sf._rservers.append(rs_ref)

        for pr in self.probes:
            pr['sf_id'] = sf_ref['id']
            try:
                pr_ref = db_api.probe_update(self.conf, pr['id'], pr)
            except exception.ProbeNotFound:
                pr_ref = db_api.probe_create(self.conf, pr)
            self.sf._probes.append(pr_ref)

        for vip in self.vips:
            vip['sf_id'] = sf_ref['id']
            vip['lb_id'] = lb_ref['id']
            try:
                vip_ref = db_api.virtualserver_update(self.conf, vip['id'],
                                                      vip)
            except exception.VirtualServerNotFound:
                vip_ref = db_api.virtualserver_create(self.conf, vip)
            vips.append(vip_ref)

        for st in stickies:
            st['sf_id'] = sf_ref['id']
            try:
                st_ref = db_api.sticky_update(self.conf, st['id'], st)
            except exception.StickyNotFound:
                st_ref = db_api.sticky_create(self.conf, st)
            self.sf._sticky.append(st_ref)

        self.rs = self.sf._rservers
        self.probes = self.sf._probes
        self.vips = vips