Skip to content

Commit 3719323

Browse files
committed
Merge branch 'master' into fix_#938
2 parents 23a4f2a + 1f96ef7 commit 3719323

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1342
-149
lines changed

completions/bash/multipass

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright © 2017-2019 Canonical Ltd.
1+
# Copyright © 2017-2020 Canonical Ltd.
22
#
33
# This program is free software: you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License version 3 as
@@ -46,8 +46,8 @@ _multipass_complete()
4646
prev="${COMP_WORDS[COMP_CWORD-1]}"
4747
cmd="${COMP_WORDS[1]}"
4848
prev_opts=false
49-
multipass_cmds="transfer delete exec find help info launch list mount purge \
50-
recover shell start stop suspend restart umount version get set"
49+
multipass_cmds="transfer delete exec find help info launch list list-networks mount \
50+
purge recover shell start stop suspend restart umount version get set"
5151

5252
opts="--help --verbose"
5353
case "${cmd}" in
@@ -57,11 +57,14 @@ _multipass_complete()
5757
"list"|"ls")
5858
opts="${opts} --format"
5959
;;
60+
"list-networks"|"ln")
61+
opts="${opts} --format"
62+
;;
6063
"delete")
6164
opts="${opts} --all --purge"
6265
;;
6366
"launch")
64-
opts="${opts} --cpus --disk --mem --name --cloud-init"
67+
opts="${opts} --cpus --disk --mem --name --cloud-init --network"
6568
;;
6669
"mount")
6770
opts="${opts} --gid-map --uid-map"
@@ -87,6 +90,7 @@ _multipass_complete()
8790
_filedir
8891
return
8992
;;
93+
# TODO: add "--network" here
9094
esac
9195
fi
9296

include/multipass/cli/csv_formatter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Canonical, Ltd.
2+
* Copyright (C) 2018-2020 Canonical, Ltd.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@ class CSVFormatter final : public Formatter
2727
public:
2828
std::string format(const InfoReply& info) const override;
2929
std::string format(const ListReply& list) const override;
30+
std::string format(const ListNetworksReply& list) const override;
3031
std::string format(const FindReply& list) const override;
3132
};
3233
}

include/multipass/cli/formatter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Canonical, Ltd.
2+
* Copyright (C) 2018-2020 Canonical, Ltd.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@ class Formatter
3434
virtual ~Formatter() = default;
3535
virtual std::string format(const InfoReply& reply) const = 0;
3636
virtual std::string format(const ListReply& reply) const = 0;
37+
virtual std::string format(const ListNetworksReply& reply) const = 0;
3738
virtual std::string format(const FindReply& reply) const = 0;
3839

3940
protected:

include/multipass/cli/json_formatter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Canonical, Ltd.
2+
* Copyright (C) 2018-2020 Canonical, Ltd.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@ class JsonFormatter final : public Formatter
2727
public:
2828
std::string format(const InfoReply& info) const override;
2929
std::string format(const ListReply& list) const override;
30+
std::string format(const ListNetworksReply& list) const override;
3031
std::string format(const FindReply& list) const override;
3132
};
3233
}

include/multipass/cli/table_formatter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Canonical, Ltd.
2+
* Copyright (C) 2018-2020 Canonical, Ltd.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@ class TableFormatter final : public Formatter
2727
public:
2828
std::string format(const InfoReply& info) const override;
2929
std::string format(const ListReply& list) const override;
30+
std::string format(const ListNetworksReply& list) const override;
3031
std::string format(const FindReply& list) const override;
3132
};
3233
}

include/multipass/cli/yaml_formatter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Canonical, Ltd.
2+
* Copyright (C) 2018-2020 Canonical, Ltd.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@ class YamlFormatter final : public Formatter
2727
public:
2828
std::string format(const InfoReply& info) const override;
2929
std::string format(const ListReply& list) const override;
30+
std::string format(const ListNetworksReply& list) const override;
3031
std::string format(const FindReply& list) const override;
3132
};
3233
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2020 Canonical, Ltd.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; version 3.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*
16+
*/
17+
18+
#ifndef MULTIPASS_NOT_IMPLEMENTED_ON_THIS_BACKEND_EXCEPTION_H
19+
#define MULTIPASS_NOT_IMPLEMENTED_ON_THIS_BACKEND_EXCEPTION_H
20+
21+
#include <stdexcept>
22+
23+
#include <multipass/format.h>
24+
25+
namespace multipass
26+
{
27+
class NotImplementedOnThisBackendException : public std::runtime_error
28+
{
29+
public:
30+
NotImplementedOnThisBackendException(const std::string& feature)
31+
: runtime_error(fmt::format("The {} feature is not implemented on this backend.", feature))
32+
{
33+
}
34+
};
35+
} // namespace multipass
36+
37+
#endif // MULTIPASS_NOT_IMPLEMENTED_ON_THIS_BACKEND_EXCEPTION_H
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2020 Canonical, Ltd.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; version 3.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*
16+
*/
17+
18+
#ifndef MULTIPASS_NETWORK_INTERFACE_H
19+
#define MULTIPASS_NETWORK_INTERFACE_H
20+
21+
#include <string>
22+
23+
namespace multipass
24+
{
25+
struct NetworkInterface
26+
{
27+
std::string id;
28+
std::string mac_address;
29+
bool auto_mode;
30+
};
31+
} // namespace multipass
32+
33+
#endif // MULTIPASS_NETWORK_INTERFACE_H
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2020 Canonical, Ltd.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; version 3.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*
16+
*/
17+
18+
#ifndef MULTIPASS_NETWORK_INTERFACE_INFO_H
19+
#define MULTIPASS_NETWORK_INTERFACE_INFO_H
20+
21+
#include <multipass/ip_address.h>
22+
#include <multipass/optional.h>
23+
24+
namespace multipass
25+
{
26+
struct NetworkInterfaceInfo
27+
{
28+
std::string id;
29+
std::string type;
30+
std::string description;
31+
};
32+
} // namespace multipass
33+
#endif // MULTIPASS_NETWORK_INTERFACE_INFO_H

include/multipass/platform.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <multipass/days.h>
2222
#include <multipass/logging/logger.h>
23+
#include <multipass/network_interface_info.h>
2324
#include <multipass/process/process.h>
2425
#include <multipass/process/process_spec.h>
2526
#include <multipass/sshfs_server_config.h>
@@ -70,6 +71,11 @@ bool is_remote_supported(const std::string& remote);
7071
bool is_image_url_supported();
7172

7273
std::function<int()> make_quit_watchdog(); // call while single-threaded; call result later, in dedicated thread
74+
75+
// Get information on the network interfaces that are seen by the platform, indexed by name
76+
std::map<std::string, NetworkInterfaceInfo> get_network_interfaces_info();
77+
std::string reinterpret_interface_id(const std::string& ux_id); // give platforms a chance to reinterpret network IDs
78+
7379
} // namespace platform
7480
} // namespace multipass
7581
#endif // MULTIPASS_PLATFORM_H

0 commit comments

Comments
 (0)