Exemplo n.º 1
0
    def delete(self, params):
        """Delete the specified network groups
               fuel network-group --delete --network 1
               fuel network-group --delete --network 2,3,4
        """
        ngs = NetworkGroup.get_by_ids(params.network)
        for n in ngs:
            NetworkGroup.delete(n.id)

        self.serializer.print_to_output(
            {},
            "Network groups with IDS {0} have been deleted.".format(
                ','.join(params.network))
        )
Exemplo n.º 2
0
    def create(self, params):
        """Create a new network group
               fuel network-group --create --node-group 1 --name "new network"
                --release 2 --vlan 100 --cidr 10.0.0.0/24
        """
        NetworkGroup.create(
            params.name,
            params.release,
            params.vlan,
            params.cidr,
            params.gateway,
            int(params.nodegroup.pop()),
            params.meta
        )

        self.serializer.print_to_output(
            {},
            "Network group {0} has been created".format(params.name)
        )
Exemplo n.º 3
0
    def set(self, params):
        """Set parameters for the specified network group:
            fuel network-group --set --network 1 --name new_name
        """
        # Since network has set type and we cannot update multiple network
        # groups at once, we pick first network group id from set.
        ng_id = next(iter(params.network))

        if len(params.network) > 1:
            msg = ("Warning: Only first network with id={0}"
                   " will be updated.".format(ng_id))
            six.print_(msg, file=sys.stderr)

        ng = NetworkGroup(ng_id)

        update_params = get_args_for_update(params, self.serializer)
        data = ng.set(update_params)

        self.serializer.print_to_output(
            data,
            "Network group id={0} has been updated".format(ng_id))
Exemplo n.º 4
0
    def create(self, params):
        """Create a new network group
               fuel network-group --create --node-group 1 --name "new network"
                --release 2 --vlan 100 --cidr 10.0.0.0/24

               fuel network-group --create --node-group 2 --name "new network"
               --release 2 --vlan 100 --cidr 10.0.0.0/24 --gateway 10.0.0.1
               --meta 'meta information in JSON format'
        """
        meta = self.serializer.deserialize(params.meta) if params.meta else {}

        NetworkGroup.create(
            params.name,
            params.release,
            params.vlan,
            params.cidr,
            params.gateway,
            int(params.nodegroup.pop()),
            meta
        )
        self.serializer.print_to_output(
            {},
            "Network group {0} has been created".format(params.name)
        )