Exemple #1
0
    def set_slot(self, slot_number, slot_type):
        """ Adds a module in a slot
            slot_number: integer
            slot_type: string
        """

        try:
            self.dynagen.setproperty(self.router, 'slot' + str(slot_number), slot_type)
        except (TypeError, ValueError, lib.DynamipsError), e:
            error(e)
Exemple #2
0
    def set_slot(self, slot_number, slot_type):
        """ Adds a module in a slot
            slot_number: integer
            slot_type: string
        """

        try:
            self.dynagen.setproperty(self.router, 'slot' + str(slot_number),
                                     slot_type)
        except (TypeError, ValueError, lib.DynamipsError), e:
            error(e)
Exemple #3
0
    def set_config(self, config):
        """ Set a configuration in Dynamips
            config: dict
        """

        assert(self.router)
        # apply the options
        for option in self.router_options:
            try:
                router_option = getattr(self.router, option)
            except AttributeError:
                continue
            if router_option != config[option]:
                try:
                    setattr(self.router, option, config[option])
                except lib.DynamipsError, e:
                    error(e)
Exemple #4
0
    def set_config(self, config):
        """ Set a configuration in Qemu
            config: dict
        """

        assert(self.emudev)
        # apply the options
        for option in self.emudev_options:
            try:
                emu_option = getattr(self.emudev, option)
            except AttributeError:
                continue
            if emu_option != config[option]:
                try:
                    setattr(self.emudev, option, config[option])
                except lib.DynamipsError, e:
                    error(e)
Exemple #5
0
    def set_config(self, config):
        """ Set a configuration in Dynamips
            config: dict
        """

        assert (self.router)
        # apply the options
        for option in self.router_options:
            try:
                router_option = getattr(self.router, option)
            except AttributeError:
                continue
            if router_option != config[option]:
                try:
                    setattr(self.router, option, config[option])
                except lib.DynamipsError, e:
                    error(e)
Exemple #6
0
    def set_config(self, config):
        """ Set a configuration in Qemu
            config: dict
        """

        assert (self.emudev)
        # apply the options
        for option in self.emudev_options:
            try:
                emu_option = getattr(self.emudev, option)
            except AttributeError:
                continue
            if emu_option != config[option]:
                try:
                    setattr(self.emudev, option, config[option])
                except lib.DynamipsError, e:
                    error(e)
    def set_config(self, config):
        """ Set a configuration in VBox
            config: dict
        """
        #print "AnyVBoxEmuDevice::set_config()"

        assert (self.emu_vboxdev)
        # apply the options
        for option in self.emu_vboxdev_options:
            try:
                emu_option = getattr(self.emu_vboxdev, option)
            except AttributeError:
                continue

            if emu_option != config[option]:
                try:
                    setattr(self.emu_vboxdev, option, config[option])
                except lib.DynamipsError, e:
                    error(e)
Exemple #8
0
    def set_config(self, config):
        """ Set a configuration in VBox
            config: dict
        """
        #print "AnyVBoxEmuDevice::set_config()"

        assert(self.emu_vboxdev)
        # apply the options
        for option in self.emu_vboxdev_options:
            try:
                emu_option = getattr(self.emu_vboxdev, option)
            except AttributeError:
                continue

            if emu_option != config[option]:
                try:
                    setattr(self.emu_vboxdev, option, config[option])
                except lib.DynamipsError, e:
                    error(e)
Exemple #9
0
    def get_devdefaults(self):
        """ Get device defaults
        """

        model = self.model
        devdefaults = {}
        for key in dynagen_namespace.DEVICETUPLE:
            devdefaults[key] = {}

        config = globals.GApp.dynagen.defaults_config

        #go through all section under dynamips server in running config and populate the devdefaults with model defaults
        for r in config[self.d]:
            router_model = config[self.d][r]
            # compare whether this is defaults section
            if router_model.name in dynagen_namespace.DEVICETUPLE and router_model.name == model:
                # Populate the appropriate dictionary
                for scalar in router_model.scalars:
                    if router_model[scalar] != None:
                        devdefaults[router_model.name][scalar] = router_model[scalar]

        #check whether a defaults section for this router type exists
        if model in dynagen_namespace.DEVICETUPLE:
            if devdefaults[model] == {} and not devdefaults[model].has_key('image'):
                error('Create a defaults section for ' + model + ' first! Minimum setting is image name')
                return False
            elif not devdefaults[model].has_key('image'):
                error('Specify image name for ' + model + ' routers first!')
                return False
        else:
            error('Bad model: ' + model)
            return False
        return devdefaults
Exemple #10
0
    def get_devdefaults(self):
        """ Get device defaults
        """

        model = self.model
        devdefaults = {}
        for key in dynagen_namespace.DEVICETUPLE:
            devdefaults[key] = {}

        config = globals.GApp.dynagen.defaults_config
        #go through all section under dynamips server in running config and populate the devdefaults with model defaults
        for f in config[self.d]:
            device_model = config[self.d][f]

            # compare whether this is defaults section
            if device_model.name in dynagen_namespace.DEVICETUPLE and device_model.name == model:
                # Populate the appropriate dictionary
                for scalar in device_model.scalars:
                    if device_model[scalar] != None:
                        devdefaults[device_model.name][scalar] = device_model[scalar]

        #check whether a defaults section for this router type exists
        if model in dynagen_namespace.DEVICETUPLE:
            if devdefaults[model] == {} and not devdefaults[model].has_key('image'):
                error('Create a defaults section for ' + model + ' first! Minimum setting is image name')
                return False
            # check if an image has been configured first (not for ASA, AWP and IDS)
            elif not devdefaults[model].has_key('image') and model != '5520' and model != 'Soft32' and model != 'IDS-4215':
                error('Specify image name for ' + model + ' device first!')
                return False
        else:
            error('Bad model: ' + model)
            return False
        return devdefaults
Exemple #11
0
    def get_devdefaults(self):
        """ Get device defaults
        """

        model = self.model
        devdefaults = {}
        for key in dynagen_namespace.DEVICETUPLE:
            devdefaults[key] = {}

        config = globals.GApp.dynagen.defaults_config
        #go through all section under dynamips server in running config and populate the devdefaults with model defaults
        for f in config[self.d]:
            device_model = config[self.d][f]

            # compare whether this is defaults section
            if device_model.name in dynagen_namespace.DEVICETUPLE and device_model.name == model:
                # Populate the appropriate dictionary
                for scalar in device_model.scalars:
                    if device_model[scalar] != None:
                        devdefaults[
                            device_model.name][scalar] = device_model[scalar]

        #check whether a defaults section for this router type exists
        if model in dynagen_namespace.DEVICETUPLE:
            if devdefaults[model] == {} and not devdefaults[model].has_key(
                    'image'):
                error('Create a defaults section for ' + model +
                      ' first! Minimum setting is image name')
                return False
            # check if an image has been configured first (not for ASA, AWP and IDS)
            elif not devdefaults[model].has_key(
                    'image'
            ) and model != '5520' and model != 'Soft32' and model != 'IDS-4215':
                error('Specify image name for ' + model + ' device first!')
                return False
        else:
            error('Bad model: ' + model)
            return False
        return devdefaults
Exemple #12
0
    def get_devdefaults(self):
        """ Get device defaults
        """

        model = self.model
        devdefaults = {}
        for key in dynagen_namespace.DEVICETUPLE:
            devdefaults[key] = {}

        config = globals.GApp.dynagen.defaults_config

        #go through all section under dynamips server in running config and populate the devdefaults with model defaults
        for r in config[self.d]:
            router_model = config[self.d][r]
            # compare whether this is defaults section
            if router_model.name in dynagen_namespace.DEVICETUPLE and router_model.name == model:
                # Populate the appropriate dictionary
                for scalar in router_model.scalars:
                    if router_model[scalar] != None:
                        devdefaults[
                            router_model.name][scalar] = router_model[scalar]

        #check whether a defaults section for this router type exists
        if model in dynagen_namespace.DEVICETUPLE:
            if devdefaults[model] == {} and not devdefaults[model].has_key(
                    'image'):
                error('Create a defaults section for ' + model +
                      ' first! Minimum setting is image name')
                return False
            elif not devdefaults[model].has_key('image'):
                error('Specify image name for ' + model + ' routers first!')
                return False
        else:
            error('Bad model: ' + model)
            return False
        return devdefaults