コード例 #1
0
    def getVMs(self):
        """ getVMs - Get all volumes of docker containers
        """
        machines = []
        volumePath = self.getVolumePath('')

        for host in self.hosts:
            volumes = subprocess.check_output(["ssh"] + DistDocker._SSH_FLAGS +
                                                DistDocker._SSH_AUTH_FLAGS +
                                                ["%s@%s" % (self.hostUser, host),
                                                "(ls %s)" % volumePath]).split('\n')
            for volume in volumes:
                if re.match("%s-" % config.Config.PREFIX, volume):
                    machine = TangoMachine()
                    machine.vmms = 'distDocker'
                    machine.name = volume
                    machine.domain_name = host
                    volume_l = volume.split('-')
                    machine.id = volume_l[1]
                    machine.image = volume_l[2]
                    machine.ssh_control_dir = tempfile.mkdtemp(prefix="tango-docker-ssh")
                    machine.ssh_flags = ['-o', 'ControlPath=' + os.path.join(machine.ssh_control_dir, "control")]
                    machine.use_ssh_master = config.Config.USE_SSH_MASTER
                    machines.append(machine)
        return machines
コード例 #2
0
ファイル: distDocker.py プロジェクト: mojojojo99/Tango
 def getVMs(self):
     """ getVMs - Get all volumes of docker containers
     """
     machines = []
     try:
         hosts=socket.gethostbyname_ex(self.hostDNSPoolname)[2]
     except EnvironmentError:
         return machines
     volumePath = self.getVolumePath('')
     for host in hosts:
         volumes = subprocess.check_output(["ssh"] + DistDocker._SSH_FLAGS +
                                             DistDocker._SSH_AUTH_FLAGS +
                                             ["%s@%s" % (self.hostUser, host),
                                             "(ls %s)" % volumePath]).decode('utf-8').split('\n')
         for volume in volumes:
             if re.match("%s-" % config.Config.PREFIX, volume):
                 machine = TangoMachine()
                 machine.vmms = 'distDocker'
                 machine.name = volume
                 machine.domain_name = host
                 machine.ssh_flags = DistDocker._SSH_AUTH_FLAGS
                 machine.use_ssh_master = False
                 volume_l = volume.split('-')
                 machine.id = volume_l[1]
                 machine.image = volume_l[2]
                 machines.append(machine)
     return machines
コード例 #3
0
ファイル: distDocker.py プロジェクト: cg2v/Tango
 def getVMs(self):
     """ getVMs - Get all volumes of docker containers
     """
     machines = []
     try:
         hosts=socket.gethostbyname_ex(self.hostDNSPoolname)[2]
     except EnvironmentError:
         return machines
     volumePath = self.getVolumePath('')
     for host in hosts:
         volumes = subprocess.check_output(["ssh"] + DistDocker._SSH_FLAGS +
                                             DistDocker._SSH_AUTH_FLAGS +
                                             ["%s@%s" % (self.hostUser, host),
                                             "(ls %s)" % volumePath]).split('\n')
         for volume in volumes:
             if re.match("%s-" % config.Config.PREFIX, volume):
                 machine = TangoMachine()
                 machine.vmms = 'distDocker'
                 machine.name = volume
                 machine.domain_name = host
                 machine.ssh_flags = DistDocker._SSH_AUTH_FLAGS
                 machine.use_ssh_master = False
                 volume_l = volume.split('-')
                 machine.id = volume_l[1]
                 machine.image = volume_l[2]
                 machines.append(machine)
     return machines
コード例 #4
0
ファイル: localDocker.py プロジェクト: Ben0mega/Tango
 def getVMs(self):
     """ getVMs - Executes and parses `docker ps`. This function
     is a lot of parsing and can break easily.
     """
     # Get all volumes of docker containers
     machines = []
     volumePath = self.getVolumePath('')
     for volume in os.listdir(volumePath):
         if re.match("%s-" % config.Config.PREFIX, volume):
             machine = TangoMachine()
             machine.vmms = 'localDocker'
             machine.name = volume
             volume_l = volume.split('-')
             machine.id = volume_l[1]
             machine.image = volume_l[2]
             machines.append(machine)
     return machines
コード例 #5
0
 def createTangoMachine(self, image, vmms, vmObj={"cores": 1, "memory": 512}):
     """createTangoMachine - Creates a tango machine object from image"""
     return TangoMachine(
         name=image,
         vmms=vmms,
         image="%s" % (image),
         cores=vmObj["cores"],
         memory=vmObj["memory"],
         disk=None,
         network=None,
     )
コード例 #6
0
 def createTangoMachine(self, image, vmms=Config.VMMS_NAME,
                        vmObj={'cores': 1, 'memory': 512}):
     """ createTangoMachine - Creates a tango machine object from image
     """
     return TangoMachine(
         name=image,
         vmms=vmms,
         image="%s" % (image),
         cores=vmObj["cores"],
         memory=vmObj["memory"],
         disk=None,
         network=None)
コード例 #7
0
 def createTangoMachine(self, image, vmms=Config.VMMS_NAME,
         vmObj={'cores': 1, 'memory': 512, 'fallback_instance_type': 't2.nano'}):
     """ createTangoMachine - Creates a tango machine object from image
     """
     return TangoMachine(
         name=image,
         vmms=vmms,
         image="%s" % (image),
         cores=vmObj["cores"],
         memory=vmObj["memory"],
         fallback_instance_type=vmObj["fallback_instance_type"],
         disk=None,
         network=None)
コード例 #8
0
ファイル: ec2SSH.py プロジェクト: cg2v/Tango
    def getVMs(self):
        """ getVMs - Returns the complete list of VMs on this account. Each
        list entry is a boto.ec2.instance.Instance object.
        """
        # TODO: Find a way to return vm objects as opposed ec2 instance
        # objects.
        instances = list()
        for i in self.connection.get_all_instances():
            if i.id is not config.Config.TANGO_RESERVATION_ID:
                inst = i.instances.pop()
                if inst.state_code is config.Config.INSTANCE_RUNNING:
                    instances.append(inst)

        vms = list()
        for inst in instances:
            vm = TangoMachine()
            vm.ec2_id = inst.id
            vm.name = str(inst.tags.get('Name'))
            self.log.debug('getVMs: Instance - %s, EC2 Id - %s' %
                           (vm.name, vm.ec2_id))
            vms.append(vm)

        return vms
コード例 #9
0
    def getVMs(self):
        """getVMs - Returns the complete list of VMs on this account. Each
        list entry is a boto.ec2.instance.Instance object.
        """
        # TODO: Find a way to return vm objects as opposed ec2 instance
        # objects.
        instances = list()
        for i in self.connection.get_all_instances():
            if i.id is not config.Config.TANGO_RESERVATION_ID:
                inst = i.instances.pop()
                if inst.state_code is config.Config.INSTANCE_RUNNING:
                    instances.append(inst)

        vms = list()
        for inst in instances:
            vm = TangoMachine()
            vm.ec2_id = inst.id
            vm.name = str(inst.tags.get("Name"))
            self.log.debug("getVMs: Instance - %s, EC2 Id - %s" %
                           (vm.name, vm.ec2_id))
            vms.append(vm)

        return vms
コード例 #10
0
ファイル: localDocker.py プロジェクト: icanb/Tango
 def getVMs(self):
     """ getVMs - Executes and parses `docker ps`
     """
     # Get all volumes of docker containers
     machines = []
     volumePath = self.getVolumePath('')
     for volume in os.listdir(volumePath):
         if re.match("%s-" % config.Config.PREFIX, volume):
             machine = TangoMachine()
             machine.vmms = 'localDocker'
             machine.name = volume
             volume_l = volume.split('-')
             machine.id = volume_l[1]
             machine.image = volume_l[2]
             machines.append(machine)
     return machines
コード例 #11
0
ファイル: localDocker.py プロジェクト: practischool/Tango
 def getVMs(self):
     """getVMs - Executes and parses `docker ps`. This function
     is a lot of parsing and can break easily.
     """
     # Get all volumes of docker containers
     machines = []
     volumePath = self.getVolumePath("")
     for volume in os.listdir(volumePath):
         if re.match("%s-" % config.Config.PREFIX, volume):
             machine = TangoMachine()
             machine.vmms = "localDocker"
             machine.name = volume
             volume_l = volume.split("-")
             machine.id = volume_l[1]
             machine.image = volume_l[2]
             machines.append(machine)
     return machines
コード例 #12
0
def createInstances(num):
    for imageName in pools:
        (poolName, ext) = os.path.splitext(imageName)
        print "creating", num, "for pool", poolName
        vm = TangoMachine(vmms="ec2SSH", image=imageName)
        server.preallocVM(vm, num)