Esempio n. 1
0
            def add_deployed_model_remove_from_hangar(c, target):
                path = canonical_path(target)
                target = traverse1(path)

                cpath = canonical_path(c)
                c = traverse1(cpath)
                if c is None:
                    raise Exception('Compute not found: "%s"' % cpath)

                new_compute = Compute(unicode(hostname), u'inactive')
                new_compute.__name__ = name
                new_compute.__owner__ = owner_obj
                new_compute.template = unicode(template)
                new_compute._ipv4_address = unicode(ipaddr)
                new_compute.mac_address = getattr(c, 'mac_address', None)
                new_compute.memory = getattr(c, 'memory', 0)
                new_compute.diskspace = getattr(c, 'diskspace', {u'total': 0})
                new_compute.num_cores = getattr(c, 'num_cores', 0)
                new_compute.license_activated = getattr(
                    c, 'license_activated', True)

                alsoProvides(new_compute, IVirtualCompute)
                alsoProvides(new_compute, IDeployed)
                noLongerProvides(new_compute, IManageable)
                target.add(new_compute)

                container = c.__parent__
                del container[name]

                timestamp = int(time.time() * 1000)
                IStream(new_compute).add((timestamp, {
                    'event': 'change',
                    'name': 'features',
                    'value': new_compute.features,
                    'old_value': self.context.features
                }))
                IStream(new_compute).add((timestamp, {
                    'event':
                    'change',
                    'name':
                    'ipv4_address',
                    'value':
                    new_compute._ipv4_address,
                    'old_value':
                    self.context._ipv4_address
                }))
Esempio n. 2
0
            def add_deployed_model_remove_from_hangar(c, target):
                path = canonical_path(target)
                target = traverse1(path)

                cpath = canonical_path(c)
                c = traverse1(cpath)
                if c is None:
                    raise Exception('Compute not found: "%s"' % cpath)

                new_compute = Compute(unicode(hostname), u'inactive')
                new_compute.__name__ = name
                new_compute.__owner__ = owner_obj
                new_compute.template = unicode(template)
                new_compute._ipv4_address = unicode(ipaddr)
                new_compute.mac_address = getattr(c, 'mac_address', None)
                new_compute.memory = getattr(c, 'memory', 0)
                new_compute.diskspace = getattr(c, 'diskspace', {u'total': 0})
                new_compute.num_cores = getattr(c, 'num_cores', 0)

                alsoProvides(new_compute, IVirtualCompute)
                alsoProvides(new_compute, IDeployed)
                noLongerProvides(new_compute, IManageable)
                target.add(new_compute)

                container = c.__parent__
                del container[name]

                timestamp = int(time.time() * 1000)
                IStream(new_compute).add((timestamp, {'event': 'change',
                                                      'name': 'features',
                                                      'value': new_compute.features,
                                                      'old_value': self.context.features}))
                IStream(new_compute).add((timestamp, {'event': 'change',
                                                      'name': 'ipv4_address',
                                                      'value': new_compute._ipv4_address,
                                                      'old_value': self.context._ipv4_address}))
Esempio n. 3
0
 def update():
     machines = db.get_root()['oms_root']['machines']
     machine = Compute(unicode(host), u'active', mgt_stack=mgt_stack)
     machine.__name__ = str(uuid5(NAMESPACE_DNS, host))
     machines.add(machine)
     return machine.__name__
Esempio n. 4
0
 def update():
     machines = db.get_root()['oms_root']['machines']
     machine = Compute(unicode(host), u'active', mgt_stack=mgt_stack)
     machine.__name__ = str(uuid5(NAMESPACE_DNS, host))
     machines.add(machine)
     return machine.__name__